org.cts.units
Class Measure

java.lang.Object
  extended by org.cts.units.Measure
All Implemented Interfaces:
Serializable

public class Measure
extends Object
implements Serializable

Author:
Michaƫl Michaud
See Also:
Serialized Form

Constructor Summary
Measure(double value, Unit unit)
          Creates a new Measure.
Measure(Number value, Unit unit)
          Creates a new Measure.
Measure(Number value, Unit unit, double precision)
          Creates a new Measure.
 
Method Summary
 Measure convert(Unit unit)
          Converts this measure to another unit.
 Unit getCompatibleUnit(Unit... units)
          Get compatible Unit for this unit It uses after WKT parsing.
 double getPrecision()
          Gets the precision of this measure.
 Quantity getQuantity()
          Gets the Quantity measured.
 double getSValue()
          Gets the value of this measure expressed as a double in the base unit.
 Unit getUnit()
          Gets the unit of this measure.
 Number getValue()
          Gets the value of this measure.
 void setUnit(Unit unit)
          Set the unit of this measure.
 void setValue(Number value)
          Set Value of this measure.
 Measure toBaseUnit()
          Gets the same Measure using the base unit.
 String toString()
          Returns the measure as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Measure

public Measure(double value,
               Unit unit)
Creates a new Measure.

Parameters:
value - the value of the measure
unit - the unit used to express the measure

Measure

public Measure(Number value,
               Unit unit)
Creates a new Measure.

Parameters:
value - the value of the measure
unit - the unit used to express the measure

Measure

public Measure(Number value,
               Unit unit,
               double precision)
Creates a new Measure.

Parameters:
value - the value of the measure
unit - the unit used to express the measure
precision - of this measure. If different from NaN, this parameter can be used to express a limit in this measure precision for future calculations.
Method Detail

getSValue

public double getSValue()
Gets the value of this measure expressed as a double in the base unit. The S stands for 'SI' or for 'Standard'. Prefer this method for calculation and performance, and getValue for precision.


getValue

public Number getValue()
Gets the value of this measure.


setValue

public void setValue(Number value)
Set Value of this measure.

Parameters:
value - the new Value to set to this Measure

getUnit

public Unit getUnit()
Gets the unit of this measure.


setUnit

public void setUnit(Unit unit)
Set the unit of this measure.

Parameters:
unit - the new Unit to set to this Measure

getQuantity

public Quantity getQuantity()
Gets the Quantity measured.


getPrecision

public double getPrecision()
Gets the precision of this measure.


toBaseUnit

public Measure toBaseUnit()
Gets the same Measure using the base unit. The measure value in the base unit is a Double.


convert

public Measure convert(Unit unit)
                throws IllegalArgumentException
Converts this measure to another unit. The measure value in the new unit system is a Double.

Parameters:
unit - the new unit for the returned measure
Throws:
IllegalArgumentException

toString

public String toString()
Returns the measure as a String.

Overrides:
toString in class Object

getCompatibleUnit

public Unit getCompatibleUnit(Unit... units)
Get compatible Unit for this unit It uses after WKT parsing. Get the compatible Unit parsed from WKT.

Parameters:
units - : list of possible compatible Unit


Copyright © 2014 IRSTV CNRS-FR-2488. All Rights Reserved.