net.agmodel.physical
Class Mass

java.lang.Object
  |
  +--net.agmodel.physical.AbstractQuantity
        |
        +--net.agmodel.physical.Mass
All Implemented Interfaces:
Cloneable, Comparable, Serializable

public final class Mass
extends AbstractQuantity
implements Comparable

This class represents the measure of the quantity of matter that a body or an object contains.  The mass of the body is not dependent on gravity and therefore is different from but proportional to its weight

See Also:
Serialized Form

Field Summary
static int CARAT
          Used to specify carat unit.
protected static double[] factors
          Conversion table.
static int GRAIN
          Used to specify grain unit.
static int GRAM
          Used to specify gram unit.
static int HUNDREDWEIGHT_UK
          Used to specify UK hundredweight unit (= 112 pounds).
static int HUNDREDWEIGHT_US
          Used to specify US hundredweight unit (= 100 pounds).
static int KILOGRAM
          Used to specify kilogram unit.
static int OUNCE_AVOIRDUPOIS
          Used to specify avoirdupois ounce unit (US).
static int OUNCE_TROY
          Used to specify troy ounce unit.
static int POUND
          Used to specify pound unit.
static int QUINTAL
          Used to specify metric quintal unit.
static int SLUG
          Used to specify slug unit.
static int STONE
          Used to specify stone unit.
static int TON_UK
          Used to specify UK ton unit.
static int TON_US
          Used to specify US ton unit.
static int TONNE
          Used to specify metric ton unit.
 
Fields inherited from class net.agmodel.physical.AbstractQuantity
AMOUNT_OF_SUBSTANCE, COMPLETE, derivation, DEVOID, DIMENSIONLESS, ELECTRIC_CURRENT, LENGTH, LUMINOUS_INTENSITY, MASS, SPATIALLYINTERPOLATED, TEMPORALLYINTERPOLATED, THERMODYNAMIC_TEMPERATURE, TIME, UNINTERPOLATED
 
Constructor Summary
Mass(Composite c)
          Mass constructor from Composite quantity.
Mass(double value, int unit)
          Mass constructor.
 
Method Summary
 Mass add(Mass x)
          Returns a Mass whose value is (this + x).
 int compareTo(Mass x)
          Compares this Mass with the specified Mass.
 int compareTo(Object o)
          Compares this Mass with the specified Object.
 Mass divide(double coefficient)
          Returns a Mass whose value is (this / coefficient).
 VolumetricDensity divide(Volume v)
          Returns a VolumetricDensity whose value is (this / v).
protected  int getDimensionSI()
          Gets the SI dimension of this Mass.
 double getValue(int unit)
          Gets the mass in the specified unit.
protected  double getValueSI()
          Gets the mass in kilograms.
 Mass multiply(double coefficient)
          Returns a Mass whose value is (this * coefficient).
 void setValue(double value, int unit)
          Sets this Mass using the specified unit.
 Mass substract(Mass x)
          Returns a Mass whose value is (this - x).
 
Methods inherited from class net.agmodel.physical.AbstractQuantity
clone, divide, getSymbolSI, isSpatiallyInterpolated, isTemporallyInterpolated, multiply, toComposite, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KILOGRAM

public static final int KILOGRAM
Used to specify kilogram unit.  The kilogram is equal to the mass of an international prototype in the form of a platinum-iridium cylinder kept at Sevres in France

See Also:
Constant Field Values

CARAT

public static final int CARAT
Used to specify carat unit.

See Also:
Constant Field Values

GRAIN

public static final int GRAIN
Used to specify grain unit.

See Also:
Constant Field Values

GRAM

public static final int GRAM
Used to specify gram unit.

See Also:
Constant Field Values

HUNDREDWEIGHT_US

public static final int HUNDREDWEIGHT_US
Used to specify US hundredweight unit (= 100 pounds).

See Also:
Constant Field Values

HUNDREDWEIGHT_UK

public static final int HUNDREDWEIGHT_UK
Used to specify UK hundredweight unit (= 112 pounds).

See Also:
Constant Field Values

QUINTAL

public static final int QUINTAL
Used to specify metric quintal unit.

See Also:
Constant Field Values

OUNCE_AVOIRDUPOIS

