ucar.units
Class TimeScaleUnit

java.lang.Object
  extended by ucar.units.UnitImpl
      extended by ucar.units.TimeScaleUnit
All Implemented Interfaces:
java.io.Serializable, Unit

public final class TimeScaleUnit
extends UnitImpl

Provides support for a reference time unit whose origin is at a certain time. Instances of this class are immutable.

Version:
$Id: TimeScaleUnit.java 64 2006-07-12 22:30:50Z edavis $
Author:
Steven R. Emmerson
See Also:
Serialized Form

Nested Class Summary
protected static class TimeScaleUnit.MyConverter
          Provides support for Converter-s.
 
Constructor Summary
TimeScaleUnit(Unit unit, java.util.Date origin)
          Constructs from a reference unit and a time origin.
TimeScaleUnit(Unit unit, java.util.Date origin, UnitName id)
          Constructs from a reference unit, a time origin, and an identifier.
 
Method Summary
 Unit clone(UnitName id)
          Clones this unit, changing the identifier.
 boolean equals(java.lang.Object object)
          Indicates if this unit is semantically identical to an object.
 java.lang.String getCanonicalString()
          Returns the canonical string representation of the unit.
 Converter getConverterTo(Unit outputUnit)
          Returns a Converter for converting numeric values from this unit to another unit.
 DerivedUnit getDerivedUnit()
          Returns the derived unit underlying the reference time unit.
 java.util.Date getOrigin()
          Returns the time origin.
 Unit getUnit()
          Returns the reference unit.
 boolean isCompatible(Unit that)
          Indicates if numeric values in this unit are convertible to another unit.
 boolean isDimensionless()
          Indicates if this unit is dimensionless.
static void main(java.lang.String[] args)
          Tests this class.
protected  Unit myDivideBy(Unit that)
          Divides this unit by another unit.
protected  Unit myDivideInto(Unit that)
          Divides this unit into another unit.
protected  Unit myMultiplyBy(Unit that)
          Multiplies this unit by another unit.
protected  Unit myRaiseTo(int power)
          Raises this unit to a power.
 java.lang.String toString()
          Returns the string representation of this unit.
 
Methods inherited from class ucar.units.UnitImpl
convertTo, convertTo, convertTo, convertTo, convertTo, convertTo, divideBy, divideInto, getName, getPlural, getSymbol, getUnitName, makeLabel, multiplyBy, raiseTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeScaleUnit

public TimeScaleUnit(Unit unit,
                     java.util.Date origin)
              throws BadUnitException,
                     UnitSystemException
Constructs from a reference unit and a time origin.

Parameters:
unit - The reference time unit.
origin - The time origin.
Throws:
BadUnitException - unit is not a unit of time.
UnitSystemException

TimeScaleUnit

public TimeScaleUnit(Unit unit,
                     java.util.Date origin,
                     UnitName id)
              throws BadUnitException,
                     UnitSystemException
Constructs from a reference unit, a time origin, and an identifier.

Parameters:
unit - The reference time unit.
origin - The time origin.
id - The identifier.
Throws:
BadUnitException - unit is not a unit of time.
UnitSystemException
Method Detail

getUnit

public Unit getUnit()
Returns the reference unit.

Returns:
The reference unit.

getOrigin

public java.util.Date getOrigin()
Returns the time origin.

Returns:
The time origin.

clone

public Unit clone(UnitName id)
Clones this unit, changing the identifier.

Parameters:
id - The new identifier.
Returns:
This unit with the new identifier.

myMultiplyBy

protected Unit myMultiplyBy(Unit that)
                     throws MultiplyException
Multiplies this unit by another unit. This operation is invalid.

Specified by:
myMultiplyBy in class UnitImpl
Parameters:
that - The other unit.
Returns:
The product of multiplying this unit by the other unit.
Throws:
MultiplyException - Illegal operation. Always thrown.

myDivideBy

protected Unit myDivideBy(Unit that)
                   throws DivideException
Divides this unit by another unit. This operation is invalid.

Specified by:
myDivideBy in class UnitImpl
Parameters:
that - The other unit.
Returns:
The quotient of dividing this unit by the other unit.
Throws:
DivideException - Illegal operation. Always thrown.

myDivideInto

protected Unit myDivideInto(Unit that)
                     throws DivideException
Divides this unit into another unit. This operation is invalid.

Specified by:
myDivideInto in class UnitImpl
Parameters:
that - The other unit.
Returns:
The quotient of dividing this unit into the other unit.
Throws:
DivideException - Illegal operation. Always thrown.

myRaiseTo

protected Unit myRaiseTo(int power)
                  throws RaiseException
Raises this unit to a power. This operation is invalid.

Specified by:
myRaiseTo in class UnitImpl
Parameters:
power - The power.
Returns:
The result of raising this unit to the power.
Throws:
RaiseException - Illegal operation. Always thrown.

getDerivedUnit

public DerivedUnit getDerivedUnit()
Returns the derived unit underlying the reference time unit.

Returns:
The derived unit underlying the reference time unit.

getConverterTo

public Converter getConverterTo(Unit outputUnit)
                         throws ConversionException
Returns a Converter for converting numeric values from this unit to another unit.

Specified by:
getConverterTo in interface Unit
Overrides:
getConverterTo in class UnitImpl
Parameters:
outputUnit - The other unit. Shall be a TimeScaleUnit.
Returns:
A Converter.
Throws:
ConversionException - outputUnit is not a TimeScaleUnit.

isCompatible

public final boolean isCompatible(Unit that)
Indicates if numeric values in this unit are convertible to another unit.

Specified by:
isCompatible in interface Unit
Overrides:
isCompatible in class UnitImpl
Parameters:
that - The other unit.
Returns:
true if and only if numeric values in this unit are convertible to that.

equals

public boolean equals(java.lang.Object object)
Indicates if this unit is semantically identical to an object.

Specified by:
equals in interface Unit
Overrides:
equals in class UnitImpl
Parameters:
object - The object.
Returns:
true if and only if this unit is semantically identical to object .

isDimensionless

public boolean isDimensionless()
Indicates if this unit is dimensionless. TimeScaleUnit-s are never dimensionless.

Returns:
false.

toString

public java.lang.String toString()
Returns the string representation of this unit.

Specified by:
toString in interface Unit
Overrides:
toString in class UnitImpl
Returns:
The string representation of this unit.

getCanonicalString

public java.lang.String getCanonicalString()
Returns the canonical string representation of the unit.

Returns:
The canonical string representation.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Tests this class.

Throws:
java.lang.Exception