JSR-275 - Measurements and Units Specification

javax.measure.converter
Class LogConverter

java.lang.Object
  extended by javax.measure.converter.UnitConverter
      extended by javax.measure.converter.LogConverter
All Implemented Interfaces:
java.io.Serializable

public final class LogConverter
extends UnitConverter

This class represents a logarithmic converter. Such converter is typically used to create logarithmic unit. For example:

     Unit<Dimensionless> BEL = Unit.ONE.transform(new LogConverter(10).inverse());
     

Instances of this class are immutable.

Version:
3.1, April 22, 2006
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.measure.converter.UnitConverter
IDENTITY
 
Constructor Summary
LogConverter(double base)
          Creates a logarithmic converter having the specified base.
 
Method Summary
 double convert(double amount)
          Converts a double value.
 boolean equals(java.lang.Object obj)
          Indicates whether this converter is considered the same as the converter specified (they must be of same types).
 double getBase()
          Returns the logarithmic base of this 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 javax.measure.converter.UnitConverter
concatenate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogConverter

public LogConverter(double base)
Creates a logarithmic converter having the specified base.

Parameters:
base - the logarithmic base (e.g. Math.E for the Natural Logarithm).
Method Detail

getBase

public double getBase()
Returns the logarithmic base of this converter.

Returns:
the logarithmic base (e.g. Math.E for the Natural Logarithm).

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.

equals

public boolean equals(java.lang.Object obj)
Description copied from class: UnitConverter
Indicates whether this converter is considered the same as the converter specified (they must be of same types).

Specified by:
equals in class UnitConverter
Parameters:
obj - the converter with which to compare.
Returns:
true if the specified object is a converter considered equals to this converter;false otherwise.

hashCode

public int hashCode()
Description copied from class: UnitConverter
Returns a hash code value for this converter. Equals object have equal hash codes.

Specified by:
hashCode in class UnitConverter
Returns:
this converter hash code value.
See Also:
UnitConverter.equals(java.lang.Object)

JSR-275 - Measurements and Units Specification

Copyright © 2007 JSR-275