Version: 1.1.1

org.biomoby.shared.data
Class MobyDataComposite

java.lang.Object
  extended by org.biomoby.shared.MobyData
      extended by org.biomoby.shared.MobyPrimaryData
          extended by org.biomoby.shared.MobyPrimaryDataSimple
              extended by org.biomoby.shared.data.MobyDataObject
                  extended by org.biomoby.shared.data.MobyDataComposite
All Implemented Interfaces:
Cloneable, Comparable, ConcurrentMap<String,MobyDataObject>, Map<String,MobyDataObject>, MobyDataInstance
Direct Known Subclasses:
MobyDataBytes, MobyDataObjectDeferred

public class MobyDataComposite
extends MobyDataObject
implements ConcurrentMap<String,MobyDataObject>

This is the class that represents any non-primitive object instance (i.e. anything except object, boolean, integer, float, date-time, or string) from the MOBY data type ontology. The members of the composite object are stored in a Java Map, and can be either primitives, or other composites. This class implements the ConcurrentMap interface to allow for the easy editing of a composite object's members at runtime.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from interface org.biomoby.shared.data.MobyDataInstance
CENTRAL_XML_MODE, SERVICE_XML_MODE
 
Constructor Summary
MobyDataComposite(Element element)
          Construct the object using a DOM fragment.
MobyDataComposite(Element element, Registry registry)
           
MobyDataComposite(MobyDataType type)
           
MobyDataComposite(MobyDataType type, MobyNamespace namespace, String id, Object... memberStrings)
          Instantiates a composite with a variable number of members using Java 1.5's varargs.
MobyDataComposite(MobyDataType type, String name)
           
MobyDataComposite(MobyDataType type, String name, MobyNamespace namespace, String id)
           
MobyDataComposite(MobyDataType type, String name, String namespace, String id)
           
MobyDataComposite(String typeName)
           
MobyDataComposite(String typeName, Registry r)
           
MobyDataComposite(String typeName, String name)
           
MobyDataComposite(String typeName, String name, Registry r)
           
MobyDataComposite(String typeName, String name, String namespace, String id)
          Only call this constructor if you are sure that the data type name is in the ontology, otherwise the datatype will be null.
MobyDataComposite(String typeName, String name, String namespace, String id, Registry registry)
           
 
Method Summary
 void clear()
          Effectively deletes the composite, leaving you with a blank base object
 MobyDataComposite clone()
          Simply calls new constructor with object's existing data type, name and value.
 boolean containsKey(Object fieldName)
          To check for the presence of a field with a given name
 boolean containsValue(Object value)
          To check for the presence of a value in one of the members (e.g Integer, Float, String, Calendar)
 Set<Map.Entry<String,MobyDataObject>> entrySet()
          Retrieves each field name/MobyDataObject pair for the members of the composite object
 boolean equals(Object o)
          Returns true if and only if both objects have the same fields with the same values, and the same object ID
 MobyDataObject get(Object fieldName)
          Retrieves a member of the composite with a given field name.
 Object getObject()
          Gives access to the Java object instance underlying the MobyData instance.
 int hashCode()
           
 boolean isEmpty()
          Is this a blank, uninstantiated object?
 boolean isObjectValid()
          Report whether all required fields for the object's datatype have been instantiated (i.e. the object is ready to use as input to a service).
 Set<String> keySet()
          Retrieves a list of the field names in this object
 MobyDataObject put(String fieldName, MobyDataObject value)
          Add a field to the composite.
 void putAll(Map<? extends String,? extends MobyDataObject> map)
          Sets a number of object fields at once.
 MobyDataObject putIfAbsent(String key, MobyDataObject value)
           
 MobyDataObject remove(Object fieldName)
          Removes the field with the given name, if present
 boolean remove(Object key, Object value)
           
 MobyDataObject replace(String fieldName, MobyDataObject value)
           
 boolean replace(String fieldName, MobyDataObject oldValue, MobyDataObject newValue)
           
 int size()
          Reports the number of data members in the composite object
 String toXML()
          Produces a full-blown XML fragment that depending on the value of getXmlMode() is either a template for use in MOBY Central services, or a Simple element for use in calling a service instance.
 Collection<MobyDataObject> values()
          For the user's convenience, the returned Collection is a MobyDataSetInstance, allowing for MOBY-savvy equivalency testing with another Collection of data instances.
 
Methods inherited from class org.biomoby.shared.data.MobyDataObject
addCrossReference, addCrossReferences, addCrossReferences, addProvisionInfo, compareTo, createInstanceFromDOM, createInstanceFromDOM, createInstanceFromString, createInstanceFromString, createInstanceFromXML, getCrossReferences, getId, getName, getPrimaryNamespace, getProvisionInfo, getTextContents, getValue, getXmlMode, hasCrossReferences, setId, setName, setPrimaryNamespace, setProvisionInfo, setXmlMode, toString
 
Methods inherited from class org.biomoby.shared.MobyPrimaryDataSimple
addNamespace, format, getDataType, getNamespaces, removeNamespace, removeNamespace, setDataType, setNamespaces
 
Methods inherited from class org.biomoby.shared.MobyPrimaryData
isPrimary
 
Methods inherited from class org.biomoby.shared.MobyData
getId, getName, getUserData, setUserData
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.biomoby.shared.data.MobyDataInstance
getName, getUserData, setUserData
 

Constructor Detail

MobyDataComposite

public MobyDataComposite(Element element)
                  throws MobyException
Construct the object using a DOM fragment.

Throws:
MobyException - if the element is not a MobyObject tag

MobyDataComposite

public MobyDataComposite(Element element,
                         Registry registry)
                  throws MobyException
Throws:
MobyException

MobyDataComposite

