|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface UnitConverter
A converter of numeric values.
Instances of this class are obtained through the Unit.getConverterTo(Unit) method.
| Method Summary | |
|---|---|
UnitConverter |
concatenate(UnitConverter converter)
Concatenates this converter with another converter. |
BigDecimal |
convert(BigDecimal value,
MathContext ctx)
Converts a BigDecimal number according to the specified math context. |
double |
convert(double value)
Converts a double value. |
Number |
convert(Number value)
Converts a Number value. |
List<? extends UnitConverter> |
getCompoundConverters()
Returns the chain of fundamental converters making up this converter or null if this converter is a fundamental converter. |
UnitConverter |
inverse()
Returns the inverse of this converter. |
boolean |
isIdentity()
Indicates if this converter is the identity converter. |
boolean |
isLinear()
Indicates if this converter is linear. |
| Method Detail |
|---|
boolean isIdentity()
convert(x) == x).
true if this converter is an identity converter.boolean isLinear()
convert(u + v) == convert(u) + convert(v)convert(r * u) == r * convert(u)For linear converters the following property always hold:
y1 = c1.convert(x1);
y2 = c2.convert(x2);
assert y1*y2 == c1.concatenate(c2).convert(x1*x2);
true if this converter is linear; false otherwise.UnitConverter inverse()
x is a valid value,
then x == inverse().convert(convert(x)) to within the accuracy
of computer arithmetic.
double convert(double value)
double value.
value - the numeric value to convert.
double value after conversion.Number convert(Number value)
Number value.
value - the numeric value to convert.
Number value after conversion.
BigDecimal convert(BigDecimal value,
MathContext ctx)
throws ArithmeticException
BigDecimal number according to the specified math context.
value - the decimal number to convert.ctx - the math context being used for conversion.
ArithmeticException - if the result is inexact but the context is MathContext.UNLIMITED,
or the precision is 0 and the quotient has a
non-terminating decimal expansion.UnitConverter concatenate(UnitConverter converter)
converter - the other converter to concatenate with this converter.
List<? extends UnitConverter> getCompoundConverters()
null if this converter is a fundamental converter. For example,
cvtr1.concatenate(cvtr2).getCompoundConverters() returns {cvtr1, cvtr2}.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||