com.davisor.data
Class FloatData

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

public class FloatData
extends SimpleNumberValue

FloatData represents float 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:
FloatType, Serialized Form

Field Summary
 
Fields inherited from class com.davisor.data.SimpleNumberValue
M_type, M_value
 
Constructor Summary
FloatData()
          Creates a new float number data object with the default type and value (0.0)
FloatData(float value)
          Create a new float number data object with the default type and given value.
FloatData(FloatData data)
          Shallow copy constructor.
FloatData(FloatData data, boolean deep)
          Deep or shallow copy constructor.
FloatData(FloatType type, java.lang.String stringValue, java.text.ParsePosition status)
          Creates a float data value from a string value.
FloatData(java.lang.Number value)
          Creates a new float number data object with the default type and given value.
FloatData(NumberType type)
          Create a new float number data object with the given float type and default value (0.0).
FloatData(NumberType type, float value)
          Create a new float number data object with the given type and value.
FloatData(NumberType type, java.lang.Number value)
          Create a new float number data object with the given type and 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 the data float value.
 void setValue(float value)
          Sets the data float value.
 void setValue(long value)
          Sets the 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)
          Converts 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, shortValue, sub, toString, toXML, unit
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FloatData

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

See Also:
FloatData(NumberType,float)

FloatData

public FloatData(FloatData data)
Shallow copy constructor.

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

FloatData

public FloatData(FloatData 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)

FloatData

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

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

FloatData

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

Parameters:
value - data value
See Also:
FloatData(NumberType,float)

FloatData

public FloatData(NumberType type)
Create a new float number data object with the given float type and default value (0.0).

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

FloatData

public FloatData(NumberType type,
                 java.lang.Number value)
Create a new float number 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)

FloatData

public FloatData(NumberType type,
                 float value)
Create a new float 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)

FloatData

public FloatData(FloatType type,
                 java.lang.String stringValue,
                 java.text.ParsePosition status)
          throws InvalidDataException
Creates a float 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 the current type specification equal to the value returned by this method will ensure optimal value formatting and parsing for values of the same magnitude as this value.

The float data optimal specificaton 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.

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:
SimpleNumberType.floatValue(String,ParsePosition)

toStatement

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

Throws:
java.sql.SQLException - if a SQL error occurs.

dup

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


setValue

public void setValue(float value)
              throws InvalidDataException
Sets the data float value.

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

setValue

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

Specified by:
setValue in interface NumberValue
Specified by:
setValue in class SimpleNumberValue
Throws:
InvalidDataException - if the value cannot be converted to a float value

setValue

public void setValue(long value)
              throws InvalidDataException
Sets the 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.