com.davisor.data
Class BigIntegerData

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

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

BigIntegerData represents arbitrary precision integer number data. The data value inside may also be null. This indicates that the number value of this object is undetermined.

Since:
JDK1.3
See Also:
BigIntegerType, Serialized Form

Field Summary
static int PRECISION
          Deinterpolation scale precision (10).
static java.math.BigInteger TEN
          Constant big integer value of 10.
 
Fields inherited from class com.davisor.data.SimpleNumberValue
M_type, M_value
 
Constructor Summary
BigIntegerData()
          Construct a new big integer data object with the default type and value (BigInteger.ZERO).
BigIntegerData(BigIntegerData data)
          Shallow copy constructor.
BigIntegerData(BigIntegerData data, boolean deep)
          Deep or shallow copy constructor.
BigIntegerData(BigIntegerType type, java.lang.String stringValue, java.text.ParsePosition status)
          Creates a big integer data value from a string value.
BigIntegerData(long value)
          Construct a new big integer data object with the default type and given value.
BigIntegerData(java.lang.Number value)
          Constructs a big integer data object with the default type and given value.
BigIntegerData(NumberType type)
          Construct a new integer data object with the given big type and default value (BigInteger.ZERO).
BigIntegerData(NumberType type, long value)
          Construct a new big integer data object with the given type and value.
BigIntegerData(NumberType type, java.lang.Number value)
          Construct a new big integer data object with the given type and value.
 
Method Summary
 DataValue abs()
          Returns absolute data value of current value.
 DataValue add(DataValue value)
          Adds data values.
 DataValue ceil(DataValue precision)
          Quantizes the current value up to an even value within given precision.
 double deinterpolate(DataValue min, DataValue max)
          De-interpolates the current data value to a scalar value, in respect, with the given data value range.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 DataValue floor(DataValue precision)
          Quantizes the current value down to an even value within given precision.
 DataValue interpolate(double value, DataValue max)
          Interpolates the given scalar value to data value, in respect, with the range defined by this value and the given maximum value.
 DataValue negate()
          Returns the negation of current value.
 void setValue(double value)
          Sets the data double value.
 void setValue(long value)
          Sets the data integer value.
 void setValue(java.lang.Number value)
          Sets the data Number value.
 void setValue(java.lang.String stringValue, java.text.ParsePosition status)
          Sets data value from a string value.
 DataValue sub(DataValue value)
          Substracts a data value.
 void toStatement(java.sql.PreparedStatement statement, int parameter)
          Converts data to a prepared statement input parameter.
 DataValue unit(DataValue targetValue, double maxSteps)
          Gets the largest suitable unit step to represent a value change between this value and the given target value.
 
Methods inherited from class com.davisor.data.SimpleNumberValue
byteValue, compareTo, div, doubleValue, equals, floatValue, getFormat, getFormat, getType, hashCode, intValue, isNull, longValue, max, min, mul, numberValue, setValue, setValue, setValue, setValue, shortValue, toString, toXML
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TEN

public static final java.math.BigInteger TEN
Constant big integer value of 10.


PRECISION

public static final int PRECISION
Deinterpolation scale precision (10).

See Also:
Constant Field Values
Constructor Detail

BigIntegerData

public BigIntegerData()
Construct a new big integer data object with the default type and value (BigInteger.ZERO).


BigIntegerData

public BigIntegerData(BigIntegerData data)
Shallow copy constructor.

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

BigIntegerData

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

BigIntegerData

public BigIntegerData(java.lang.Number value)
Constructs a big integer data object with the default type and given value.

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

BigIntegerData

public BigIntegerData(long value)
Construct a new big integer data object with the default type and given value.

Parameters:
value - data value
See Also:
BigIntegerData(NumberType,long)

BigIntegerData

public BigIntegerData(NumberType type)
Construct a new integer data object with the given big type and default value (BigInteger.ZERO).

See Also:
BigIntegerData(NumberType,long)

BigIntegerData

