|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectucar.units.UnitImpl
ucar.units.ScaledUnit
public final class ScaledUnit
Provides support for a unit that is a mutiplicative factor of a reference unit. Instances of this class are immutable.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class ucar.units.UnitImpl |
|---|
UnitImpl.MyConverter |
| Constructor Summary | |
|---|---|
ScaledUnit(double scale)
Constructs from a multiplicative factor. |
|
ScaledUnit(double scale,
Unit unit)
Constructs from a multiplicative factor and a reference unit. |
|
ScaledUnit(double scale,
Unit unit,
UnitName id)
Constructs from a multiplicative factor, a reference unit, and an identifier. |
|
| Method Summary | |
|---|---|
Unit |
clone(UnitName id)
Clones this unit, changing the identifier. |
boolean |
equals(Object object)
Indicates if this unit is semantically identical to an object. |
double |
fromDerivedUnit(double amount)
Converts a numeric value from the underlying derived unit to this unit. |
double[] |
fromDerivedUnit(double[] input,
double[] output)
Converts numeric values from the underlying derived unit to this unit. |
float |
fromDerivedUnit(float amount)
Converts a numeric value from the underlying derived unit to this unit. |
float[] |
fromDerivedUnit(float[] input,
float[] output)
Converts numeric values from the underlying derived unit to this unit. |
String |
getCanonicalString()
Returns the canonical string representation of the unit. |
DerivedUnit |
getDerivedUnit()
Gets the derived unit underlying this unit. |
double |
getScale()
Returns the multiplicative factor. |
Unit |
getUnit()
Returns the reference unit. |
int |
hashCode()
Returns the hash code of this instance. |
boolean |
isDimensionless()
Indicates if this unit is dimensionless. |
static void |
main(String[] args)
Tests this class. |
Unit |
multiplyBy(double scale)
Multiplies this unit by a scale factor. |
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. |
double |
toDerivedUnit(double amount)
Converts a numeric value from this unit to the underlying derived unit. |
double[] |
toDerivedUnit(double[] input,
double[] output)
Converts numeric values from this unit to the underlying derived unit. |
float |
toDerivedUnit(float amount)
Converts a numeric value from this unit to the underlying derived unit. |
float[] |
toDerivedUnit(float[] input,
float[] output)
Converts numeric values from this unit to the underlying derived unit. |
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, log, makeLabel, multiplyBy, raiseTo, shiftTo, shiftTo |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ScaledUnit(double scale)
scale - The multiplicative factor.
public ScaledUnit(double scale,
Unit unit)
scale - The multiplicative factor.unit - The reference unit.
public ScaledUnit(double scale,
Unit unit,
UnitName id)
scale - The multiplicative factor.unit - The reference unit.id - The identifier for the unit.| Method Detail |
|---|
public double getScale()
public Unit getUnit()
public Unit clone(UnitName id)
clone in interface Unitid - The new identifier.
public Unit multiplyBy(double scale)
throws MultiplyException
Unitm is a
meter unit, then m.multiplyBy(1e-2) returns a centimeter unit.
multiplyBy in interface UnitmultiplyBy in class UnitImplscale - The scale factor.
MultiplyException - if scale is zero.
protected Unit myMultiplyBy(Unit that)
throws MultiplyException
myMultiplyBy in class UnitImplthat - The other unit.
MultiplyException - Can't multiply these units together.
protected Unit myDivideBy(Unit that)
throws OperationException
myDivideBy in class UnitImplthat - The other unit.
OperationException - Can't divide these units.
protected Unit myDivideInto(Unit that)
throws OperationException
myDivideInto in class UnitImplthat - The other unit.
OperationException - Can't divide these units.
protected Unit myRaiseTo(int power)
throws RaiseException
myRaiseTo in class UnitImplpower - The power.
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 numeric value in this unit.
ConversionException - Can't convert value to the underlying derived unit.
public double toDerivedUnit(double amount)
throws ConversionException
toDerivedUnit in interface DerivableUnitamount - The numeric value in this unit.
ConversionException - Can't convert value to the underlying derived unit.
public float[] toDerivedUnit(float[] input,
float[] output)
throws ConversionException
toDerivedUnit in interface DerivableUnitinput - The numeric values in this unit.output - The equivalent values in the underlying derived unit.
output.
ConversionException - Can't convert values to the underlying derived unit.
public double[] toDerivedUnit(double[] input,
double[] output)
throws ConversionException
toDerivedUnit in interface DerivableUnitinput - The numeric values in this unit.output - The equivalent values in the underlying derived unit.
output.
ConversionException - Can't convert values to the underlying derived unit.
public float fromDerivedUnit(float amount)
throws ConversionException
fromDerivedUnit in interface DerivableUnitamount - The numeric value in the underlying derived unit.
ConversionException - Can't convert value.
public double fromDerivedUnit(double amount)
throws ConversionException
fromDerivedUnit in interface DerivableUnitamount - The numeric value in the underlying derived unit.
ConversionException - Can't convert value.
public float[] fromDerivedUnit(float[] input,
float[] output)
throws ConversionException
fromDerivedUnit in interface DerivableUnitinput - The numeric values in the underlying derived unit.output - The equivalent values in this unit.
output.
ConversionException - Can't convert values.
public double[] fromDerivedUnit(double[] input,
double[] output)
throws ConversionException
fromDerivedUnit in interface DerivableUnitinput - The numeric values in the underlying derived unit.output - The equivalent values in this unit.
output.
ConversionException - Can't convert values.public boolean equals(Object object)
equals in interface Unitequals in class Objectobject - The object.
true if an only if this unit is semantically
identical to object
.public int hashCode()
hashCode in class UnitImplpublic boolean isDimensionless()
isDimensionless in interface Unittrue if and only if this unit is dimensionless.public String toString()
toString in interface UnittoString in class UnitImplpublic String getCanonicalString()
getCanonicalString in interface Unit
public static void main(String[] args)
throws Exception
Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||