|
||||||||||
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 Unit
id
- The new identifier.
public Unit multiplyBy(double scale) throws MultiplyException
Unit
m
is a
meter unit, then m.multiplyBy(1e-2)
returns a centimeter unit.
multiplyBy
in interface Unit
multiplyBy
in class UnitImpl
scale
- The scale factor.
MultiplyException
- if scale
is zero.protected Unit myMultiplyBy(Unit that) throws MultiplyException
myMultiplyBy
in class UnitImpl
that
- The other unit.
MultiplyException
- Can't multiply these units together.protected Unit myDivideBy(Unit that) throws OperationException
myDivideBy
in class UnitImpl
that
- The other unit.
OperationException
- Can't divide these units.protected Unit myDivideInto(Unit that) throws OperationException
myDivideInto
in class UnitImpl
that
- The other unit.
OperationException
- Can't divide these units.protected Unit myRaiseTo(int power) throws RaiseException
myRaiseTo
in class UnitImpl
power
- The power.
RaiseException
- Can't raise this unit to a power.public DerivedUnit getDerivedUnit()
getDerivedUnit
in interface DerivableUnit
getDerivedUnit
in interface Unit
public float toDerivedUnit(float amount) throws ConversionException
toDerivedUnit
in interface DerivableUnit
amount
- 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 DerivableUnit
amount
- 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 DerivableUnit
input
- 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 DerivableUnit
input
- 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 DerivableUnit
amount
- The numeric value in the underlying derived unit.
ConversionException
- Can't convert value.public double fromDerivedUnit(double amount) throws ConversionException
fromDerivedUnit
in interface DerivableUnit
amount
- 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 DerivableUnit
input
- 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 DerivableUnit
input
- 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 Unit
equals
in class Object
object
- The object.
true
if an only if this unit is semantically
identical to object
.public int hashCode()
hashCode
in class UnitImpl
public boolean isDimensionless()
isDimensionless
in interface Unit
true
if and only if this unit is dimensionless.public String toString()
toString
in interface Unit
toString
in class UnitImpl
public 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 |