Version: 1.1.1

org.biomoby.shared.data
Class MobyDataInt

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.MobyDataInt
All Implemented Interfaces:
Cloneable, Comparable, MobyDataInstance

public class MobyDataInt
extends MobyDataObject

A class representing a MOBY Integer primitive. Note that the Integer notion in MOBY does not define a specific bit precision. All values in this class are stored as Java BigInteger, which has no minmum or maximum value, to avoid loss of data integrity. Because getObject() will return an immutable BigInteger, basic arithmetic methods have been included to allow modification of the underlying value.


Field Summary
 
Fields inherited from interface org.biomoby.shared.data.MobyDataInstance
CENTRAL_XML_MODE, SERVICE_XML_MODE
 
Constructor Summary
MobyDataInt(Element element)
          Construct the object using a DOM fragment.
MobyDataInt(Element element, Registry registry)
           
MobyDataInt(int i)
           
MobyDataInt(Number n)
           
MobyDataInt(Number n, Registry r)
           
MobyDataInt(String articleName, int i)
          Constructor to use if the incoming value is a primitive.
MobyDataInt(String articleName, int i, Registry registry)
           
MobyDataInt(String articleName, Number n)
          Constructor to use if the incoming value is a number object such as Float, Double, Integer, BigInteger, BigDecimal, etc.
MobyDataInt(String articleName, Number n, Registry registry)
           
MobyDataInt(String articleName, String stringNumber)
          Constructor to use if the incoming value is a string representing an integer number.
MobyDataInt(String articleName, String stringNumber, Registry registry)
           
 
Method Summary
 void add(Number n)
          Perform the addition operand on the data value.
 MobyDataInt clone()
          Simply calls new constructor with object's existing data type, name and value.
 int compareTo(Object object)
          Override BigInteger.compareTo() because it only compares to other BigInteger.
 void divide(Number n)
          Perform the division operand on the data value.
 Object getObject()
          Gives access to the Java object instance underlying the MobyData instance.
 String getValue()
          A lexical (prefereably human readable) representation of the underlying object value (not including the namespace and ID).
 int intValue()
          A convenience method, which returns the underlying BigInteger's primitive int representation.
 long longValue()
          A convenience method, which returns the underlying BigInteger's primitive int representation.
 void mod(Number n)
          Perform the modulus operand on the data value.
 void multiply(Number n)
          Perform the multiplication operand on the data value.
 void pow(Number n)
          Raise the stored value to an exponent.
 void subtract(Number n)
          Perform the subtraction operand on the data value.
 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.
 
Methods inherited from class org.biomoby.shared.data.MobyDataObject
addCrossReference, addCrossReferences, addCrossReferences, addProvisionInfo, createInstanceFromDOM, createInstanceFromDOM, createInstanceFromString, createInstanceFromString, createInstanceFromXML, equals, getCrossReferences, getId, getName, getPrimaryNamespace, getProvisionInfo, getTextContents, 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, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.biomoby.shared.data.MobyDataInstance
getName, getUserData, setUserData
 

Constructor Detail

MobyDataInt

public MobyDataInt(Element element)
            throws IllegalArgumentException
Construct the object using a DOM fragment.

Throws:
IllegalArgumentException - if the element is not a Integer tag

MobyDataInt

public MobyDataInt(Element element,
                   Registry registry)
            throws IllegalArgumentException
Throws:
IllegalArgumentException

MobyDataInt

public MobyDataInt(String articleName,
                   Number n)
Constructor to use if the incoming value is a number object such as Float, Double, Integer, BigInteger, BigDecimal, etc. Real numbers will be converted to their integer equivalents.


MobyDataInt

public MobyDataInt(String articleName,
                   Number n,
                   Registry registry)

MobyDataInt

public MobyDataInt(Number n)

MobyDataInt

public MobyDataInt(Number n,
                   Registry r)

MobyDataInt

public MobyDataInt(String articleName,
                   int i)
Constructor to use if the incoming value is a primitive. If you want to pass in a float or double, cast it to an int.


MobyDataInt

public MobyDataInt(String articleName,
                   int i,
                   Registry registry)

MobyDataInt

public MobyDataInt(int i)

MobyDataInt

public MobyDataInt(String articleName,
                   String stringNumber)
            throws NumberFormatException
Constructor to use if the incoming value is a string representing an integer number.

Throws:
NumberFormatException - if the string does not represent an integer number

MobyDataInt

public MobyDataInt(String articleName,
                   String stringNumber,
                   Registry registry)
            throws NumberFormatException
Throws:
NumberFormatException
Method Detail

add

public void add(Number n)
Perform the addition operand on the data value. Non-integer arguments will be rounded to their BigInteger equivalents.


subtract

public void subtract(Number n)
Perform the subtraction operand on the data value. Non-integer arguments will be rounded to their BigInteger equivalents.


multiply

public void multiply(Number n)
Perform the multiplication operand on the data value. Non-integer arguments will be rounded to their BigInteger equivalents.


divide

public void divide(Number n)
Perform the division operand on the data value. Non-integer arguments will be rounded to their BigInteger equivalents.


mod

public void mod(Number n)
Perform the modulus operand on the data value. Non-integer arguments will be rounded to their BigInteger equivalents.


pow

public void pow(Number n)
Raise the stored value to an exponent. Non-integer arguments will be rounded to their long equivalents. If your exponent is greater than Long.MAX_VALUE, you are crazy (as computing this would require the energy to boil earth's oceans), and out of luck.


clone

public MobyDataInt 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

compareTo

public int compareTo(Object object)
Override BigInteger.compareTo() because it only compares to other BigInteger. This method will compare to any java.lang.Number

Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class MobyDataObject

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:
a BigInteger, the full precision value of the data

intValue

public int intValue()
A convenience method, which returns the underlying BigInteger's primitive int representation. Caution: if the number is too big to fit, you're only getting the lower 32 bits! Use the BigInteger returned by getObject if you aren't sure of the range of your input.


longValue

public long longValue()
A convenience method, which returns the underlying BigInteger's primitive int representation. Caution: if the number is too big to fit, you're only getting the lower 64 bits! Use the BigInteger returned by getObject if you aren't sure of the range of your input.


getValue

public String getValue()
Description copied from class: MobyDataObject
A lexical (prefereably human readable) representation of the underlying object value (not including the namespace and ID). This value is used in sorting, and potentially for user interface elements such as tool tips and comment fields. For base objects, there is no underlying value (just a namespace and id), so the result is always a constant string "[Object]".

Overrides:
getValue in class MobyDataObject

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

Version: 1.1.1

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