|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
DataValue defines a generic interface for data values.
Type| Method Summary | |
DataValue |
abs()
Returns absolute data value of current value. |
DataValue |
add(DataValue value)
Adds this and given 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. |
DataValue |
div(DataValue value)
Divides the current value with given value. |
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. |
DataValue |
max(DataValue value)
Finds the larger of this and the given data value. |
DataValue |
min(DataValue value)
Finds the smaller of this and the given data value. |
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 the data value from a string value. |
DataValue |
sub(DataValue value)
Substracts given data value from this data value. |
void |
toStatement(java.sql.PreparedStatement statement,
int parameter)
Converts the data to a prepared statement input parameter. |
java.lang.String |
toString()
Gets the string representation of this data value. |
java.lang.String |
toXML()
Gets the XML string representation of this data 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 interface java.lang.Comparable |
compareTo |
| Methods inherited from interface com.davisor.data.SerializableData |
isNull |
| Methods inherited from interface com.davisor.data.Data |
getType |
| Methods inherited from interface com.davisor.core.Dupable |
dup |
| Method Detail |
public DataValue abs()
throws InvalidDataException
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.
InvalidDataException - if absolute value can not be computed
public DataValue add(DataValue value)
throws InvalidDataException
value - a data value to be added to this data value
InvalidDataException - if data values cannot be added
public DataValue ceil(DataValue precision)
throws InvalidDataException
precision - the precision within quantization occurs
InvalidDataException - if precision was of unacceptable typefloor(DataValue),
Type.ceil(com.davisor.data.DataValue, com.davisor.data.DataValue, com.davisor.data.DataValue)
public double deinterpolate(DataValue min,
DataValue max)
throws InvalidDataException
It has been a definite design decision to restrict de-interpolation values to single double values instead of more elaborate data structures that would allow the representation of multi-dimensional de-interpolation results. For a multidimensional object, linear interpolation rarely makes any sense, and if it does, multi-dimensional objects must define their own interpolation schemes anyway. The only multi-dimensional data that would have benefited from multi-dimensional de-interpolation results would have been data structures that carry several unrelated data values. The benefits gained from their convenient one-operation de-interpolation would not, however, be enough to justify the inconvenience caused by the increased de-interpolation value access complexity. Instead, multi-dimensional data structures with unrelated elements should be de-interpolated element by element under explicit guidance.
It is also recommended that generic multi-dimensional de-interpolation operations de-interpolate their members separately, and return a result only if member de-interpolation results are mutually equal. In any other case, the de-interpolation should fail. Such implementations are, however, urged to make a difference between ordinary de-interpolation failures and failures due to member de-interpolation value conflicts.
Deinterpolation failures may be reported through appropriate
exceptions, or by returning Double.NaN.
Double.NaN indicates a mathematically invalid result
like division by zero when values of compatible types are applied
to each other. Exceptions report incompatible values and types,
like when trying for example to deinterpolate text against dates.
min - a data value representing a range's lower limitmax - a data value representing a range's higher limit
DeinterpolationException - if the de-interpolation fails due
to a de-interpolation value conflict
InvalidDataException - if the de-interpolation fails for some
other reasoninterpolate(double, com.davisor.data.DataValue),
DeinterpolationException,
TupleData.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue)
public DataValue div(DataValue value)
throws InvalidDataException
value - the divider
InvalidDataException - if current value cannot be divided with
given divider.
public DataValue floor(DataValue precision)
throws InvalidDataException
precision - the precision within the quantization occurs
InvalidDataException - if precision was of unacceptable typeceil(DataValue),
Type.floor(com.davisor.data.DataValue, com.davisor.data.DataValue, com.davisor.data.DataValue)public java.lang.String getFormat()
Data.getType(),
Type.getFormat(),
Type.setFormat(java.lang.String)
public DataValue interpolate(double value,
DataValue max)
throws InvalidDataException
value - the scalar value to be interpolatedmax - a data value representing a range's higher limit
InvalidDataException - if the interpolation failsdeinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue)
public DataValue max(DataValue value)
throws InvalidDataException
If the given value is null or an
instance of VoidValue, a reference to
this instance is returned.
value - a data value to be compared with this data value
(may be null)
InvalidDataException - if the values cannot be compared
public DataValue min(DataValue value)
throws InvalidDataException
If the given value is null or an
instance of VoidValue, a reference to
this instance is returned.
value - a data value to be compared with this data value
(may be null)
InvalidDataException - if the values cannot be compared
public DataValue mul(DataValue value)
throws InvalidDataException
value - the multiplier
InvalidDataException - if current value cannot be multiplied with
given multiplier.
public DataValue negate()
throws InvalidDataException
InvalidDataException - if absolute value can not be computed
public void setValue(java.lang.String stringValue,
java.text.ParsePosition status)
throws InvalidDataException
stringValue - string value to be parsed (may be null)status - parse status (may be null)
InvalidDataException - if string value could not be parserCountType.countValue(String,ParsePosition)
public DataValue sub(DataValue value)
throws InvalidDataException
value - a data value to be substracted from this data value
InvalidDataException - if value can not be
substracted
public void toStatement(java.sql.PreparedStatement statement,
int parameter)
throws java.sql.SQLException
java.sql.SQLException - if a SQL error occurspublic java.lang.String toString()
Note that this method overlaps the standard Java Object class interface. The semantics for the string returned by this method are, however, more strict than those of the standard method.
toXML(),
Type.toData(String,ParsePosition)public java.lang.String toXML()
Note that this method resembles the toString() method, and
indeed, many implementations are expected to use one of these
methods to generate output for the other.
toString(),
Type.toData(String,ParsePosition)
public DataValue unit(DataValue targetValue,
double maxSteps)
throws InvalidDataException
targetValue - target value to be reached (may be null)maxSteps - maximum number of steps (zero leaves the choise open)
InvalidDataException - if target value is unsuitable
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||