com.davisor.data
Class VoidValue

java.lang.Object
  extended bycom.davisor.data.VoidData
      extended bycom.davisor.data.VoidValue
All Implemented Interfaces:
java.lang.Comparable, Data, DataValue, com.davisor.core.Dupable, java.io.Serializable, SerializableData
Direct Known Subclasses:
GenericValue

public class VoidValue
extends VoidData
implements DataValue

VoidValue represents an undefined value. In particular, when compared against other defined values with min(com.davisor.data.DataValue) and max(com.davisor.data.DataValue) values, the other value is always returned.

Since:
JDK1.1
See Also:
Type, VoidType, Serialized Form

Field Summary
 
Fields inherited from class com.davisor.data.VoidData
M_type
 
Constructor Summary
  VoidValue()
          Default constructor.
protected VoidValue(Type type)
          Create a new data object.
  VoidValue(VoidValue data, boolean deep)
          Deep or shallow copy constructor.
 
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.
 int compareTo(java.lang.Object o)
          Compares this void value to other values.
 double deinterpolate(DataValue min, DataValue max)
          De-interpolates the current data value to a scalar value, in respect, with the given data value range.
 DataValue div(DataValue value)
          Divides the current value with given value.
 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.
 java.lang.String getFormat()
          Gets the type specification optimal for this particular value.
 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.
 boolean isNull()
          Tests if this data object value is undetermined.
 DataValue max(DataValue value)
          Finds the larger of two data values.
 DataValue min(DataValue value)
          Finds the smaller of two data values.
 DataValue mul(DataValue value)
          Multiplies the current value with given value.
 DataValue negate()
          Returns the negation of current value.
 void setValue(java.lang.String stringValue, java.text.ParsePosition status)
          Sets data value from a string value.
 DataValue sub(DataValue value)
          Subtracts a data value.
 void toStatement(java.sql.PreparedStatement statement, int parameter)
          Converts the data to a prepared statement input parameter.
 java.lang.String toXML()
          Gets the XML string representation of this value.
 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.VoidData
equals, getDataValue, getType, hashCode, setType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.davisor.data.DataValue
toString
 
Methods inherited from interface com.davisor.data.Data
getType
 

Constructor Detail

VoidValue

public VoidValue()
Default constructor.


VoidValue

public VoidValue(VoidValue 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:
VoidData.getType(), Type.dup()

VoidValue

protected VoidValue(Type type)
Create a new data object.

Parameters:
type - The type of data.
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares this void value to other values. A void value is always equal to null values and instances of VoidValue class, and smaller than anything else.

Specified by:
compareTo in interface java.lang.Comparable
See Also:
max(com.davisor.data.DataValue), min(com.davisor.data.DataValue), Data.getType(), Compare.compareTo(Object,Object)

isNull

public boolean isNull()
Tests if this data object value is undetermined.

Specified by:
isNull in interface SerializableData
Returns:
always true
See Also:
Type.isNull(com.davisor.data.SerializableData)

abs

public DataValue abs()
              throws InvalidDataException
Returns absolute data value of current value. Taking void value absolute value returns a duplicate of this object. This behaviour is expected to be overridden by most subclasses.

Specified by:
abs in interface DataValue
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. Adding a void data value to any other data value returns a duplicate of the other value. If the other value is null, a duplicate of this object is returned. This behaviour is expected to be overridden by most subclasses.

Specified by:
add in interface DataValue
Parameters:
value - a data value to be added to this data value
Returns:
a new data object
Throws:
InvalidDataException - if the data values can not be added

ceil

public DataValue ceil(DataValue precision)
               throws InvalidDataException
Quantizes the current value up to an even value within given precision. Quantizing a void data value returns a duplicate of this object. This behaviour is expected to be overridden by most subclasses.

Specified by:
ceil in interface DataValue
Parameters:
precision - the precision within quantization occurs (ignored)
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. De-interpolating a void data value against any value range returns a NaN number value. This behaviour is expected to be overridden by most subclasses.

Specified by:
deinterpolate in interface DataValue
Parameters:
min - a data value representing a range's lower limit (ignored)
max - a data value representing a range's higher limit (ignored)
Returns:
de-interpolated scalar value (always NaN)
Throws:
InvalidDataException - if the de-interpolation fails for some other reason
See Also:
DataValue.interpolate(double, com.davisor.data.DataValue), DeinterpolationException, TupleData.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue)

