public interface Unit
| Modifier and Type | Method and Description |
|---|---|
Unit |
clone(UnitName id)
Clones this unit, changing the identifier.
|
double[] |
convertTo(double[] amounts,
Unit outputUnit)
Converts numerical values from this unit to another unit.
|
double[] |
convertTo(double[] input,
Unit outputUnit,
double[] output)
Converts numerical values from this unit to another unit.
|
double |
convertTo(double amount,
Unit outputUnit)
Converts a numerical value from this unit to another unit.
|
float[] |
convertTo(float[] amounts,
Unit outputUnit)
Converts numerical values from this unit to another unit.
|
float[] |
convertTo(float[] input,
Unit outputUnit,
float[] output)
Converts numerical values from this unit to another unit.
|
float |
convertTo(float amount,
Unit outputUnit)
Converts a numerical value from this unit to another unit.
|
Unit |
divideBy(Unit that)
Divides this unit by another.
|
Unit |
divideInto(Unit that)
Divides this unit into another.
|
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)
Gets a Converter that converts numeric values from this unit to another,
compatible unit.
|
DerivedUnit |
getDerivedUnit()
Returns the derived unit that underlies this unit.
|
java.lang.String |
getName()
Gets the name of this unit.
|
java.lang.String |
getPlural()
Gets the plural form of the name of this unit.
|
java.lang.String |
getSymbol()
Gets the symbol of this unit.
|
UnitName |
getUnitName()
Gets the identifier of this unit.
|
boolean |
isCompatible(Unit that)
Indicates if this unit is compatible with another unit.
|
boolean |
isDimensionless()
Indicates if values in this unit are dimensionless.
|
Unit |
log(double base)
Returns a logarithmic unit whose reference level is equal to this unit.
|
java.lang.String |
makeLabel(java.lang.String quantityID)
Makes a label for a named quantity.
|
Unit |
multiplyBy(double scale)
Multiplies this unit by a scale factor.
|
Unit |
multiplyBy(Unit that)
Multiplies this unit by another.
|
Unit |
raiseTo(int power)
Raises this unit to a power.
|
Unit |
shiftTo(java.util.Date origin)
Returns a unit identical to this instance but whose origin (i.e., zero
value) has been shifted to the given time.
|
Unit |
shiftTo(double origin)
Returns a unit identical to this instance but whose origin (i.e., zero
value) has been shifted to the given value.
|
java.lang.String |
toString()
Returns the string representation of the unit.
|
UnitName getUnitName()
java.lang.String getName()
java.lang.String getPlural()
java.lang.String getSymbol()
java.lang.String toString()
toString in class java.lang.Objectjava.lang.String getCanonicalString()
DerivedUnit getDerivedUnit()
Unit clone(UnitName id)
id - The identifier for the new unit.Unit multiplyBy(Unit that) throws MultiplyException
that - The other unit.MultiplyException - Can't multiply these units.Unit multiplyBy(double scale) throws MultiplyException
m is a
meter unit, then m.multiplyBy(1e-2) returns a centimeter unit.scale - The scale factor.MultiplyException - if scale is zero.Unit divideBy(Unit that) throws OperationException
that - The other unit.OperationException - Can't divide these units.Unit divideInto(Unit that) throws OperationException
that - The other unit.OperationException - Can't divide these units.Unit raiseTo(int power) throws RaiseException
power - The power.RaiseException - Can't raise this unit to a power.Unit shiftTo(double origin) throws ShiftException
degK
is a Kelvin unit, then degK.shiftTo(273.15) is a Celsius unit.origin - The new origin in units of this instance.origin of this instance.ShiftException - if the corresponding new unit can't be created.Unit shiftTo(java.util.Date origin) throws ShiftException
sec is
a second unit, then sec.shiftTo(new Date(0L) is the unit
corresponding to seconds since the epoch (1970-01-01 00:00:00 UTC).origin - The new origin.origin.ShiftException - if the corresponding new unit can't be created. For example,
if this instance isn't a unit of time.Unit log(double base)
mW is a milliwatt unit, then mW.log(10.)
returns a base-ten logarithmic unit with a milliwatt reference level.base - The logarithmic base. Must be one of 2, Math.E
, or 10.java.lang.IllegalArgumentException - if base isn't one of the allowed values.Converter getConverterTo(Unit outputUnit) throws ConversionException
outputUnit - The unit to which to convert the numerical values.ConversionException - The units aren't compatible.float convertTo(float amount,
Unit outputUnit)
throws ConversionException
amount - The numerical value in this unit.outputUnit - The unit to which to convert the numerical value.ConversionException - The units aren't compatible.double convertTo(double amount,
Unit outputUnit)
throws ConversionException
amount - The numerical value in this unit.outputUnit - The unit to which to convert the numerical value.ConversionException - The units aren't compatible.float[] convertTo(float[] amounts,
Unit outputUnit)
throws ConversionException
amounts - The numerical values in this unit.outputUnit - The unit to which to convert the numerical values.ConversionException - The units aren't compatible.double[] convertTo(double[] amounts,
Unit outputUnit)
throws ConversionException
amounts - The numerical values in this unit.outputUnit - The unit to which to convert the numerical values.ConversionException - The units aren't compatible.float[] convertTo(float[] input,
Unit outputUnit,
float[] output)
throws ConversionException
input - The numerical values in this unit.outputUnit - The unit to which to convert the numerical values.output - The output numerical values. May be the same array as the
input values.output.ConversionException - The units aren't compatible.double[] convertTo(double[] input,
Unit outputUnit,
double[] output)
throws ConversionException
input - The numerical values in this unit.outputUnit - The unit to which to convert the numerical values.output - The output numerical values. May be the same array as the
input values.output.ConversionException - The units aren't compatible.boolean isCompatible(Unit that)
that - The other unit.boolean equals(java.lang.Object object)
equals in class java.lang.Objectobject - The object.true if and only if this unit is semantically
identical to the object.java.lang.String makeLabel(java.lang.String quantityID)
quantityID - An identifier of the quantity for which the label is intended
(e.g. "altitude").boolean isDimensionless()
true if and only if this unit is dimensionless.