Version: 1.1.1

org.biomoby.shared.datatypes
Class MobyObject

java.lang.Object
  extended by org.biomoby.shared.datatypes.MobyObject
Direct Known Subclasses:
MobyBoolean, MobyDateTime, MobyFloat, MobyInteger, MobyString, MobyXref

public class MobyObject
extends Object

An object representing a Biomoby Object, the main Biomoby data type, where all other data types are inherited from.

Every Biomoby object consists of three components:

For example, a namespace might be a GenBank (NCBI) "gi", and an identifier in that namespace might be "163483", meaning that such instance refers to the resource defined as a GenBank record with the gi=163483.

The Biomoby objects can also appear as members (attributes) of other Biomoby objects. In such case, they should be recognized by their name (also called an article name).

When a Biomoby service is invoked it may get more Biomoby objects. In such case, they can be also identified by their name (also called an article name).

Version:
$Id: MobyObject.java,v 1.8 2008/03/02 18:47:35 senger Exp $
Author:
Martin Senger

Constructor Summary
MobyObject()
          Default constructor.
MobyObject(String namespace, String id)
          Another constructor.
 
Method Summary
 void addXref(MobyXref xref)
          Add a cross reference to those already attached.
 String format(int indent)
          Return the same contents as toString() method but indented by level expressed in the parameter 'indent'.
 String getId()
          Get an identifier of this object.
 String getMobyTypeName()
          Return a Biomoby data type name represented by this object.
 String getName()
          Get a name of this object.
 String getNamespace()
          Get a namespace of the resource being represented by this object.
 MobyProvisionInfo getProvision()
          Get provision data attached to this object.
 String getValue()
          Get the value of this object.
 MobyXref[] getXrefs()
          Get cross references attached to this object.
 boolean isPrimitiveType()
          Return true if this object represents a Biomoby primitive type.
 void setId(String id)
          Set an identifier (within the namespace) that specifies the precise resource represented by the object.
 void setName(String name)
          Set a name (called also an article name) that identifies this objects within other Biomoby objects.
 void setNamespace(String namespace)
          Set a namespace of the resource being represented by this object.
 void setProvision(MobyProvisionInfo provision)
          Attach a service provision information to this object.
 void setValue(String value)
          Set a value of this object.
 void setValueXML(String value)
          Set a value of this object.
 void setXrefs(MobyXref[] xrefs)
          Attach cross references to this object.
 String toString()
          Format all non-empty public members in a human-readable way.
 org.jdom.Element toXML()
          Create an XML element representing this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MobyObject

public MobyObject()
Default constructor.


MobyObject

public MobyObject(String namespace,
                  String id)
Another constructor.

Parameters:
namespace - of the resource being represented by this object
id - within the 'namespace' that specifies the * precise resource represented by the object
Method Detail

getMobyTypeName

public String getMobyTypeName()
Return a Biomoby data type name represented by this object.


toString

public String toString()
Format all non-empty public members in a human-readable way.

Overrides:
toString in class Object
Returns:
a formatted string
See Also:
for making the returned string better indented

format

public String format(int indent)
Return the same contents as toString() method but indented by level expressed in the parameter 'indent'. It is useful when a hierarchy of objects call toString methods on their children. For example, assuming that a MobyObject has a list of cross references (represented by a Vector xrefs, the method toString of such MobyObject can include code like this:
  StringBuffer buf = new StringBuffer();
  for (Enumeration en = xrefs.elements(); en.hasMoreElements(); )
    buf.append (((MobyXref)en.nextElement()).format (1));

Parameters:
indent - means a level of wanted indentation: number 1 means three spaces, number two six spaces, etc.
Returns:
a formatted, and indented, string

toXML

public org.jdom.Element toXML()
Create an XML element representing this object.

Returns:
a jDom element that can be easily incorporated into a bigger XML document

isPrimitiveType

public boolean isPrimitiveType()
Return true if this object represents a Biomoby primitive type.


setNamespace

public void setNamespace(String namespace)
Set a namespace of the resource being represented by this object.


getNamespace

public String getNamespace()
Get a namespace of the resource being represented by this object.


setId

public void setId(String id)
Set an identifier (within the namespace) that specifies the precise resource represented by the object.


getId

public String getId()
Get an identifier of this object.


setName

public void setName(String name)
Set a name (called also an article name) that identifies this objects within other Biomoby objects.


getName

public String getName()
Get a name of this object.


setValue

public void setValue(String value)
              throws MobyException
Set a value of this object. A value can be set only for Biomoby objects that represent primitive types (such as MobyString or MobyInteger. The value is internaly always kept as a string - but subclasses can overwrite this method to add checking for the correct format of this value.

Parameters:
value - to be stored; a null value is changed to an empty value ("")
Throws:
MobyException - if the 'value' does not have a correct format (used by subclasses)
See Also:
how to set value as CDATA

setValueXML

public void setValueXML(String value)
                 throws MobyException
Set a value of this object. This is identical to setValue(java.lang.String) except the set value will appear in the resulting XML surronded by the CDATA notation.

Parameters:
value - to be stored; a null value is changed to an empty value ("")
Throws:
MobyException - if the 'value' does not have a correct format (used by subclasses)
See Also:
how to set value normally

getValue

public String getValue()
Get the value of this object.


setProvision

public void setProvision(MobyProvisionInfo provision)
Attach a service provision information to this object.


getProvision

public MobyProvisionInfo getProvision()
Get provision data attached to this object.


setXrefs

public void setXrefs(MobyXref[] xrefs)
Attach cross references to this object.

Parameters:
xrefs - is a list of cross references

addXref

public void addXref(MobyXref xref)
Add a cross reference to those already attached.

Parameters:
xref - is a cross reference to be added
See Also:
setXrefs(org.biomoby.shared.datatypes.MobyXref[])

getXrefs

public MobyXref[] getXrefs()
Get cross references attached to this object.


Version: 1.1.1

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