com.davisor.data
Class DoubleData

java.lang.Object
  extended byjava.lang.Number
      extended bycom.davisor.data.SimpleNumberValue
          extended bycom.davisor.data.DoubleData
All Implemented Interfaces:
java.lang.Comparable, Data, DataValue, com.davisor.core.Dupable, NumberValue, java.io.Serializable, SerializableData

public class DoubleData
extends SimpleNumberValue
implements com.davisor.core.Dupable

DoubleData represents double valued number data. The data value inside may also be null. This indicates that the number value of this object is undetermined.

Since:
JDK1.1
See Also:
DoubleType, Serialized Form

Field Summary
 
Fields inherited from class com.davisor.data.SimpleNumberValue
M_type, M_value
 
Constructor Summary
DoubleData()
          Creates a new double number data object with the default double type and value (0.0)
DoubleData(double value)
          Create a new double number data object with the default type and given value.
DoubleData(DoubleData data)
          Shallow copy constructor.
DoubleData(DoubleData data, boolean deep)
          Deep or shallow copy constructor.
DoubleData(java.lang.Number value)
          Creates a new double number data object with the default type and given value.
DoubleData(NumberType type)
          Constructs a double data object with the given type and default value (0.0).
DoubleData(NumberType type, double value)
          Create a new double number data object with the given type and value.
DoubleData(NumberType type, java.lang.Number value)
          Constructs a double data object with the given type and value.
DoubleData(NumberType type, java.lang.String stringValue, java.text.ParsePosition status)
          Creates a double data value from a string value.
 
Method Summary
 DataValue abs()
          Returns absolute data value of current value.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 java.lang.String getFormat()
          Gets the type specification optimal for this particular value.
 DataValue negate()
          Returns the negation of current value.
 void setValue(double value)
          Sets data double value.
 void setValue(long value)
          Sets data long value.
 void setValue(java.lang.Number value)
          Sets data Number value.
 void setValue(java.lang.String stringValue, java.text.ParsePosition status)
          Sets data value from a string value.
 void toStatement(java.sql.PreparedStatement statement, int parameter)
          Convert data to a prepared statement input parameter.
 
Methods inherited from class com.davisor.data.SimpleNumberValue
add, byteValue, ceil, compareTo, deinterpolate, div, doubleValue, equals, floatValue, floor, getFormat, getType, hashCode, interpolate, intValue, isNull, longValue, max, min, mul, numberValue, setValue, setValue, setValue, setValue, shortValue, sub, toString, toXML, unit
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoubleData

public DoubleData()
Creates a new double number data object with the default double type and value (0.0)

See Also:
DoubleData(NumberType,double)

DoubleData

public DoubleData(DoubleData data)
Shallow copy constructor.

Parameters:
data - source data (may be null)
See Also:
SimpleNumberValue.SimpleNumberValue(SimpleNumberValue,boolean)

DoubleData

public DoubleData(DoubleData data,
                  boolean deep)
Deep or shallow copy constructor. If it is shallow, then the new object shares an underlying type with the original object. If it is deep, then the type is dupped.

Parameters:
data - source data (may be null)
deep - determines if the copying is deep or shallow
See Also:
SimpleNumberValue.SimpleNumberValue(SimpleNumberValue,boolean)

DoubleData

public DoubleData(java.lang.Number value)
Creates a new double number data object with the default type and given value.

Parameters:
value - data value (may be null)
See Also:
SimpleNumberValue.SimpleNumberValue(NumberType,Number)

DoubleData

public DoubleData(double value)
Create a new double number data object with the default type and given value.

Parameters:
value - data value
See Also:
DoubleData(NumberType,double)

DoubleData

public DoubleData(NumberType type)
Constructs a double data object with the given type and default value (0.0).

Parameters:
type - the type of data (may be null)
See Also:
DoubleData(NumberType,double)

DoubleData

public DoubleData(NumberType type,
                  java.lang.Number value)
Constructs a double data object with the given type and value.

Parameters:
type - the type of data (may be null)
value - data value (may be null)
See Also:
SimpleNumberValue.SimpleNumberValue(NumberType,Number)

DoubleData

public DoubleData(NumberType type,
                  double value)
Create a new double number data object with the given type and value.

Parameters:
type - the type of data (may be null)
value - data value
See Also:
SimpleNumberValue.SimpleNumberValue(NumberType,Number)

DoubleData

public DoubleData(NumberType type,
                  java.lang.String stringValue,
                  java.text.ParsePosition status)
           throws InvalidDataException
Creates a double data value from a string value.

Parameters:
type - the type of data (may be null)
stringValue - string value to be parsed (may be null)
status - parse status (may be null)
Throws:
InvalidDataException - if string value could not be parser
See Also:
setValue(String,ParsePosition)
Method Detail

abs

public DataValue abs()
              throws InvalidDataException
Returns absolute data value of current value.

Absolute values must satisfy a requirement that when added to any other value, the result must be greater than or equal to the original value.

Specified by:
abs in interface DataValue
Specified by:
abs in class SimpleNumberValue
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if absolute value can not be computed

getFormat

public java.lang.String getFormat()
Gets the type specification optimal for this particular value. The specification returned may differ from the current type specification. If so, setting current type specification equal with the value returned by this method will ensure optimal value formatting and parsing for values of the same magnitude as this value.

The double data optimal specification string describes a format that has a minimum number of decimals, but at least one.

Specified by:
getFormat in interface DataValue
Overrides:
getFormat in class SimpleNumberValue
See Also:
Data.getType(), FormatType.getFormat(), FormatType.setFormat(java.util.Locale, java.lang.String)

negate

public DataValue negate()
                 throws InvalidDataException
Returns the negation of current value.

Specified by:
negate in interface DataValue
Specified by:
negate in class SimpleNumberValue
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if absolute value can not be computed

setValue

public void setValue(java.lang.String stringValue,
                     java.text.ParsePosition status)
              throws InvalidDataException
Sets data value from a string value.

Specified by:
setValue in interface DataValue
Parameters:
stringValue - string value to be parsed (may be null)
status - parse status (may be null)
Throws:
InvalidDataException - if string value could not be parser
See Also:
NumberType.doubleValue(String,ParsePosition)

toStatement

public void toStatement(java.sql.PreparedStatement statement,
                        int parameter)
                 throws java.sql.SQLException
Convert data to a prepared statement input parameter.

Specified by:
toStatement in interface DataValue
Throws:
java.sql.SQLException - if a SQL error occurs.

dup

public com.davisor.core.Dupable dup()
Makes a deep copy of this object.

Specified by:
dup in interface com.davisor.core.Dupable

setValue

public void setValue(double value)
              throws InvalidDataException
Sets data double value.

Specified by:
setValue in interface NumberValue
Specified by:
setValue in class SimpleNumberValue
Throws:
InvalidDataException - never

setValue

public void setValue(long value)
              throws InvalidDataException
Sets data long value.

Specified by:
setValue in interface NumberValue
Specified by:
setValue in class SimpleNumberValue
Throws:
InvalidDataException - never

setValue

public void setValue(java.lang.Number value)
              throws InvalidDataException
Sets data Number value.

Specified by:
setValue in interface NumberValue
Specified by:
setValue in class SimpleNumberValue
Throws:
InvalidDataException - never


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.