javax.measure.unit
Class CompoundUnit<Q extends Quantity>

java.lang.Object
  extended by javax.measure.unit.Unit<Q>
      extended by javax.measure.unit.DerivedUnit<Q>
          extended by javax.measure.unit.CompoundUnit<Q>
All Implemented Interfaces:
java.io.Serializable

public final class CompoundUnit<Q extends Quantity>
extends DerivedUnit<Q>

This class represents the multi-radix units (such as "hour:min:sec"). Instances of this class are created using the Unit.compound method. Instances of this class are used mostly for formatting purpose.

Examples of compound units:

     Unit<Duration> HOUR_MINUTE_SECOND = HOUR.compound(MINUTE).compound(SECOND);
     Unit<Angle> DEGREE_MINUTE_ANGLE = DEGREE_ANGLE.compound(MINUTE_ANGLE);
     Unit<Length> FOOT_INCH = FOOT.compound(INCH);
     

Version:
1.0, April 15, 2009
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.measure.unit.Unit
ONE
 
Method Summary
 boolean equals(java.lang.Object that)
          Indicates if the specified unit can be considered equals to the one specified.
 UnitConverter getConverterTo(Unit<Q> unit)
          Returns a converter of numeric values from this unit to another unit.
 Unit<Q> getHigh()
          Returns the high unit(s) of this compound unit (can be a CompoundUnit itself).
 Unit<Q> getLow()
          Returns the lowest unit or main unit of this compound unit (never a CompoundUnit).
 int hashCode()
          Returns the hash code for this unit.
 Unit<Q> toSI()
          Returns the standard unit from which this unit is derived.
 java.lang.String toString()
          Overrides the default implementation as compound units are not recognized by the standard UCUM format.
 
Methods inherited from class javax.measure.unit.Unit
alternate, asType, compound, divide, divide, divide, getDimension, inverse, isCompatible, isSI, plus, pow, root, times, times, times, transform, valueOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getLow

public Unit<Q> getLow()
Returns the lowest unit or main unit of this compound unit (never a CompoundUnit).

Returns:
the lower unit.

getHigh

public Unit<Q> getHigh()
Returns the high unit(s) of this compound unit (can be a CompoundUnit itself).

Returns:
the high unit(s).

equals

public boolean equals(java.lang.Object that)
Description copied from class: Unit
Indicates if the specified unit can be considered equals to the one specified.

Specified by:
equals in class Unit<Q extends Quantity>
Parameters:
that - the object to compare to.
Returns:
true if this unit is considered equal to that unit; false otherwise.

hashCode

public int hashCode()
Description copied from class: Unit
Returns the hash code for this unit.

Specified by:
hashCode in class Unit<Q extends Quantity>
Returns:
this unit hashcode value.

toString

public java.lang.String toString()
Overrides the default implementation as compound units are not recognized by the standard UCUM format.

Overrides:
toString in class Unit<Q extends Quantity>
Returns:
the textual representation of this compound unit.

toSI

public Unit<Q> toSI()
Description copied from class: Unit
Returns the standard unit from which this unit is derived. The SI unit identifies the "type" of quantity for which this unit is employed. For example:
     boolean isAngularVelocity(Unit<?> u) {
         return u.toSI().equals(RADIAN.divide(SECOND));
     }
     assert(REVOLUTION.divide(MINUTE).isAngularVelocity());
 

Note: Having the same SI unit is not sufficient to ensure that a converter exists between the two units (e.g. °C/m and K/m).

Specified by:
toSI in class Unit<Q extends Quantity>
Returns:
the system unit this unit is derived from.

getConverterTo

public final UnitConverter getConverterTo(Unit<Q> unit)
Description copied from class: Unit
Returns a converter of numeric values from this unit to another unit. As a minimum unit sub-classes should be able to provide a unit converter to their associated standard unit.

Overrides:
getConverterTo in class Unit<Q extends Quantity>
Parameters:
unit - the unit to which to convert the numeric values.
Returns:
the converter from this unit to that unit.


Copyright © 2009 JScience. All Rights Reserved.