|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.units.UnitImpl
ucar.units.OffsetUnit
public final class OffsetUnit
Provides support for units that are offset from reference units (ex: as the unit "degree Celsius" is offset from the reference unit "kelvin"). Instances of this class are immutable.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class ucar.units.UnitImpl |
|---|
UnitImpl.MyConverter |
| Constructor Summary | |
|---|---|
OffsetUnit(Unit unit,
double offset)
Constructs from a reference unit and an offset. |
|
OffsetUnit(Unit unit,
double offset,
UnitName id)
Constructs from a reference unit, and offset, and a unit 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. |
double |
fromDerivedUnit(double amount)
Converts a value in the convertible derived unit to the equivalent value in this unit. |
double[] |
fromDerivedUnit(double[] input,
double[] output)
Converts values in the convertible derived unit to the equivalent values in this unit. |
float |
fromDerivedUnit(float amount)
Converts a value in the convertible derived unit to the equivalent value in this unit. |
float[] |
fromDerivedUnit(float[] input,
float[] output)
Converts values in the convertible derived unit to the equivalent values in this unit. |
java.lang.String |
getCanonicalString()
Returns the canonical string representation of the unit. |
DerivedUnit |
getDerivedUnit()
Returns the derived unit that is convertible with this unit. |
double |
getOffset()
Returns the offset. |
Unit |
getUnit()
Returns the reference unit. |
boolean |
isDimensionless()
Indicates if this unit is dimensionless. |
static void |
main(java.lang.String[] args)
Tests this class. |
protected Unit |
myDivideBy(Unit that)
Divide this unit by another unit. |
protected Unit |
myDivideInto(Unit that)
Divide this unit into another unit. |
protected Unit |
myMultiplyBy(Unit that)
Multiply this unit by another unit. |
protected Unit |
myRaiseTo(int power)
Raise this unit to a power. |
double |
toDerivedUnit(double amount)
Converts a value in this unit to the equivalent value in the convertible derived unit. |
double[] |
toDerivedUnit(double[] input,
double[] output)
Converts values in this unit to the equivalent values in the convertible derived unit. |
float |
toDerivedUnit(float amount)
Converts a value in this unit to the equivalent value in the convertible derived unit. |
float[] |
toDerivedUnit(float[] input,
float[] output)
Converts values in this unit to the equivalent values in the convertible derived unit. |
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, getConverterTo, getName, getPlural, getSymbol, getUnitName, isCompatible, makeLabel, multiplyBy, raiseTo |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public OffsetUnit(Unit unit,
double offset)
unit - The reference unit.offset - The origin of this unit in terms of the
reference unit. For example, a degree
Celsius unit would be created as "new
OffsetUnit(kelvin, 273.15).
public OffsetUnit(Unit unit,
double offset,
UnitName id)
unit - The reference unit.offset - The origin of this unit in terms of the
reference unit. For example, a degree
Celsius unit would be created as "new
OffsetUnit(kelvin, 273.15).id - The identifier for the new unit.| Method Detail |
|---|
public Unit getUnit()
public double getOffset()
public Unit clone(UnitName id)
clone in interface Unitid - The identifier for the new unit.
protected Unit myMultiplyBy(Unit that)
throws MultiplyException
myMultiplyBy in class UnitImplthat - The unit to multiply this unit by.
that.
The offset of this unit will be ignored; thus,
for example "celsius.myMultiplyBy(day)" is
equivalent to "kelvin.myMultiplyBy(day)".
MultiplyException - Can't multiply these units together.
protected Unit myDivideBy(Unit that)
throws OperationException
myDivideBy in class UnitImplthat - The unit to divide this unit by.
that.
The offset of this unit will be ignored; thus,
for example "celsius.myDivideBy(day)" is
equivalent to "kelvin.myDivideBy(day)".
OperationException - Can't divide these units.
protected Unit myDivideInto(Unit that)
throws OperationException
myDivideInto in class UnitImplthat - The unit to divide this unit into.
that unit and
this unit. The offset of this unit will be
ignored; thus, for example
"celsius.myDivideInto(day)" is equivalent to
"kelvin.myDivideInto(day)".
OperationException - Can't divide these units.
protected Unit myRaiseTo(int power)
throws RaiseException
myRaiseTo in class UnitImplpower - The power to raise this unit by.
power.
The offset of this unit will be
ignored; thus, for example
"celsius.myRaiseTo(2)" is equivalent to
"kelvin.myRaiseTo(2)".
RaiseException - Can't raise this unit to a power.public DerivedUnit getDerivedUnit()
getDerivedUnit in interface DerivableUnitgetDerivedUnit in interface Unit
public float toDerivedUnit(float amount)
throws ConversionException
toDerivedUnit in interface DerivableUnitamount - The value in this unit.
ConversionException - Can't convert between units.
public double toDerivedUnit(double amount)
throws ConversionException
toDerivedUnit in interface DerivableUnitamount - The value in this unit.
ConversionException - Can't convert between units.
public float[] toDerivedUnit(float[] input,
float[] output)
throws ConversionException
toDerivedUnit in interface DerivableUnitinput - The values in this unit.output - The equivalent values in the convertible
derived unit. May be the same array as
input.
output.
ConversionException - Can't convert between units.
public double[] toDerivedUnit(double[] input,
double[] output)
throws ConversionException
toDerivedUnit in interface DerivableUnitinput - The values in this unit.output - The equivalent values in the convertible
derived unit. May be the same array as
input.
output.
ConversionException - Can't convert between units.
public float fromDerivedUnit(float amount)
throws ConversionException
fromDerivedUnit in interface DerivableUnitamount - The value in the convertible derived unit.
ConversionException - Can't convert between units.
public double fromDerivedUnit(double amount)
throws ConversionException
fromDerivedUnit in interface DerivableUnitamount - The value in the convertible derived unit.
ConversionException - Can't convert between units.
public float[] fromDerivedUnit(float[] input,
float[] output)
throws ConversionException
fromDerivedUnit in interface DerivableUnitinput - The values in the convertible derived unit.output - The equivalent values in this unit.
May be the same array as input.
output.
ConversionException - Can't convert between units.
public double[] fromDerivedUnit(double[] input,
double[] output)
throws ConversionException
fromDerivedUnit in interface DerivableUnitinput - The values in the convertible derived unit.output - The equivalent values in this unit.
May be the same array as input.
output.
ConversionException - Can't convert between units.public boolean equals(java.lang.Object object)
equals in interface Unitequals in class UnitImplobject - The object.
true if and only if this unit
is semantically identical to object
.public boolean isDimensionless()
isDimensionless in interface Unittrue if and only if this unit
is dimensionless.public java.lang.String toString()
toString in interface UnittoString in class UnitImplpublic java.lang.String getCanonicalString()
getCanonicalString in interface Unit
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||