edu.neu.ccs
Class XDouble

java.lang.Object
  |
  +--edu.neu.ccs.XObject
        |
        +--edu.neu.ccs.XNumber
              |
              +--edu.neu.ccs.XDouble
All Implemented Interfaces:
Cloneable, Serializable, Stringable
Direct Known Subclasses:
HexXDouble

public class XDouble
extends XNumber

Object wrapper for the primitive double type that also provides Stringable capabilities. The default value for this class is the double representation of zero.

Since:
1.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.neu.ccs.XObject
changeAdapter, VALUE
 
Constructor Summary
XDouble()
          Constructs a wrapper for the default double value.
XDouble(double d)
          Constructs a wrapper for the given double value.
XDouble(String s)
          Constructs a wrapper for the double value whose state information is encapsulated in the given String data.
 
Method Summary
 byte byteValue()
          Returns the value of this number as a byte value.
 double doubleValue()
          Returns the value of this number as a double value.
 boolean equals(Object other)
          Returns true if the wrapped object is equal to the given object, and false if it is not.
 float floatValue()
          Returns the value of this number as a float value.
 void fromStringData(String data)
          Sets the state of this object using information contained in the given String.
 double getValue()
          Returns the value wrapped by this object.
 int hashCode()
          Returns an int hash code appropriate for the wrapped object.
 int intValue()
          Returns the value of this number as a int value.
 long longValue()
          Returns the value of this number as a long value.
static double parseDouble(String s)
          Parses a double value from a String using the current shared parser.
 void setValue(double d)
          Sets the value wrapped by this object to the given value.
 short shortValue()
          Returns the value of this number as a short value.
static double[] toPrimitiveArray(XDouble[] x)
          Returns an array of primitive double values copied from the given array of XDouble objects.
 String toString()
          Returns a String representation of the wrapped value.
 String toStringData()
          Returns a String encapsulation of this object that contains information needed to set the state of this object at a later time.
static XDouble[] toXArray(double[] a)
          Returns an array of XDouble objects initialized from the given array of double values.
 
Methods inherited from class edu.neu.ccs.XObject
addPropertyChangeListener, addPropertyChangeListener, formatErrorMessage, removePropertyChangeListener, removePropertyChangeListener, toStringArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XDouble

public XDouble()
Constructs a wrapper for the default double value.

See Also:
XDouble(double), XDouble(String)

XDouble

public XDouble(double d)
Constructs a wrapper for the given double value.

Parameters:
d - the value to be wrapped
See Also:
XDouble(), XDouble(String)

XDouble

public XDouble(String s)
        throws ParseException
Constructs a wrapper for the double value whose state information is encapsulated in the given String data.

Parameters:
s - a String representation of the desired value
Throws:
ParseException - if the data is malformed
See Also:
XDouble(), XDouble(double)
Method Detail

fromStringData

public void fromStringData(String data)
                    throws ParseException
Description copied from interface: Stringable
Sets the state of this object using information contained in the given String.

Specified by:
fromStringData in interface Stringable
Specified by:
fromStringData in class XObject
Parameters:
data - the String containing state information
Throws:
ParseException - if the data is malformed
See Also:
Stringable.toStringData()

toStringData

public String toStringData()
Description copied from interface: Stringable
Returns a String encapsulation of this object that contains information needed to set the state of this object at a later time.

Specified by:
toStringData in interface Stringable
Specified by:
toStringData in class XObject
See Also:
Stringable.fromStringData(String)

byteValue

public byte byteValue()
Description copied from class: XNumber
Returns the value of this number as a byte value.

Specified by:
byteValue in class XNumber

shortValue

public short shortValue()
Description copied from class: XNumber
Returns the value of this number as a short value.

Specified by:
shortValue in class XNumber

intValue

public int intValue()
Description copied from class: XNumber
Returns the value of this number as a int value.

Specified by:
intValue in class XNumber

longValue

public long longValue()
Description copied from class: XNumber
Returns the value of this number as a long value.

Specified by:
longValue in class XNumber

floatValue

public float floatValue()
Description copied from class: XNumber
Returns the value of this number as a float value.

Specified by:
floatValue in class XNumber

doubleValue

public double doubleValue()
Description copied from class: XNumber
Returns the value of this number as a double value.

Specified by:
doubleValue in class XNumber

equals

public boolean equals(Object other)
Returns true if the wrapped object is equal to the given object, and false if it is not.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns an int hash code appropriate for the wrapped object.

Overrides:
hashCode in class Object

toString

public String toString()
Returns a String representation of the wrapped value.

Overrides:
toString in class Object

setValue

public void setValue(double d)
Sets the value wrapped by this object to the given value.

Parameters:
d - the value to be wrapped
See Also:
getValue()

getValue

public double getValue()
Returns the value wrapped by this object.

See Also:
setValue(double)

parseDouble

public static double parseDouble(String s)
                          throws NumberFormatException
Parses a double value from a String using the current shared parser.

Returns:
the extracted double value
Throws:
NumberFormatException - if the data is malformed

toPrimitiveArray

public static double[] toPrimitiveArray(XDouble[] x)
Returns an array of primitive double values copied from the given array of XDouble objects.

Parameters:
x - an array of XDoubles
Returns:
the resulting array of double values
See Also:
toXArray(double[])

toXArray

public static XDouble[] toXArray(double[] a)
Returns an array of XDouble objects initialized from the given array of double values.

Parameters:
a - an array of doubles
Returns:
the resulting array of XDouble objects
See Also:
toPrimitiveArray(XDouble[])