div

public DataValue div(DataValue value)
              throws InvalidDataException
Divides the current value with given value. Division returns always zero value of the divider type. This behaviour is expected to be overridden by most subclasses.

Specified by:
div in interface DataValue
Parameters:
value - the divider
Returns:
a new data object.
Throws:
InvalidDataException - if current divider is null or zero value.

floor

public DataValue floor(DataValue precision)
                throws InvalidDataException
Quantizes the current value down to an even value within given precision. Quantizing a void data value returns a duplicate of this object. This behaviour is expected to be overridden by most subclasses.

Specified by:
floor in interface DataValue
Parameters:
precision - the precision within 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)

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 with the value returned by this method will ensure optimal value formatting and parsing for values of the same magnitude as this value.

The void data optimal specificaton string is always the current specification string for the current type.

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

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. The result will always be a duplicate of this object. This behaviour is expected to be overridden by most subclasses.

Specified by:
interpolate in interface DataValue
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 the interpolation fails
See Also:
DataValue.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue)

max

public DataValue max(DataValue value)
              throws InvalidDataException
Finds the larger of two data values. If the given value is null, a reference to this instance is returned, otherwise value is returned.

Please note, that this behaviour is not typical, as the same void value may be both smaller and greater than an other value, depending which of the min or max methods is called.

Specified by:
max in interface DataValue
Parameters:
value - a data value to be compared with this data value
Returns:
the largest of the compared data values
Throws:
InvalidDataException - if the data value cannot be compared
See Also:
min(com.davisor.data.DataValue)

min

public DataValue min(DataValue value)
              throws InvalidDataException
Finds the smaller of two data values. If the given value is null, a reference to this instance is returned, otherwise value is returned.

Please note, that this behaviour is not typical, as the same void value may be both smaller and greater than an other value, depending which of the min or max methods is called.

Specified by:
min in interface DataValue
Parameters:
value - a data value to be compared with this data value
Returns:
the largest of the compared data values
Throws:
InvalidDataException - if the data value cannot be compared
See Also:
max(com.davisor.data.DataValue)

mul

public DataValue mul(DataValue value)
              throws InvalidDataException
Multiplies the current value with given value. Multiplication returns always zero value of the multiplier type. This behaviour is expected to be overridden by most subclasses.

Specified by:
mul in interface DataValue
Parameters:
value - the multiplier
Returns:
a new data object.
Throws:
InvalidDataException - if current multiplier is null.

negate

public DataValue negate()
                 throws InvalidDataException
Returns the negation of current value. Taking a negation of a void value returns a duplicate of this object. This behaviour is expected to be overridden by most subclasses.

Specified by:
negate in interface DataValue
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.

Void values have no value, so given string value is just ignored.

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

sub

public DataValue sub(DataValue value)
              throws InvalidDataException
Subtracts a data value. Substracting a value from a void value returns a negation of the other value. This behaviour is expected to be overridden by most subclasses.

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

toStatement

public void toStatement(java.sql.PreparedStatement statement,
                        int parameter)
                 throws java.sql.SQLException
Converts the data to a prepared statement input parameter. The parameter value is always set to null.

Specified by:
toStatement in interface DataValue
Parameters:
statement - statement to be updated
parameter - index of the statement parameter to be updated
Throws:
java.sql.SQLException - if a SQL error occurs.

toXML

public java.lang.String toXML()
Gets the XML string representation of this value.

This default implementation returns always <null/> tag.

Specified by:
toXML in interface DataValue
Returns:
complete string representing the data.
See Also:
VoidData.toString(), XMLUnicodeEncoder.encode(java.lang.String, boolean)

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. Taking an unit step from a void data value returns a duplicate of this object. This behaviour is expected to be overridden by most subclasses.

Specified by:
unit in interface DataValue
Parameters:
targetValue - target value to be reached (ignored)
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


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