| java.lang.Object javax.measure.Measure
Measure | abstract public class Measure implements Measurable<Q>,Serializable(Code) | | This class represents the result of a measurement stated in a
known unit.
There is no constraint upon the measurement value itself: scalars,
vectors, or even data sets are valid values as long as
an aggregate magnitude can be determined (see
Measurable ).
author: Jean-Marie Dautelle version: 4.2, August 26, 2007 |
Constructor Summary | |
protected | Measure() Default constructor. |
Method Summary | |
public int | compareTo(Measurable<Q> that) Compares this measure to the specified measurable quantity.
This method compares the
Measurable.doubleValue(Unit) of
both this measure and the specified measurable stated in the
same unit (this measure's
Measure.getUnit() unit ).
a negative integer, zero, or a positive integer as this measureis less than, equal to, or greater than the specified measurablequantity. | abstract public double | doubleValue(Unit<Q> unit) Returns the value of this measure stated in the specified unit as
a double . | public boolean | equals(Object obj) Compares this measure against the specified object for
strict equality (same unit and amount).
To compare measures stated using different units the
Measure.compareTo method should be used. | public float | floatValue(Unit<Q> unit) Returns the value of this measure stated in the specified unit as a
float . | abstract public Unit<Q> | getUnit() Returns the measurement unit of this measure. | abstract public V | getValue() Returns the measurement value of this measure. | public int | hashCode() Returns the hash code for this scalar. | public int | intValue(Unit<Q> unit) Returns the estimated integral value of this measure stated in
the specified unit as a int . | public long | longValue(Unit<Q> unit) Returns the estimated integral value of this measure stated in
the specified unit as a long . | abstract public Measure<V, Q> | to(Unit<Q> unit) Returns the measure equivalent to this measure but stated in the
specified unit. | public String | toString() Returns the String representation of this measure
The string produced for a given measure is always the same;
it is not affected by locale. | public static Measure<java.lang.Double, Q> | valueOf(double doubleValue, Unit<Q> unit) Returns the scalar measure for the specified double
stated in the specified unit. | public static Measure<java.lang.Long, Q> | valueOf(long longValue, Unit<Q> unit) Returns the scalar measure for the specified double
stated in the specified unit. | public static Measure<java.lang.Float, Q> | valueOf(float floatValue, Unit<Q> unit) Returns the scalar measure for the specified float
stated in the specified unit. | public static Measure<java.lang.Integer, Q> | valueOf(int intValue, Unit<Q> unit) Returns the scalar measure for the specified int
stated in the specified unit. | public static Measure<BigDecimal, Q> | valueOf(BigDecimal decimal, Unit<Q> unit) | public static Measure<BigDecimal, Q> | valueOf(BigDecimal decimal, Unit<Q> unit, MathContext mathContext) | public static Measure<double[], Q> | valueOf(double[] components, Unit<Q> unit) |
Measure | protected Measure()(Code) | | Default constructor.
|
compareTo | public int compareTo(Measurable<Q> that)(Code) | | Compares this measure to the specified measurable quantity.
This method compares the
Measurable.doubleValue(Unit) of
both this measure and the specified measurable stated in the
same unit (this measure's
Measure.getUnit() unit ).
a negative integer, zero, or a positive integer as this measureis less than, equal to, or greater than the specified measurablequantity. Double.compare(this.doubleValue(getUnit()), that.doubleValue(getUnit())) |
doubleValue | abstract public double doubleValue(Unit<Q> unit)(Code) | | Returns the value of this measure stated in the specified unit as
a double . If the measure has too great a magnitude to
be represented as a double , it will be converted to
Double.NEGATIVE_INFINITY or
Double.POSITIVE_INFINITY as appropriate.
Parameters: unit - the unit in which this measure is stated. the numeric value after conversion to type double . |
equals | public boolean equals(Object obj)(Code) | | Compares this measure against the specified object for
strict equality (same unit and amount).
To compare measures stated using different units the
Measure.compareTo method should be used.
Parameters: obj - the object to compare with. true if both objects are identical (same unit and same amount); false otherwise. |
floatValue | public float floatValue(Unit<Q> unit)(Code) | | Returns the value of this measure stated in the specified unit as a
float . If the measure has too great a magnitude to be
represented as a float , it will be converted to
Float.NEGATIVE_INFINITY or
Float.POSITIVE_INFINITY as appropriate.
Parameters: unit - the unit in which the measure is stated. the numeric value after conversion to type float . |
getUnit | abstract public Unit<Q> getUnit()(Code) | | Returns the measurement unit of this measure.
the measurement unit. |
getValue | abstract public V getValue()(Code) | | Returns the measurement value of this measure.
the measurement value. |
hashCode | public int hashCode()(Code) | | Returns the hash code for this scalar.
the hash code value. |
intValue | public int intValue(Unit<Q> unit)(Code) | | Returns the estimated integral value of this measure stated in
the specified unit as a int .
Note: This method differs from the Number.intValue()
in the sense that the closest integer value is returned
and an ArithmeticException is raised instead
of a bit truncation in case of overflow (safety critical).
Parameters: unit - the unit in which the measurable value is stated. the numeric value after conversion to type int . throws: ArithmeticException - if this quantity cannot be represented as a int number in the specified unit. |
longValue | public long longValue(Unit<Q> unit) throws ArithmeticException(Code) | | Returns the estimated integral value of this measure stated in
the specified unit as a long .
Note: This method differs from the Number.longValue()
in the sense that the closest integer value is returned
and an ArithmeticException is raised instead
of a bit truncation in case of overflow (safety critical).
Parameters: unit - the unit in which the measurable value is stated. the numeric value after conversion to type long . throws: ArithmeticException - if this quantity cannot be represented as a long number in the specified unit. |
to | abstract public Measure<V, Q> to(Unit<Q> unit)(Code) | | Returns the measure equivalent to this measure but stated in the
specified unit. This method may result in lost of precision
(e.g. measure of integral value).
Parameters: unit - the new measurement unit. the measure stated in the specified unit. |
toString | public String toString()(Code) | | Returns the String representation of this measure
The string produced for a given measure is always the same;
it is not affected by locale. This means that it can be used
as a canonical string representation for exchanging data,
or as a key for a Hashtable, etc. Locale-sensitive
measure formatting and parsing is handled by the
MeasureFormat class and its subclasses.
the string representation of this measure. |
valueOf | public static Measure<java.lang.Double, Q> valueOf(double doubleValue, Unit<Q> unit)(Code) | | Returns the scalar measure for the specified double
stated in the specified unit.
Parameters: doubleValue - the measurement value. Parameters: unit - the measurement unit. |
valueOf | public static Measure<java.lang.Long, Q> valueOf(long longValue, Unit<Q> unit)(Code) | | Returns the scalar measure for the specified double
stated in the specified unit.
Parameters: longValue - the measurement value. Parameters: unit - the measurement unit. |
valueOf | public static Measure<java.lang.Float, Q> valueOf(float floatValue, Unit<Q> unit)(Code) | | Returns the scalar measure for the specified float
stated in the specified unit.
Parameters: floatValue - the measurement value. Parameters: unit - the measurement unit. |
valueOf | public static Measure<java.lang.Integer, Q> valueOf(int intValue, Unit<Q> unit)(Code) | | Returns the scalar measure for the specified int
stated in the specified unit.
Parameters: intValue - the measurement value. Parameters: unit - the measurement unit. |
|
|