Version: 1.1.1

org.biomoby.shared.data
Class MobyContentInstance

java.lang.Object
  extended by org.biomoby.shared.data.MobyContentInstance
All Implemented Interfaces:
Map<String,MobyDataJob>

public class MobyContentInstance
extends Object
implements Map<String,MobyDataJob>

This class represents the data package sent back and forth between clients and servers. Currently, this corresponds to the "mobyContent" element and children in the MOBY API. It holds a named collection of data groups, which could correspond to either queries or responses depending on its use. It contains also two ancillary pieces of information populated by service providers: the service notes (generally, human readable text describing the service), and the authority URI (points to more info about the service). This class implements MobyDataInstance because it does have an XML representation of MOBY instance data, but using it in CENTRAL_XML_MODE does not currently have a solidly defined behaviour (what if it's a mixed bag of different data?). The Map interface is implemented to make it easier to fetch, enumerate, and merge content objects and their subgroups.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
MobyContentInstance()
          Creates a blank MOBY envelope, to be filled in programatically with data instances.
MobyContentInstance(Element objectTag)
          Builds a MobyContentInstance (i.e. one or more MOBY queries or responses) using a DOM-parsed XML MOBY envelope (i.e. the mobyContent tag).
MobyContentInstance(Element objectTag, Registry registry)
           
MobyContentInstance(MobyDataInstance mdi, String paramName)
          A convenience constructor when you want to create an envelope with just one object in it.
 
Method Summary
 void addException(ServiceException me)
          Adds a new exception to the list of exceptions associated with the content
 void clear()
          Effectively deletes the contents, leaving you with a data-less container.
 boolean containsKey(Object fieldName)
          To check for the presence of a data group with a given name
 boolean containsValue(Object value)
          To check for the presence of a data group as one of the members
 Set<Map.Entry<String,MobyDataJob>> entrySet()
          Retrieves each name/data group pair for the members of content.
 boolean equals(Object o)
          Returns true if and only if both query sets have the same queries with the same values
 MobyDataJob get(Object fieldName)
          Retrieves a member (AbstractMap) of the composite with a given field name.
 ServiceException[] getExceptions()
           
 String getServiceAuthorityURI()
           
 String getServiceNotes()
           
 int getXmlMode()
          Report whether toXML will produce Central template or service call instance XML.
 boolean hasExceptions()
          Indicates whether the moby content has any exception (according to the style of MOBY-S RFC 1863)
 boolean hasExceptions(int severity)
          Indicates whether the moby content has any exception of the given severity or worse (according to the style of MOBY-S RFC 1863).
 int hashCode()
           
 boolean isEmpty()
          Is this a blank, uninstantiated object?
 Set<String> keySet()
          Retrieves a list of the query names in this object.
 void parseDataGroup(Element dataGroupTag, Registry registry)
           
 void put(MobyDataJob value)
          same as put(String, MobyDataJob), but the queryID will be automatically generated for this value
 MobyDataJob put(String queryID, MobyDataJob value)
           
 void putAll(Map<? extends String,? extends MobyDataJob> map)
          Sets a number of queries at once.
 MobyDataJob remove(Object fieldName)
          Removes the query with the given name, if present
 MobyDataObjectSet retrieveObjects()
          This is a convenience method that allows the user extract all Objects from all content job subgroups (simples and collections) into a single Collection, removing duplicates.
static void setDebugMode(boolean mode)
           
static void setDebugPrintStream(PrintStream ps)
          Standard error is used unless this method is called.
 void setExceptions(ServiceException[] mes)
          Sets the exception list for the content en masse, replacing any current values
 void setServiceAuthorityURI(String uri)
           
 void setServiceNotes(String notes)
          Note this is only the human readable notes.
 void setXmlMode(int mode)
           
 int size()
          Reports the number of queries
 String toString()
           
 String toXML()
           
 Collection<MobyDataJob> values()
          Returns all of the queries
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MobyContentInstance

public MobyContentInstance()
Creates a blank MOBY envelope, to be filled in programatically with data instances. Useful if you are a client composing a query, or a server composing a response.


MobyContentInstance

public MobyContentInstance(MobyDataInstance mdi,
                           String paramName)
                    throws MobyException
A convenience constructor when you want to create an envelope with just one object in it. This object will be put into its own data group (mobyData tag), and automatically assigned a queryID. If paramName is null, the parameter is assigned an empty string for articleName. For now, single parameter requests can have empty articleNames in jMOBY. This may change in the future.

Throws:
MobyException - if the passed in object is not a MobyDataObject or a MobyDataObjectSet or null (an empty data group)

MobyContentInstance

public MobyContentInstance(Element objectTag)
                    throws MobyException
Builds a MobyContentInstance (i.e. one or more MOBY queries or responses) using a DOM-parsed XML MOBY envelope (i.e. the mobyContent tag). This is useful if you want to parse a response from a server, or if you are a server and you want to parse an incoming query. The resulting object can be modified using the standard Map interface methods, with queryID as key, and MobyDataInstance Vectors (mobyData) as values.

Throws:
MobyException

MobyContentInstance

public MobyContentInstance(Element objectTag,
                           Registry registry)
                    throws MobyException
Throws:
MobyException
Method Detail

setDebugMode

public static void setDebugMode(boolean mode)
Parameters:
mode - if true, debugging information is printed to the stream returned by getDebugOutputStream

setDebugPrintStream

public static void setDebugPrintStream(PrintStream ps)
                                throws IllegalArgumentException
Standard error is used unless this method is called.

Parameters:
ps - the OutputStream to which debugging information is sent.
Throws:
IllegalArgumentException - if the stream is null

parseDataGroup

public void parseDataGroup(Element dataGroupTag,
                           Registry registry)
                    throws MobyException
Throws:
MobyException

retrieveObjects

public MobyDataObjectSet retrieveObjects()
This is a convenience method that allows the user extract all Objects from all content job subgroups (simples and collections) into a single Collection, removing duplicates.


getServiceAuthorityURI

public String getServiceAuthorityURI()

setServiceAuthorityURI

public void setServiceAuthorityURI(String uri)

getServiceNotes

public String getServiceNotes()
Returns:
the human readable message (e.g. citation) to associate with these results

setServiceNotes

public void setServiceNotes(String notes)
Note this is only the human readable notes. Although exceptions are part of the notes element in the MOBY XML, they are logically separated in this object.

Parameters:
notes - the human readable message (e.g. citation) to associate with these results

setExceptions

public void setExceptions(ServiceException[] mes)
Sets the exception list for the content en masse, replacing any current values

Parameters:
mes - the exceptions to associate with the content, or null to remove any existing exceptions

addException

public void addException(ServiceException me)
Adds a new exception to the list of exceptions associated with the content


getExceptions

public ServiceException[] getExceptions()
Returns:
the list of exceptions associated with this content

hasExceptions

public boolean hasExceptions()
Indicates whether the moby content has any exception (according to the style of MOBY-S RFC 1863)

Returns:
true if there are exceptions (any severity) in the content

hasExceptions

public boolean hasExceptions(int severity)
Indicates whether the moby content has any exception of the given severity or worse (according to the style of MOBY-S RFC 1863).

Parameters:
severity - the minimum severity of exception (info < warning < error) to report
Returns:
true if there are exceptions (of the specified severity or greater) in the content

setXmlMode

public void setXmlMode(int mode)
                throws IllegalArgumentException
Throws:
IllegalArgumentException

getXmlMode

public int getXmlMode()
Report whether toXML will produce Central template or service call instance XML.

Returns:
one of CENTRAL_XML_MODE or SERVICE_XML_MODE

toString

public String toString()
Overrides:
toString in class Object

toXML

public String toXML()

clear

public void clear()
Effectively deletes the contents, leaving you with a data-less container. This does not clear the service notes and authority URI members.

Specified by:
clear in interface Map<String,MobyDataJob>

containsKey

public boolean containsKey(Object fieldName)
To check for the presence of a data group with a given name

Specified by:
containsKey in interface Map<String,MobyDataJob>

containsValue

public boolean containsValue(Object value)
To check for the presence of a data group as one of the members

Specified by:
containsValue in interface Map<String,MobyDataJob>

entrySet

public Set<Map.Entry<String,MobyDataJob>> entrySet()
Retrieves each name/data group pair for the members of content.

Specified by:
entrySet in interface Map<String,MobyDataJob>

equals

public boolean equals(Object o)
Returns true if and only if both query sets have the same queries with the same values

Specified by:
equals in interface Map<String,MobyDataJob>
Overrides:
equals in class Object

get

public MobyDataJob get(Object fieldName)
Retrieves a member (AbstractMap) of the composite with a given field name.

Specified by:
get in interface Map<String,MobyDataJob>

hashCode

public int hashCode()
Specified by:
hashCode in interface Map<String,MobyDataJob>
Overrides:
hashCode in class Object

isEmpty

public boolean isEmpty()
Is this a blank, uninstantiated object?

Specified by:
isEmpty in interface Map<String,MobyDataJob>

keySet

public Set<String> keySet()
Retrieves a list of the query names in this object. NOTE: IF YOU DELETE OBJECTS FROM THIS SET, THEY ARE REMOVED FROM THE MOBY PAYLOAD TOO!

Specified by:
keySet in interface Map<String,MobyDataJob>

put

public MobyDataJob put(String queryID,
                       MobyDataJob value)
Specified by:
put in interface Map<String,MobyDataJob>
Parameters:
queryID - a unique ID for the query. If null, or not a String, or blank it will be auto-generated
value - an AbstractMap of , where the string is the parameter name

put

public void put(MobyDataJob value)
same as put(String, MobyDataJob), but the queryID will be automatically generated for this value


putAll

public void putAll(Map<? extends String,? extends MobyDataJob> map)
Sets a number of queries at once.

Specified by:
putAll in interface Map<String,MobyDataJob>

remove

public MobyDataJob remove(Object fieldName)
Removes the query with the given name, if present

Specified by:
remove in interface Map<String,MobyDataJob>
Returns:
the query removed

size

public int size()
Reports the number of queries

Specified by:
size in interface Map<String,MobyDataJob>

values

public Collection<MobyDataJob> values()
Returns all of the queries

Specified by:
values in interface Map<String,MobyDataJob>

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010