JScience v2.0

org.jscience.physics.units
Class CompoundUnit<Q extends Quantity>

java.lang.Object
  extended by org.jscience.physics.units.Unit<Q>
      extended by org.jscience.physics.units.DerivedUnit<Q>
          extended by org.jscience.physics.units.CompoundUnit<Q>
All Implemented Interfaces:
java.io.Serializable

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

This class represents a compound unit. Compound units are used to express quantites using multi-radix units. Instances of this class are created using the Unit.compound(org.jscience.physics.units.Unit) method. For example:

        Unit HOUR_MINUTE_SECOND 
            = NonSI.HOUR.compound(NonSI.MINUTE).compound(SI.SECOND);

Version:
1.1, May 24, 2005
Author:
Jean-Marie Dautelle
See Also:
Unit.compound(org.jscience.physics.units.Unit), Serialized Form

Field Summary
 
Fields inherited from class org.jscience.physics.units.Unit
ONE
 
Constructor Summary
protected CompoundUnit(Unit<Q> mainUnit, Unit<Q> subUnit)
          Creates a compound unit
 
Method Summary
protected  boolean equalsImpl(java.lang.Object that)
          Indicates if the specified unit can be considered equals to the one specified (for unicity purpose).
 Unit<Q> getMainUnit()
          Returns the main unit of this compound unit.
protected  Unit<? super Q> getParentUnitImpl()
          Returns the parent units this unit is derived from.
 Unit<Q> getSubUnit()
          Returns the sub-unit of this compound unit.
protected  int hashCodeImpl()
          Returns the hash code for this unit (calculated only once as units are unique).
protected  Converter toParentUnitImpl()
          Returns the converter to the parent unit.
 
Methods inherited from class org.jscience.physics.units.Unit
alias, alternate, compound, divide, equals, getBaseUnits, getConverterTo, getDimension, getInstance, getInstances, getParentUnit, hashCode, inverse, isCompatible, label, plus, pow, readResolve, root, times, times, toBaseUnits, toParentUnit, toString, toText, transform, valueOf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompoundUnit

protected CompoundUnit(Unit<Q> mainUnit,
                       Unit<Q> subUnit)
Creates a compound unit

Parameters:
mainUnit - the main unit.
subUnit - the sub-unit.
Method Detail

getMainUnit

public Unit<Q> getMainUnit()
Returns the main unit of this compound unit.

Returns:
the main unit.

getSubUnit

public Unit<Q> getSubUnit()
Returns the sub-unit of this compound unit.

Returns:
the sub-unit.

equalsImpl

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

Specified by:
equalsImpl in class Unit<Q extends Quantity>
Returns:
true if this unit is considered equal to that unit; false otherwise.

hashCodeImpl

protected int hashCodeImpl()
Description copied from class: Unit
Returns the hash code for this unit (calculated only once as units are unique).

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

getParentUnitImpl

protected Unit<? super Q> getParentUnitImpl()
Description copied from class: Unit
Returns the parent units this unit is derived from.

Specified by:
getParentUnitImpl in class Unit<Q extends Quantity>
Returns:
the parent unit or this if this unit is a base unit or a product of base units.

toParentUnitImpl

protected Converter toParentUnitImpl()
Description copied from class: Unit
Returns the converter to the parent unit.

Specified by:
toParentUnitImpl in class Unit<Q extends Quantity>
Returns:
the converter to Unit.getParentUnitImpl()

JScience v2.0

Copyright © 2005 JScience.