public static final int OUNCE_AVOIRDUPOIS
Used to specify avoirdupois ounce unit (US).  The avoirdupois system of weights and measures is based on a pound containing 16 ounces or 7,000 grains and equal to 453.59 grams.

See Also:
Constant Field Values

OUNCE_TROY

public static final int OUNCE_TROY
Used to specify troy ounce unit.  The troy system of weight and measures is based on a grain which is the same as in the avoirdupois system and a pound contains 12 ounces, 240 pennyweights, or 5,760 grains.

See Also:
Constant Field Values

POUND

public static final int POUND
Used to specify pound unit.

See Also:
Constant Field Values

SLUG

public static final int SLUG
Used to specify slug unit.

See Also:
Constant Field Values

STONE

public static final int STONE
Used to specify stone unit.

See Also:
Constant Field Values

TON_US

public static final int TON_US
Used to specify US ton unit.

See Also:
Constant Field Values

TON_UK

public static final int TON_UK
Used to specify UK ton unit.

See Also:
Constant Field Values

TONNE

public static final int TONNE
Used to specify metric ton unit.

See Also:
Constant Field Values

factors

protected static final double[] factors
Conversion table. For each unit, it specifies the equivalent value in kilogram.

Constructor Detail

Mass

public Mass(double value,
            int unit)
Mass constructor.

Parameters:
value - the mass in the specified unit.
unit - the measurement unit being used.
Throws:
ArrayIndexOutOfBoundsException - unknown measurement unit

Mass

public Mass(Composite c)
Mass constructor from Composite quantity.

Parameters:
c - the quantity to convert.
Throws:
UnitDimensionException - composite is not a mass.
See Also:
Composite
Method Detail

getValue

public double getValue(int unit)
Gets the mass in the specified unit.

Parameters:
unit - the measurement unit being used.
Returns:
mass in the specified measurement unit.
Throws:
ArrayIndexOutOfBoundsException - unknown measurement unit

setValue

public void setValue(double value,
                     int unit)
Sets this Mass using the specified unit.

Parameters:
value - the new mass in the specified unit.
unit - the measurement unit being used.
Throws:
ArrayIndexOutOfBoundsException - unknown measurement unit

add

public Mass add(Mass x)
Returns a Mass whose value is (this + x).

Parameters:
x - the Mass to be added.
Returns:
(this + x)

substract

public Mass substract(Mass x)
Returns a Mass whose value is (this - x).

Parameters:
x - the Mass to be substracted.
Returns:
(this - x)

multiply

public Mass multiply(double coefficient)
Returns a Mass whose value is (this * coefficient).

Parameters:
coefficient - the dimensionless multiplier.
Returns:
(this * coefficient)

divide

public Mass divide(double coefficient)
Returns a Mass whose value is (this / coefficient).

Parameters:
coefficient - the dimensionless divisor.
Returns:
(this / coefficient)
Throws:
ArithmeticException - coefficient == 0.0

divide

public VolumetricDensity divide(Volume v)
Returns a VolumetricDensity whose value is (this / v).

Parameters:
v - the volume divisor.
Returns:
(this / v)

compareTo

public int compareTo(Mass x)
Compares this Mass with the specified Mass. This method is provided in preference to individual methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=). The suggested idiom for performing these comparisons is: (x.compareTo(y) <op> 0), where <op> is one of the six comparison operators.

Parameters:
x - Mass to which this Mass is to be compared.
Returns:
-1, 0 or 1 as this Mass is numerically less than, equal to, or greater than x.

compareTo

public int compareTo(Object o)
Compares this Mass with the specified Object. If the Object is a Mass, this method behaves like compareTo(Mass). Otherwise, it throws a ClassCastException (as Masss are comparable only to other Masss).

Specified by:
compareTo in interface Comparable
Parameters:
o - Object to which this Mass is to be compared.
Returns:
a negative number, zero, or a positive number as this Mass is numerically less than, equal to, or greater than o, which must be a Mass.
Throws:
ClassCastException - o is not a Mass.
See Also:
compareTo(Mass), Comparable

getValueSI

protected double getValueSI()
Gets the mass in kilograms.

Specified by:
getValueSI in class AbstractQuantity
Returns:
mass in kilograms.

getDimensionSI

protected int getDimensionSI()
Gets the SI dimension of this Mass.

Specified by:
getDimensionSI in class AbstractQuantity
Returns:
MASS