|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectucar.units.UnitImpl
public abstract class UnitImpl
Provides support for classes that implement units.
| Nested Class Summary | |
|---|---|
protected static class |
UnitImpl.MyConverter
Provides support for converting numeric values from this unit to another unit. |
| Constructor Summary | |
|---|---|
protected |
UnitImpl()
Constructs with no ID. |
protected |
UnitImpl(UnitName id)
Constructs with the given ID. |
| Method Summary | |
|---|---|
double[] |
convertTo(double[] amounts,
Unit outputUnit)
Converts numeric values from this unit to another unit. |
double[] |
convertTo(double[] input,
Unit outputUnit,
double[] output)
Converts numeric values from this unit to another unit. |
double |
convertTo(double amount,
Unit outputUnit)
Converts a numeric value from this unit to another unit. |
float[] |
convertTo(float[] amounts,
Unit outputUnit)
Converts numeric values from this unit to another unit. |
float[] |
convertTo(float[] input,
Unit outputUnit,
float[] output)
Converts numeric values from this unit to another unit. |
float |
convertTo(float amount,
Unit outputUnit)
Converts a numeric 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. |
Converter |
getConverterTo(Unit outputUnit)
Gets a Converter for converting numeric values from this unit to another, compatible unit. |
String |
getName()
Gets the name of the unit. |
String |
getPlural()
Gets the plural form of the name of the unit. |
String |
getSymbol()
Gets the symbol for the unit. |
UnitName |
getUnitName()
Gets the identifier of this unit. |
abstract int |
hashCode()
Returns the hash code of this instance. |
boolean |
isCompatible(Unit that)
Indicates if numeric values in this unit are convertible with another unit. |
Unit |
log(double base)
Returns a logarithmic unit whose reference level is equal to this unit. |
String |
makeLabel(String quantityID)
Returns a label for a quantity in this unit. |
Unit |
multiplyBy(double scale)
Multiplies this unit by a scale factor. |
Unit |
multiplyBy(Unit that)
Multiplies this unit by another. |
protected abstract Unit |
myDivideBy(Unit unit)
Divides this unit by another. |
protected abstract Unit |
myDivideInto(Unit unit)
Divides this unit into another. |
protected abstract Unit |
myMultiplyBy(Unit that)
Multiplies this unit by another. |
protected abstract Unit |
myRaiseTo(int power)
Raises this unit to a power. |
Unit |
raiseTo(int power)
Raises this unit to a power. |
Unit |
shiftTo(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. |
String |
toString()
Returns the string representation of this unit. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface ucar.units.Unit |
|---|
clone, equals, getCanonicalString, getDerivedUnit, isDimensionless |
| Constructor Detail |
|---|
protected UnitImpl()
protected UnitImpl(UnitName id)
id - The id of the unit (e.g. "foot"). May be null.| Method Detail |
|---|
public final UnitName getUnitName()
getUnitName in interface Unitnull.public final String getName()
getName in interface Unitnull.public final String getPlural()
getPlural in interface Unitnull.public final String getSymbol()
getSymbol in interface Unitnull.
public Unit shiftTo(double origin)
throws ShiftException
UnitdegK
is a Kelvin unit, then degK.shiftTo(273.15) is a Celsius unit.
shiftTo in interface Unitorigin - The new origin in units of this instance.
origin of this instance.
ShiftException - if the corresponding new unit can't be created.
public Unit shiftTo(Date origin)
throws ShiftException
Unitsec 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).
shiftTo in interface Unitorigin - 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.
public final Unit multiplyBy(Unit that)
throws MultiplyException
multiplyBy in interface Unitthat - The other unit.
MultiplyException - Can't multiply these units.
public Unit multiplyBy(double scale)
throws MultiplyException
Unitm is a
meter unit, then m.multiplyBy(1e-2) returns a centimeter unit.
multiplyBy in interface Unitscale - The scale factor.
MultiplyException - if scale is zero.
protected abstract Unit myMultiplyBy(Unit that)
throws MultiplyException
that - The other unit.
MultiplyException - Can't multiply these units.
public final Unit divideBy(Unit that)
throws OperationException
divideBy in interface Unitthat - The other unit.
OperationException - Can't divide these units.
protected abstract Unit myDivideBy(Unit unit)
throws OperationException
unit - The other unit.
OperationException - Can't divide these units.
public final Unit divideInto(Unit that)
throws OperationException
divideInto in interface Unitthat - The other unit.
OperationException - Can't divide these units.
protected abstract Unit myDivideInto(Unit unit)
throws OperationException
unit - The other unit.
OperationException - Can't divide these units.
public final Unit raiseTo(int power)
throws RaiseException
raiseTo in interface Unitpower - The power.
RaiseException - Can't raise this unit to a power.
protected abstract Unit myRaiseTo(int power)
throws RaiseException
power - The power.
RaiseException - Can't raise this unit to a power.public Unit log(double base)
UnitmW is a milliwatt unit, then mW.log(10.)
returns a base-ten logarithmic unit with a milliwatt reference level.
log in interface Unitbase - The logarithmic base. Must be one of 2, Math.E
, or 10.
public Converter getConverterTo(Unit outputUnit)
throws ConversionException
getConverterTo in interface UnitoutputUnit - The unit to which to convert the numeric values.
ConversionException - The units aren't convertible.
public float convertTo(float amount,
Unit outputUnit)
throws ConversionException
convertTo in interface Unitamount - The numeric value.outputUnit - The unit to which to convert the numeric value.
ConversionException - The units aren't convertible.
public double convertTo(double amount,
Unit outputUnit)
throws ConversionException
convertTo in interface Unitamount - The numeric value.outputUnit - The unit to which to convert the numeric value.
ConversionException - The units aren't convertible.
public float[] convertTo(float[] amounts,
Unit outputUnit)
throws ConversionException
convertTo in interface Unitamounts - The numeric values.outputUnit - The unit to which to convert the numeric values.
ConversionException - The units aren't convertible.
public double[] convertTo(double[] amounts,
Unit outputUnit)
throws ConversionException
convertTo in interface Unitamounts - The numeric values.outputUnit - The unit to which to convert the numeric values.
ConversionException - The units aren't convertible.
public float[] convertTo(float[] input,
Unit outputUnit,
float[] output)
throws ConversionException
convertTo in interface Unitinput - The input numeric values.outputUnit - The unit to which to convert the numeric values.output - The output numeric values. May be the same array as the input
values.
ConversionException - The units aren't convertible.
public double[] convertTo(double[] input,
Unit outputUnit,
double[] output)
throws ConversionException
convertTo in interface Unitinput - The input numeric values.outputUnit - The unit to which to convert the numeric values.output - The output numeric values. May be the same array as the input
values.
ConversionException - The units aren't convertible.public boolean isCompatible(Unit that)
isCompatible in interface Unitthat - The other unit.
true if and only if numeric values in this unit are
convertible the other unit.public abstract int hashCode()
hashCode in class Objectpublic String toString()
toString in interface UnittoString in class Objectpublic String makeLabel(String quantityID)
makeLabel in interface UnitquantityID - The identifier for the quantity (e.g. "altitude").
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||