| 
JSR-275 - Measurements and Units Specification | ||||||||
| 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.RationalConverter
public final class RationalConverter
 This class represents a converter multiplying numeric values by an
     exact scaling factor (represented as the quotient of two 
     long numbers).
Instances of this class are immutable.
| Field Summary | 
|---|
| Fields inherited from class javax.measure.converter.UnitConverter | 
|---|
IDENTITY | 
| Constructor Summary | |
|---|---|
RationalConverter(long dividend,
                  long divisor)
Creates a rational converter with the specified dividend and divisor.  | 
|
| Method Summary | |
|---|---|
 UnitConverter | 
concatenate(UnitConverter converter)
Concatenates this converter with another converter.  | 
 double | 
convert(double amount)
Converts a double value.  | 
 boolean | 
equals(java.lang.Object cvtr)
Indicates whether this converter is considered the same as the converter specified (they must be of same types).  | 
 long | 
getDividend()
Returns the dividend for this rational converter.  | 
 long | 
getDivisor()
Returns the positive divisor for this rational converter.  | 
 int | 
hashCode()
Returns a hash code value for this converter.  | 
 UnitConverter | 
inverse()
Returns the inverse of this converter.  | 
 boolean | 
isLinear()
Indicates if this converter is linear.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public RationalConverter(long dividend,
                         long divisor)
dividend - the dividend.divisor - the positive divisor.
java.lang.IllegalArgumentException - if divisor < 0
java.lang.IllegalArgumentException - if dividend == divisor| Method Detail | 
|---|
public long getDividend()
public long getDivisor()
public UnitConverter inverse()
UnitConverterx is a valid
 value, then x == inverse().convert(convert(x)) to within
 the accuracy of computer arithmetic.
inverse in class UnitConverterpublic double convert(double amount)
UnitConverter
convert in class UnitConverteramount - the numeric value to convert.
public boolean isLinear()
UnitConverterconvert(u + v) == convert(u) + convert(v) and
 convert(r * u) == r * convert(u).
 For linear converters the following property always hold:
     y1 = c1.convert(x1);
     y2 = c2.convert(x2); 
 then y1*y2 = c1.concatenate(c2).convert(x1*x2)
isLinear in class UnitConvertertrue if this converter is linear;
         false otherwise.public boolean equals(java.lang.Object cvtr)
UnitConverter
equals in class UnitConvertercvtr - 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)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 UnitConverterconverter - the other converter.
  | 
JSR-275 - Measurements and Units Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||