Documentation of 'javax.measure.converter.RationalConverter' Java class
RationalConverter
javax.measure.converter

Class RationalConverter

  • All Implemented Interfaces:
    java.io.Serializable


    public final class RationalConverter
    extends UnitConverter

    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.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      RationalConverter(long dividend, long divisor)
      Creates a rational converter with the specified dividend and divisor.
    • Constructor Detail

      • RationalConverter

        public RationalConverter(long dividend,
                                 long divisor)
        Creates a rational converter with the specified dividend and divisor.
        Parameters:
        dividend - the dividend.
        divisor - the positive divisor.
        Throws:
        java.lang.IllegalArgumentException - if divisor < 0
        java.lang.IllegalArgumentException - if dividend == divisor
    • Method Detail

      • getDividend

        public long getDividend()
        Returns the dividend for this rational converter.
        Returns:
        this converter dividend.
      • getDivisor

        public long getDivisor()
        Returns the positive divisor for this rational converter.
        Returns:
        this converter divisor.
      • inverse

        public UnitConverter inverse()
        Description copied from class: UnitConverter
        Returns the inverse of this converter. If x is a valid value, then x == inverse().convert(convert(x)) to within the accuracy of computer arithmetic.
        Specified by:
        inverse in class UnitConverter
        Returns:
        the inverse of this converter.
      • convert

        public double convert(double amount)
        Description copied from class: UnitConverter
        Converts a double value.
        Specified by:
        convert in class UnitConverter
        Parameters:
        amount - the numeric value to convert.
        Returns:
        the converted numeric value.
      • isLinear

        public boolean isLinear()
        Description copied from class: UnitConverter
        Indicates if this converter is linear. A converter is linear if convert(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)
        Specified by:
        isLinear in class UnitConverter
        Returns:
        true if this converter is linear; false otherwise.
      • concatenate

        public UnitConverter concatenate(UnitConverter converter)
        Description copied from class: UnitConverter
        Concatenates this converter with another converter. The resulting converter is equivalent to first converting by the specified converter, and then converting by this converter.

        Note: Implementations must ensure that the UnitConverter.IDENTITY instance is returned if the resulting converter is an identity converter.

        Overrides:
        concatenate in class UnitConverter
        Parameters:
        converter - the other converter.
        Returns:
        the concatenation of this converter with the other converter.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.