Java Units API
Build 2004-02-06

javax.units
Class AddConverter

Object
  extended byConverter
      extended byAddConverter
All Implemented Interfaces:
Serializable

public final class AddConverter
extends Converter

This class represents an add converter. An add converter adds a constant offset to numeric values.

Instances of this class are immutable.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class Converter
IDENTITY
 
Constructor Summary
AddConverter(double offset)
          Creates an add converter with the specified offset.
 
Method Summary
 Converter concatenate(Converter converter)
          Concatenates this converter with another converter.
 double convert(double x)
          Converts a double value.
 double derivative(double x)
          Returns this converter derivative for the specified x value.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this converter.
 double getOffset()
          Returns the offset value for this add converter.
 int hashCode()
          Returns a hash code value for this converter.
 Converter inverse()
          Returns the inverse of this converter.
 boolean isLinear()
          Indicates if this converter is linear.
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AddConverter

public AddConverter(double offset)
Creates an add converter with the specified offset.

Parameters:
offset - the offset value.
Method Detail

getOffset

public double getOffset()
Returns the offset value for this add converter.

Returns:
the offset value.

inverse

public Converter inverse()
Description copied from class: Converter
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 Converter
Returns:
the inverse of this converter.

convert

public double convert(double x)
Description copied from class: Converter
Converts a double value.

Specified by:
convert in class Converter
Parameters:
x - the numeric value to convert.
Returns:
the converted numeric value.

derivative

public double derivative(double x)
Description copied from class: Converter
Returns this converter derivative for the specified x value. For linear converters, this method returns a constant (the linear factor) for all x values.

Specified by:
derivative in class Converter
Parameters:
x - the value for which the derivative is calculated.
Returns:
the derivative for the specified value.

isLinear

public boolean isLinear()
Description copied from class: Converter
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).

Specified by:
isLinear in class Converter
Returns:
true if this converter is linear; false otherwise.

concatenate

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

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

equals

public boolean equals(Object obj)
Description copied from class: Converter
Indicates whether some other object is "equal to" this converter.

Overrides:
equals in class Converter
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is a linear converter and this object is also a linear converter and both have same derivatives; false otherwise.

hashCode

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

Overrides:
hashCode in class Converter
Returns:
this converter hash code value.
See Also:
Converter.equals(java.lang.Object)

Java Units API
Build 2004-02-06

Symbols, terms and definitions
JSR-108 project