public MobyDataComposite(MobyDataType type,
                         String name,
                         MobyNamespace namespace,
                         String id)

MobyDataComposite

public MobyDataComposite(MobyDataType type,
                         String name,
                         String namespace,
                         String id)

MobyDataComposite

public MobyDataComposite(String typeName,
                         String name,
                         String namespace,
                         String id)
Only call this constructor if you are sure that the data type name is in the ontology, otherwise the datatype will be null.


MobyDataComposite

public MobyDataComposite(String typeName,
                         String name,
                         String namespace,
                         String id,
                         Registry registry)

MobyDataComposite

public MobyDataComposite(MobyDataType type,
                         MobyNamespace namespace,
                         String id,
                         Object... memberStrings)
                  throws IllegalArgumentException,
                         MobyException
Instantiates a composite with a variable number of members using Java 1.5's varargs.

Parameters:
memberStrings - an even number of strings, representing name, object, name, object, ...
Throws:
IllegalArgumentException - if an odd number of memberStrings is provided
MobyException - if one of the values provided cannot be cast into the required type according to the DataType definition for the composite, or if a required member is missing.

MobyDataComposite

public MobyDataComposite(MobyDataType type,
                         String name)

MobyDataComposite

public MobyDataComposite(String typeName,
                         String name)

MobyDataComposite

public MobyDataComposite(String typeName,
                         String name,
                         Registry r)

MobyDataComposite

public MobyDataComposite(MobyDataType type)

MobyDataComposite

public MobyDataComposite(String typeName)

MobyDataComposite

public MobyDataComposite(String typeName,
                         Registry r)
Method Detail

clone

public MobyDataComposite clone()
Description copied from class: MobyDataObject
Simply calls new constructor with object's existing data type, name and value. Subclasses should override this method if more datafields need to be copied for an accurate clone of the Moby Data Instance (i.e. anything but a base object). The subclasses should ensure that they also return a MobyDataObject.

Overrides:
clone in class MobyDataObject
Returns:
an object of class MobyDataObject

isObjectValid

public boolean isObjectValid()
Report whether all required fields for the object's datatype have been instantiated (i.e. the object is ready to use as input to a service). NOT YET IMPLEMENTED


toXML

public String toXML()
Description copied from class: MobyDataObject
Produces a full-blown XML fragment that depending on the value of getXmlMode() is either a template for use in MOBY Central services, or a Simple element for use in calling a service instance.

Specified by:
toXML in interface MobyDataInstance
Overrides:
toXML in class MobyDataObject
Returns:
the MOBY XML representation of the data instance

getObject

public Object getObject()
Description copied from class: MobyDataObject
Gives access to the Java object instance underlying the MobyData instance. For example, to change a MOBY String object, call ((StringBuffer) (data.getObject()).append("extra text to add to the end") In the case of a base Moby Object, there really is no underlying Java equivalent to return, so a java.lang.Object is returned for completeness's sake. possibly useful for notification events and pointer equivalency testing in derived classes such as MobyDataServiceAssocInstance?

Specified by:
getObject in interface MobyDataInstance
Overrides:
getObject in class MobyDataObject
Returns:
HashMap of member names to MobyDataObjects

clear

public void clear()
Effectively deletes the composite, leaving you with a blank base object

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

containsKey

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

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

containsValue

public boolean containsValue(Object value)
To check for the presence of a value in one of the members (e.g Integer, Float, String, Calendar)

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

entrySet

public Set<Map.Entry<String,MobyDataObject>> entrySet()
Retrieves each field name/MobyDataObject pair for the members of the composite object

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

equals

public boolean equals(Object o)
Returns true if and only if both objects have the same fields with the same values, and the same object ID

Specified by:
equals in interface Map<String,MobyDataObject>
Overrides:
equals in class MobyDataObject
Returns:
true if the values are equals according to the underlying Java object's equals() method

get

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

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

hashCode

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

isEmpty

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

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

keySet

public Set<String> keySet()
Retrieves a list of the field names in this object

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

put

public MobyDataObject put(String fieldName,
                          MobyDataObject value)
Add a field to the composite. This is the most common operation. e.g. creating a GenericSequence involves putting a 'length' member (MobyDataInt), then putting a 'sequence' member (MobyDataString). This method will throw an IllegalArgumentException if the value does not inherit from the type defined by Moby Central NOTE: if the field already exists and is defined with the HAS relationship in the DataType ontology, the previous value is NOT overwritten, rather the MobyDataObject is switched into a MobyDataObjectVector. Replace mode will be used unless the data type and relationship are properly defined.

Specified by:
put in interface Map<String,MobyDataObject>

putAll

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

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

remove

public MobyDataObject remove(Object fieldName)
Removes the field with the given name, if present

Specified by:
remove in interface Map<String,MobyDataObject>
Returns:
the data field removed

size

public int size()
Reports the number of data members in the composite object

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

values

public Collection<MobyDataObject> values()
For the user's convenience, the returned Collection is a MobyDataSetInstance, allowing for MOBY-savvy equivalency testing with another Collection of data instances.

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

putIfAbsent

public MobyDataObject putIfAbsent(String key,
                                  MobyDataObject value)
Specified by:
putIfAbsent in interface ConcurrentMap<String,MobyDataObject>

remove

public boolean remove(Object key,
                      Object value)
Specified by:
remove in interface ConcurrentMap<String,MobyDataObject>

replace

public MobyDataObject replace(String fieldName,
                              MobyDataObject value)
Specified by:
replace in interface ConcurrentMap<String,MobyDataObject>

replace

public boolean replace(String fieldName,
                       MobyDataObject oldValue,
                       MobyDataObject newValue)
Specified by:
replace in interface ConcurrentMap<String,MobyDataObject>

Version: 1.1.1

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