Jeospace API

org.jeospace.measure
Class Length

java.lang.Object
  extended byorg.jeospace.measure.Length
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class Length
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable

An object that represents a linear unit of measure.

For reference see: http://ts.nist.gov/ts/htdocs/230/235/h4402/appenc.pdf

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton
See Also:
Mult, LengthUnit

Field Summary
protected  double magnitude
          The magnitude
protected  Mult multiplier
          The multiplier
protected  LengthUnit units
          The units
 
Constructor Summary
Length()
          Construct a Length object initialized to the default value (1 meter).
Length(double magnitude)
          Construct a Length object initialized to the specified number of meters.
Length(double magnitude, LengthUnit units)
          Construct a Length object.
Length(double magnitude, Mult multiplier, LengthUnit units)
          Construct a Length object.
Length(Length length)
          Construct a Length object.
 
Method Summary
 void add(Length inLength)
          Add to this object the argument Length object.
 void changeSign()
          Change the sign of the magnitude of this Length object.
 void clear()
          Set the value of this Length object to 0 meters.
 java.lang.Object clone()
          Return a copy of this Length object.
 int compareTo(Length that)
          Compare this object with the argument for order.
 int compareTo(java.lang.Object obj)
          Compare this object with the argument for order.
 boolean equals(java.lang.Object obj)
          Compare two Lengths for equality.
 double getMagnitude()
          Return the double value of the magnitude of this Length object.
 double getMagnitude(LengthUnit units)
          Return the double value of the magnitude of this Length object in the specified units.
 double getMagnitude(Mult inMultiplier, LengthUnit inUnits)
          Return the double value of the magnitude of this Length object in the specified multiplier and units.
 Mult getMultiplier()
          Return the Mult component of this Length object.
 double getScaledMagnitude(Length scale)
          Return the double value of the magnitude of this Length object scaled by the input Length object.
 LengthUnit getUnits()
          Return the units identifier of this Length object.
 int hashcode()
          Return the hash code
 void set(double magnitude, LengthUnit units)
          Set this Length object to the specified value.
 void set(double magnitude, Mult inMultiplier, LengthUnit inUnits)
          Set this Length object to the specified value.
 void set(Length length)
          Set this Length object to the specified value.
 void setMagnitude(double value)
          Set the value of the magnitude of this Length object.
 void subtract(Length inLength)
          Subtract from this object the argument Length object.
 java.lang.String toString()
          Return a String representation of this Length object.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

magnitude

protected double magnitude
The magnitude


multiplier

protected Mult multiplier
The multiplier


units

protected LengthUnit units
The units

Constructor Detail

Length

public Length()
Construct a Length object initialized to the default value (1 meter).


Length

public Length(double magnitude)
Construct a Length object initialized to the specified number of meters.

Parameters:
magnitude - The magnitude value.

Length

public Length(double magnitude,
              LengthUnit units)
Construct a Length object.

Parameters:
magnitude - The magnitude value.
units - The units identifier.

Length

public Length(double magnitude,
              Mult multiplier,
              LengthUnit units)
Construct a Length object.

Parameters:
magnitude - The magnitude value.
multiplier - The multiplier identifier.
units - The units identifier.

Length

public Length(Length length)
Construct a Length object.

Parameters:
length - The Length object to duplicate.
Method Detail

set

public void set(Length length)
Set this Length object to the specified value.

Parameters:
length - The Length object to duplicate

set

public void set(double magnitude,
                LengthUnit units)
Set this Length object to the specified value.

Parameters:
magnitude - The magnitude value.
units - The units identifier.

set

public void set(double magnitude,
                Mult inMultiplier,
                LengthUnit inUnits)
Set this Length object to the specified value.

Parameters:
magnitude - The magnitude value.
inMultiplier - The multiplier identifier.
inUnits - The units identifier.

changeSign

public void changeSign()
Change the sign of the magnitude of this Length object.


add

public void add(Length inLength)
Add to this object the argument Length object.

Parameters:
inLength - A Length object.

subtract

public void subtract(Length inLength)
Subtract from this object the argument Length object.

Parameters:
inLength - A Length object.

setMagnitude

public void setMagnitude(double value)
Set the value of the magnitude of this Length object.

Parameters:
value - The double value of the magnitude.

getMagnitude

public double getMagnitude()
Return the double value of the magnitude of this Length object.

Returns:
the double value of the magnitude

getMagnitude

public double getMagnitude(LengthUnit units)
Return the double value of the magnitude of this Length object in the specified units.

Parameters:
units - The units identifier.
Returns:
the double value of the magnitude

getMagnitude

public double getMagnitude(Mult inMultiplier,
                           LengthUnit inUnits)
Return the double value of the magnitude of this Length object in the specified multiplier and units.

Parameters:
inMultiplier - The multiplier identifier.
inUnits - The units identifier.
Returns:
the double value of the magnitude

getScaledMagnitude

public double getScaledMagnitude(Length scale)
Return the double value of the magnitude of this Length object scaled by the input Length object. The returned value is converted to the multiplier and units of the passed scalor and divided by the scalor's magnitude.

Parameters:
scale - The Length object to be used as a scalor.
Returns:
the scaled double value of the magnitude

getMultiplier

public Mult getMultiplier()
Return the Mult component of this Length object.

Returns:
The Mult component of this Length object.

getUnits

public LengthUnit getUnits()
Return the units identifier of this Length object.

Returns:
The units identifier of this Length object.

clear

public void clear()
Set the value of this Length object to 0 meters.


clone

public java.lang.Object clone()
Return a copy of this Length object. Overrides Cloneable.

Returns:
a copy of this Length object.

hashcode

public int hashcode()
Return the hash code

Returns:
the hash code

equals

public boolean equals(java.lang.Object obj)
Compare two Lengths for equality. The result is true if and only if the argument object is not null, is a Length object and represents a length of the same magnitude as this Length.

Two Length objects are equal only if the getMagnitude method returns the same value for both with identical multiplier and unit identifiers.

Parameters:
obj - The object to compare with
Returns:
true if the Lengths are equivalent; false otherwise.

toString

public java.lang.String toString()
Return a String representation of this Length object.

Returns:
a String representation of this Length object

compareTo

public int compareTo(Length that)
Compare this object with the argument for order.

Parameters:
that - The Length to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareTo

public int compareTo(java.lang.Object obj)
Compare this object with the argument for order.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - The Object to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the argument is not a Length.

Jeospace API

Copyright © 2006 - jeospace.org