|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.das2.datum.Datum
public class Datum
A Datum is a number in the context of a Unit, for example "15 microseconds.". A Datum object has methods for formatting itself as a String, representing itsself as a double in the context of another Unit, and mathematical operators that allow simple calculations to be made at the physical quantities. Also a Datum's precision can be limited to improve formatting.
Nested Class Summary | |
---|---|
static class |
Datum.Double
class backing Datums with a double. |
Method Summary | |
---|---|
Datum |
add(Datum datum)
returns a Datum whose value is the sum of this and datum, in this.getUnits(). |
Datum |
add(double d,
Units units)
returns a Datum whose value is the sum of this and value in the context of units, in this.getUnits(). |
Datum |
add(java.lang.Number value,
Units units)
returns a Datum whose value is the sum of this and value in the context of units, in this.getUnits(). |
int |
compareTo(Datum a)
compare this to another datum. |
int |
compareTo(java.lang.Object a)
compare the datum to the object. |
Datum |
convertTo(Units units)
creates an equivalent datum using a different unit. |
static Datum |
create(double value)
convenient method for creating a dimensionless Datum with the given value. |
static Datum |
create(double value,
Units units)
creates a datum with the given units and value, for example, Datum.create( 54, Units.milliseconds ) |
static Datum |
create(double value,
Units units,
DatumFormatter formatter)
Returns a Datum with a specific DatumFormatter attached to it. |
static Datum |
create(double value,
Units units,
double resolution)
Returns a Datum with the given value and limited to the given resolution. |
static Datum |
create(double value,
Units units,
double resolution,
DatumFormatter formatter)
Returns a Datum with the given value and limited to the given resolution. |
static Datum |
create(int value)
creates a dimensionless datum backed by an int. |
static Datum |
create(int value,
Units units)
creates a datum backed by an int with the given units. |
Datum |
divide(Datum a)
divide this by the datum a. |
Datum |
divide(double d)
divide this by the dimensionless double. |
Datum |
divide(java.lang.Number a,
Units units)
divide this by the Number provided in the context of units. |
protected double |
doubleValue()
returns the datum's double value. |
double |
doubleValue(Units units)
returns a double representing the datum in the context of units . |
boolean |
equals(Datum a)
returns true if the two datums are equal. |
boolean |
equals(java.lang.Object a)
returns true if the two datums are equal. |
boolean |
ge(Datum a)
returns true if this is greater than or equal to a. |
DatumFormatter |
getFormatter()
returns a formatter suitable for formatting this datum as a string. |
double |
getResolution(Units units)
returns the resolution (or precision) of the datum. |
Units |
getUnits()
returns the datum's units. |
protected java.lang.Number |
getValue()
returns the Number representing the datum's location in the space indentified by its units. |
boolean |
gt(Datum a)
returns true if this is greater than a. |
int |
hashCode()
returns a hashcode that is a function of the value and the units. |
protected int |
intValue()
returns the datum's int value. |
int |
intValue(Units units)
returns a int representing the datum in the context of units . |
boolean |
isFill()
convenience method for checking to see if a datum is a fill datum. |
boolean |
isFinite()
returns true if the value is finite, that is not INFINITY or NaN. |
boolean |
isValid()
Deprecated. Use isFinite instead, or getValue. |
boolean |
le(Datum a)
returns true if this is less than or equal to a. |
boolean |
lt(Datum a)
returns true if this is less than a. |
Datum |
multiply(Datum a)
multiply this by the datum a. |
Datum |
multiply(double d)
multiply by a dimensionless number. |
Datum |
multiply(java.lang.Number a,
Units units)
multiply this by the Number provided in the context of units. |
Datum |
subtract(Datum datum)
returns a Datum whose value is the difference of this and value. |
Datum |
subtract(double d,
Units units)
returns a Datum whose value is the difference of this and value in the context of units. |
Datum |
subtract(java.lang.Number a,
Units units)
returns a Datum whose value is the difference of this and value in the context of units. |
java.lang.String |
toString()
returns a human readable String representation of the Datum, which should also be parseable with Units.parse() |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
protected double doubleValue()
public double doubleValue(Units units)
units
.
units
- the Units in which the double should be returned
public double getResolution(Units units)
units
- the Units in which the double resolution should be returned. Note
the units must be convertable to this.getUnits().getOffsetUnits().
protected int intValue()
public int intValue(Units units)
units
.
units
- the Units in which the int should be returned
public Units getUnits()
protected java.lang.Number getValue()
public boolean isFill()
public Datum add(Datum datum)
datum
- Datum to add, that is convertable to this.getUnits().
public Datum add(java.lang.Number value, Units units)
value
- a Number to add in the context of units.units
- units defining the context of value. There should be a converter from
units to this Datum's units.
public Datum add(double d, Units units)
d
- a Number to add in the context of units.units
- units defining the context of value. There should be a converter from
units to this Datum's units.
public Datum subtract(Datum datum)
datum
- Datum to add, that is convertable to this.getUnits() or offset units.
public Datum subtract(java.lang.Number a, Units units)
a
- a Number to add in the context of units.units
- units defining the context of value. There should be a converter from
units to this Datum's units or offset units.
public Datum subtract(double d, Units units)
d
- a Number to add in the context of units.units
- units defining the context of value. There should be a converter from
units to this Datum's units or offset units.
public Datum divide(Datum a)
between convertable units, resulting in a Units.dimensionless quantity, or by a Units.dimensionless quantity, and a datum with this datum's units is returned.This may change, as a generic SI units class is planned.
a
- the datum divisor.
public Datum divide(java.lang.Number a, Units units)
between convertable units, resulting in a Units.dimensionless quantity, or by a Units.dimensionless quantity, and a datum with this datum's units is returned.This may change, as a generic SI units class is planned.
a
- the magnitude of the divisor.units
- the units of the divisor.
public Datum divide(double d)
d
- the magnitude of the divisor.
public Datum multiply(Datum a)
by a dimensionless datum, or when this is dimensionless. This may change, as a generic SI units class is planned. This should also throw an IllegalArgumentException if the units are LocationUnits (e.g. UT time), but doesn't. This may change.
a
- the datum to multiply
public Datum multiply(java.lang.Number a, Units units)
by a dimensionless datum, or when this is dimensionless. This may change, as a generic SI units class is planned. This should also throw an IllegalArgumentException if the units are LocationUnits (e.g. UT time), but doesn't. This may change.
a
- the magnitude of the multiplier.units
- the units of the multiplier.
public Datum multiply(double d)
d
- the multiplier.
public Datum convertTo(Units units) throws java.lang.IllegalArgumentException
x= Datum.create( 5, Units.seconds );
System.err.println( x.convertTo( Units.seconds ) );
units
- the new Datum's units
java.lang.IllegalArgumentException
- if the datum cannot be converted to the given units.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object a) throws java.lang.IllegalArgumentException
equals
in class java.lang.Object
a
- the Object to compare to.
java.lang.IllegalArgumentException
- if the Object is not a datum or the units are not convertable.public boolean equals(Datum a) throws java.lang.IllegalArgumentException
a
- the datum to compare
java.lang.IllegalArgumentException
- if the units are not convertable.public boolean lt(Datum a) throws java.lang.IllegalArgumentException
a
- a datum convertable to this Datum's units.
java.lang.IllegalArgumentException
- if the two don't have convertable units.public boolean gt(Datum a) throws java.lang.IllegalArgumentException
a
- a datum convertable to this Datum's units.
java.lang.IllegalArgumentException
- if the two don't have convertable units.public boolean le(Datum a) throws java.lang.IllegalArgumentException
a
- a datum convertable to this Datum's units.
java.lang.IllegalArgumentException
- if the two don't have convertable units.public boolean ge(Datum a) throws java.lang.IllegalArgumentException
a
- a datum convertable to this Datum's units.
java.lang.IllegalArgumentException
- if the two don't have convertable units.public int compareTo(java.lang.Object a) throws java.lang.IllegalArgumentException
compareTo
in interface java.lang.Comparable
a
- the Object to compare this datum to.
java.lang.IllegalArgumentException
- if a is not a Datum or is not convertable to this Datum's units.public int compareTo(Datum a) throws java.lang.IllegalArgumentException
a
- the Datum to compare this datum to.
java.lang.IllegalArgumentException
- if a is not convertable to this Datum's
units.public boolean isValid()
public boolean isFinite()
public java.lang.String toString()
toString
in class java.lang.Object
public static Datum create(double value)
value
- the magnitude of the datum.
public static Datum create(double value, Units units)
value
- the magnitude of the datum.units
- the units of the datum.
public static Datum create(double value, Units units, DatumFormatter formatter)
value
- the magnitude of the datum.units
- the units of the datum.formatter
- the DatumFormatter that should be used to format this datum, which will be
returned by getFormatter().
public static Datum create(double value, Units units, double resolution)
value
- the magnitude of the datum, or value to be interpretted in the context of units.units
- the units of the datum.resolution
- the limit to which the datum's precision is known.
public static Datum create(double value, Units units, double resolution, DatumFormatter formatter)
value
- the magnitude of the datum, or value to be interpretted in the context of units.units
- the units of the datum.resolution
- the limit to which the datum's precision is known.formatter
- the DatumFormatter that should be used to format this datum, which will be
returned by getFormatter().
public static Datum create(int value)
value
- the magnitude of the dimensionless datum.
public static Datum create(int value, Units units)
value
- the magnitude of the datumunits
- the units of the datum
public DatumFormatter getFormatter()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |