Jeospace API

org.jeospace.measure
Class Mass

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

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

An object that represents a unit of mass.

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, MassUnit

Field Summary
protected  double magnitude
          The magnitude
protected  Mult multiplier
          The multiplier
protected  MassUnit units
          The units
 
Constructor Summary
Mass()
          Construct a Mass object initialized to the default value (1 kilogram).
Mass(double magnitude, MassUnit units)
          Construct a Mass object.
Mass(double magnitude, Mult multiplier, MassUnit units)
          Construct a Mass object.
Mass(Mass mass)
          Construct a Mass object.
 
Method Summary
 void add(Mass mass)
          Add to this object the argument Mass object.
 void clear()
          Set the value of this Mass object to 0 kilograms.
 java.lang.Object clone()
          Return a copy of this Mass object.
 int compareTo(Mass 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 Masss for equality.
 double getMagnitude()
          Return the value of the magnitude of this Mass object.
 double getMagnitude(MassUnit inUnits)
          Return the double value of the magnitude of this Mass object in the specified units.
 double getMagnitude(Mult inMultiplier, MassUnit inUnits)
          Return the double value of the magnitude of this Mass object in the specified multiplier and units.
 Mult getMultiplier()
          Return the Mult component of this Mass object.
 MassUnit getUnits()
          Return the MassUnit component of this Mass object.
 int hashcode()
          Return the hash code
 void set(double magnitude, MassUnit units)
          Set this Mass object to the specified value.
 void set(double magnitude, Mult inMultiplier, MassUnit inUnits)
          Set this Mass object to the specified value.
 void set(Mass mass)
          Set this Mass object to the specified value.
 void setMagnitude(double value)
          Set the value of the magnitude of this Mass object.
 void subtract(Mass mass)
          Subtract from this object the argument Mass object.
 java.lang.String toString()
          Return a String representation of this Mass 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 MassUnit units
The units

Constructor Detail

Mass

public Mass()
Construct a Mass object initialized to the default value (1 kilogram).


Mass

public Mass(double magnitude,
            MassUnit units)
Construct a Mass object.

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

Mass

public Mass(double magnitude,
            Mult multiplier,
            MassUnit units)
Construct a Mass object.

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

Mass

public Mass(Mass mass)
Construct a Mass object.

Parameters:
mass - the Mass object to duplicate.
Method Detail

set

public void set(Mass mass)
Set this Mass object to the specified value.

Parameters:
mass - the Mass object to duplicate

set

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

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

set

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

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

add

public void add(Mass mass)
Add to this object the argument Mass object.

Parameters:
mass - a Mass object.

subtract

public void subtract(Mass mass)
Subtract from this object the argument Mass object.

Parameters:
mass - a Mass object.

setMagnitude

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


getMagnitude

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

Returns:
the double value of the magnitude

getMagnitude

public double getMagnitude(MassUnit inUnits)
Return the double value of the magnitude of this Mass object in the specified units.

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

getMagnitude

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

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

getMultiplier

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

Returns:
the Mult component of this Mass object.

getUnits

public MassUnit getUnits()
Return the MassUnit component of this Mass object.

Returns:
the MassUnit component of this Mass object.

clear

public void clear()
Set the value of this Mass object to 0 kilograms.


clone

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

Returns:
a copy of this Mass object.

hashcode

public int hashcode()
Return the hash code

Returns:
the hash code

equals

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

Two Mass 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 Masss are equivalent; false otherwise.

toString

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

Returns:
a String representation of this Mass object

compareTo

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

Parameters:
that - The Mass 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 Mass.

Jeospace API

Copyright © 2006 - jeospace.org