|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.measure.converter.UnitConverter
javax.measure.converter.LinearConverter
javax.measure.converter.RationalConverter
public final class RationalConverter
This class represents a converter multiplying numeric values by an
exact scaling factor (represented as the quotient of two
BigInteger numbers).
Instances of this class are immutable.
| Field Summary |
|---|
| Fields inherited from class javax.measure.converter.UnitConverter |
|---|
IDENTITY |
| Constructor Summary | |
|---|---|
RationalConverter(java.math.BigInteger dividend,
java.math.BigInteger divisor)
Creates a rational converter with the specified dividend and divisor. |
|
| Method Summary | |
|---|---|
UnitConverter |
concatenate(UnitConverter converter)
Concatenates this converter with another converter. |
java.math.BigDecimal |
convert(java.math.BigDecimal value,
java.math.MathContext ctx)
Converts a BigDecimal value. |
double |
convert(double value)
Converts a double value. |
boolean |
equals(java.lang.Object obj)
Indicates whether this converter is considered to be the the same as the one specified. |
java.math.BigInteger |
getDividend()
Returns the integer dividend for this rational converter. |
java.math.BigInteger |
getDivisor()
Returns the integer (positive) divisor for this rational converter. |
int |
hashCode()
Returns a hash code value for this converter. |
RationalConverter |
inverse()
Returns the inverse of this converter. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public RationalConverter(java.math.BigInteger dividend,
java.math.BigInteger divisor)
dividend - the dividend.divisor - the positive divisor.
java.lang.IllegalArgumentException - if divisor <= 0
java.lang.IllegalArgumentException - if dividend == divisor| Method Detail |
|---|
public java.math.BigInteger getDividend()
public java.math.BigInteger getDivisor()
public double convert(double value)
UnitConverterdouble value.
convert in class UnitConvertervalue - the numeric value to convert.
double value after conversion.
public java.math.BigDecimal convert(java.math.BigDecimal value,
java.math.MathContext ctx)
throws java.lang.ArithmeticException
UnitConverterBigDecimal value.
convert in class UnitConvertervalue - the numeric value to convert.ctx - the math context being used for conversion.
java.lang.ArithmeticException - if the result is inexact but the
rounding mode is MathContext.UNNECESSARY or
mathContext.precision == 0 and the quotient has a
non-terminating decimal expansion.public UnitConverter concatenate(UnitConverter converter)
UnitConverterNote: Implementations must ensure that the UnitConverter.IDENTITY instance
is returned if the resulting converter is an identity
converter.
concatenate in class LinearConverterconverter - the other converter.
public RationalConverter inverse()
UnitConverterx is a valid
value, then x == inverse().convert(convert(x)) to within
the accuracy of computer arithmetic.
inverse in class LinearConverterpublic final java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
UnitConverter
equals in class UnitConverterobj - the converter with which to compare.
true if the specified object is a converter
considered equals to this converter;false otherwise.public int hashCode()
UnitConverter
hashCode in class UnitConverterUnitConverter.equals(java.lang.Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||