public BigIntegerData(NumberType type,
                      java.lang.Number value)
Construct a new big integer 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)

BigIntegerData

public BigIntegerData(NumberType type,
                      long value)
Construct a new big integer 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)

BigIntegerData

public BigIntegerData(BigIntegerType type,
                      java.lang.String stringValue,
                      java.text.ParsePosition status)
               throws InvalidDataException
Creates a big integer 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

add

public DataValue add(DataValue value)
              throws InvalidDataException
Adds data values.

Specified by:
add in interface DataValue
Overrides:
add in class SimpleNumberValue
Parameters:
value - a data value to be added to this data value
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if the data values cannot be added

ceil

public DataValue ceil(DataValue precision)
               throws InvalidDataException
Quantizes the current value up to an even value within given precision. The returned value is more than or equal with the current value, but not more than the current value added by given precision.

Specified by:
ceil in interface DataValue
Overrides:
ceil in class SimpleNumberValue
Parameters:
precision - the precision within the quantization occurs
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if precision was of unacceptable type
See Also:
floor(com.davisor.data.DataValue)

deinterpolate

public double deinterpolate(DataValue min,
                            DataValue max)
                     throws InvalidDataException
De-interpolates the current data value to a scalar value, in respect, with the given data value range. This gives scalar values between [0,1], when the current data value is within the range, negative scalar values when the data value falls below the range and scalar values greater than 1.0 otherwise.

Big integer values are de-interpolated with the equation:

(thisValue - minValue) / (maxValue - minValue)

Specified by:
deinterpolate in interface DataValue
Overrides:
deinterpolate in class SimpleNumberValue
Parameters:
min - a data value representing a range's lower limit
max - a data value representing a range's higher limit
Returns:
de-interpolated scalar value (may be NaN)
Throws:
InvalidDataException - if the de-interpolation fails

floor

public DataValue floor(DataValue precision)
                throws InvalidDataException
Quantizes the current value down to an even value within given precision. The returned value is less than or equal with the current value, but not less than the current value substracted by given precision.

Specified by:
floor in interface DataValue
Overrides:
floor in class SimpleNumberValue
Parameters:
precision - the precision within the quantization occurs
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if precision was of unacceptable type
See Also:
ceil(com.davisor.data.DataValue)

interpolate

public DataValue interpolate(double value,
                             DataValue max)
                      throws InvalidDataException
Interpolates the given scalar value to data value, in respect, with the range defined by this value and the given maximum value. Scalar values between [0,1] result in data values between the current value and the given maximum value. Negative scalar values result in values smaller than this value, and scalar values higher than 1.0 return data values above the given maximum.

All number values can interpolate with this simple equation:

minValue + value * (maxValue - minValue)

Specified by:
interpolate in interface DataValue
Overrides:
interpolate in class SimpleNumberValue
Parameters:
value - the scalar value to be interpolated
max - a data value representing a range's higher limit
Returns:
a new data object containing the result
Throws:
InvalidDataException - if interpolation fails

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:
BigIntegerType.decode(String,ParsePosition)

sub

public DataValue sub(DataValue value)
              throws InvalidDataException
Substracts a data value.

Specified by:
sub in interface DataValue
Overrides:
sub in class SimpleNumberValue
Parameters:
value - a data value to be substracted from this data value
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if value can not be substracted.

toStatement

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

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

unit

public DataValue unit(DataValue targetValue,
                      double maxSteps)
               throws InvalidDataException
Gets the largest suitable unit step to represent a value change between this value and the given target value. If the values are equal, a type specific default unit step is returned. If the values are not equal, then the given target value must be reached from this value by adding the returned unit step to this value once or more.

Specified by:
unit in interface DataValue
Overrides:
unit in class SimpleNumberValue
Parameters:
targetValue - target value to be reached (may be null)
maxSteps - maximum number of steps (zero leaves the choise open)
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if target value is unsuitable

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 the data double value.

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

setValue

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

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

setValue

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