Version: 1.1.1

org.biomoby.shared.data
Class MobyDataFloat

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

public class MobyDataFloat
extends MobyDataObject

A class representing a MOBY Float primitive. Note that the Float notion in MOBY does not define a specific bit precision. All values in this class are stored as Java BigDecimal, which is arbitary precision to avoid loss of data integrity. Because getObject() will return an immutable BigDecimal, 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
MobyDataFloat(double d)
           
MobyDataFloat(double d, Registry r)
           
MobyDataFloat(Element element)
          Construct the object using a DOM fragment.
MobyDataFloat(Element element, Registry registry)
           
MobyDataFloat(Number n)
           
MobyDataFloat(Number n, Registry r)
           
MobyDataFloat(String stringNumber)
           
MobyDataFloat(String articleName, double d)
          Constructor to use if the incoming value is a primitive.
MobyDataFloat(String articleName, double d, Registry registry)
           
MobyDataFloat(String articleName, Number n)
          Constructor to use if the incoming value is a number object such as Float, Double, Integer, BigDecimal, etc.
MobyDataFloat(String articleName, Number n, Registry r)
           
MobyDataFloat(String stringNumber, Registry registry)
           
MobyDataFloat(String articleName, String stringNumber)
          Constructor to use if the incoming value is a string representing a number (including mantissa/exponent format).
MobyDataFloat(String articleName, String stringNumber, Registry registry)
           
 
Method Summary
 void add(Number n)
          Add a specified number to the data value.
 MobyDataFloat clone()
          Simply calls new constructor with object's existing data type, name and value.
 int compareTo(Object object)
          Override BigDecimal.compareTo() because it only compares to other BigInteger.
 void divide(Number n)
          Divide the data value by a number n, using the rounding off mode BigDecimal.ROUND_HALF_EVEN.
 void divide(Number n, int mode)
          Divide the data value by a number n, using the rounding off mode of your choice from BigDecimal.
 double doubleValue()
          A convenience method, which returns the underlying BigInteger's primitive int representation.
 boolean equals(Object object)
          Override BigDecimal.equals() because it only compares to other BigInteger.
 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).
 void multiply(Number n)
          Multiply the data value by a specified number.
 void pow(Number n)
          Raise the stored value to an exponent.
 void subtract(Number n)
          Subtract a specified number from 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, 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

MobyDataFloat

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

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

MobyDataFloat

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

MobyDataFloat

public MobyDataFloat(String articleName,
                     Number n)
Constructor to use if the incoming value is a number object such as Float, Double, Integer, BigDecimal, etc.


MobyDataFloat

public MobyDataFloat(String articleName,
                     Number n,
                     Registry r)

MobyDataFloat

public MobyDataFloat(Number n,
                     Registry r)

MobyDataFloat

public MobyDataFloat(Number n)

MobyDataFloat

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


MobyDataFloat

public MobyDataFloat(String articleName,
                     double d,
                     Registry registry)

MobyDataFloat

public MobyDataFloat(double d,
                     Registry r)

MobyDataFloat

public MobyDataFloat(double d)

MobyDataFloat

public MobyDataFloat(String articleName,
                     String stringNumber)
              throws NumberFormatException
Constructor to use if the incoming value is a string representing a number (including mantissa/exponent format).

Throws:
NumberFormatException - if the string does not represent a number

MobyDataFloat

public MobyDataFloat(String articleName,
                     String stringNumber,
                     Registry registry)
              throws NumberFormatException
Throws:
NumberFormatException

MobyDataFloat

public MobyDataFloat(String stringNumber)

MobyDataFloat

public MobyDataFloat(String stringNumber,
                     Registry registry)
Method Detail

clone

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

add

public void add(Number n)
Add a specified number to the data value.


subtract

public void subtract(Number n)
Subtract a specified number from the data value.


multiply

public void multiply(Number n)
Multiply the data value by a specified number.


divide

public void divide(Number n)
Divide the data value by a number n, using the rounding off mode BigDecimal.ROUND_HALF_EVEN.


divide

public void divide(Number n,
                   int mode)
Divide the data value by a number n, using the rounding off mode of your choice from BigDecimal.


pow

public void pow(Number n)
Raise the stored value to an exponent. Warning, this method fails to produce a valid answer under four conditions, because I haven't had time to implement them properly. If the exponent is non-integer and: 1) The base is larger than Double.MAX_VALUE (or smaller Double.MIN_VALUE) 2) The base is smaller then Double.MAX_VALUE (or smaller Double.MIN_VALUE) and the result of the operation is larger then (Double.MAX_VALUE or smaller Double.MIN_VALUE) 3) Underflows are silently ignored. 4) The exponent is greater than Long.MAX_VALUE (are you crazy???)


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 BigDecimal

doubleValue

public double doubleValue()
A convenience method, which returns the underlying BigInteger's primitive int representation. Caution: if the number is too big to fit, you'll end up with Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY Caution, you may lose precision on the data, even if it is within the range, especially for large e-value from BLAST, etc. Use the BigDecimal 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

compareTo

public int compareTo(Object object)
Override BigDecimal.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

equals

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

Overrides:
equals in class MobyDataObject
Returns:
true if the values are equals according to the underlying Java object's equals() method

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