net.agmodel.physical
Class Volume

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

public final class Volume
extends AbstractQuantity
implements Comparable

This class represents the amount of space occupied by a three-dimensional object or region of space, expressed in cubic units.

See Also:
Serialized Form

Field Summary
static int BARREL
          Used to specify barrel unit (oil).
static int BUSHEL_UK
          Used to specify UK bushel unit.
static int BUSHEL_US
          Used to specify US bushel unit.
static int CENTILITER
          Used to specify centiliter unit.
static int CENTILITRE
           
static int CUBIC_CENTIMETER
          Used to specify cubic centimeter unit.
static int CUBIC_CENTIMETRE
           
static int CUBIC_DECAMETER
          Used to specify cubic decameter unit.
static int CUBIC_DECAMETRE
           
static int CUBIC_DECIMETER
          Used to specify cubic decimeter unit.
static int CUBIC_DECIMETRE
           
static int CUBIC_FOOT
          Used to specify cubic foot unit.
static int CUBIC_INCH
          Used to specify cubic inch unit.
static int CUBIC_METER
          Used to specify cubic meter unit.
static int CUBIC_METRE
           
static int CUBIC_MILLIMETER
          Used to specify cubic millimeter unit.
static int CUBIC_MILLIMETRE
           
static int CUBIC_YARD
          Used to specify cubic yard unit.
static int CUP_UK
          Used to specify UK cup unit (= 10 UK ounces).
static int CUP_US
          Used to specify US cup unit (= 8 US ounces).
static int DECILITER
          Used to specify deciliter unit.
static int DECILITRE
           
static int DRACHM
          Used to specify drachm, fluid unit (= 1/1280 UK Gallon).
protected static double[] factors
          Conversion table.
static int GALLON_DRY_US
          Used to specify US gallon, dry unit.
static int GALLON_LIQUID_US
          Used to specify US gallon, liquid unit.
static int GALLON_UK
          Used to specify UK gallon unit.
static int LITER
          Used to specify liter unit, (1964 Standard: 1 liter = 1 cubic decimeter).
static int LITRE
           
static int MAAS
          Used to specify maas unit (Germany).
static int MILLILITER
          Used to specify milliter unit.
static int MILLILITRE
           
static int OUNCE_UK
          Used to specify UK ounce, fluid unit.
static int OUNCE_US
          Used to specify US ounce, fluid unit.
static int PINT_DRY_US
          Used to specify US pint, dry unit.
static int PINT_LIQUID_US
          Used to specify US pint, liquid unit.
static int PINT_UK
          Used to specify UK pint unit.
static int QUART_DRY_US
          Used to specify US quart, dry unit.
static int QUART_LIQUID_US
          Used to specify US quart, liquid unit.
static int QUART_UK
          Used to specify UK quart unit.
static int TABLESPOON_AU
          Used to specify Australian tablespoon unit.
static int TABLESPOON_UK
          Used to specify UK tablespoon unit.
static int TABLESPOON_US
          Used to specify US tablespoon 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
Volume(Composite c)
          Volume constructor from Composite quantity.
Volume(double value, int unit)
          Volume constructor.
Volume(Length radius, Angle theta)
          Volume constructor from a Length and an Angle (slice of a sphere).
 
Method Summary
 Volume add(Volume x)
          Returns a Volume whose value is (this + x).
 int compareTo(Object o)
          Compares this Volume with the specified Object.
 int compareTo(Volume x)
          Compares this Volume with the specified Volume.
 Length divide(Area x)
          Returns a Length whose value is (this / x).
 Volume divide(double coefficient)
          Returns a Volume whose value is (this / coefficient).
 Area divide(Length x)
          Returns an Area whose value is (this / x).
protected  int getDimensionSI()
          Gets the SI dimension of this Volume.
 double getValue(int unit)
          Gets the volume in the specified unit.
protected  double getValueSI()
          Gets the volume in cubic meters.
 Volume multiply(double coefficient)
          Returns a Volume whose value is (this * coefficient).
 Mass multiply(Volume d)
          Returns a Mass whose value is (this * d).
 void setValue(double value, int unit)
          Sets this Volume using the specified unit.
 Volume substract(Volume x)
          Returns a Volume 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

CUBIC_METER

public static final int CUBIC_METER
Used to specify cubic meter unit.

See Also:
Constant Field Values

CUBIC_METRE

public static final int CUBIC_METRE
See Also:
Constant Field Values

CUBIC_FOOT

public static final int CUBIC_FOOT
Used to specify cubic foot unit.

See Also:
Constant Field Values

CUBIC_YARD

public static final int CUBIC_YARD
Used to specify cubic yard unit.

See Also:
Constant Field Values

CUBIC_INCH

public static final int CUBIC_INCH
Used to specify cubic inch unit.

See Also:
Constant Field Values

LITER

public static final int LITER
Used to specify liter unit, (1964 Standard: 1 liter = 1 cubic decimeter).

See Also:
Constant Field Values

LITRE

public static final int LITRE
See Also:
Constant Field Values

GALLON_LIQUID_US

public static final int GALLON_LIQUID_US
Used to specify US gallon, liquid unit.

See Also:
Constant Field Values

GALLON_DRY_US

public static final int GALLON_DRY_US
Used to specify US gallon, dry unit.

See Also:
Constant Field Values

GALLON_UK

public static final int GALLON_UK
Used to specify UK gallon unit.

See Also:
Constant Field Values

OUNCE_US

public static final int OUNCE_US
Used to specify US ounce, fluid unit.

See Also:
Constant Field Values

OUNCE_UK

public static final int OUNCE_UK
Used to specify UK ounce, fluid unit.

See Also:
Constant Field Values

BUSHEL_US

public static final int BUSHEL_US
Used to specify US bushel unit.

See Also:
Constant Field Values

BUSHEL_UK

public static final int BUSHEL_UK
Used to specify UK bushel unit.

See Also:
Constant Field Values

BARREL

public static final int BARREL
Used to specify barrel unit (oil).

See Also:
Constant Field Values

PINT_LIQUID_US

public static final int PINT_LIQUID_US
Used to specify US pint, liquid unit.

See Also:
Constant Field Values

PINT_DRY_US

public static final int PINT_DRY_US
Used to specify US pint, dry unit.

See Also:
Constant Field Values

PINT_UK

public static final int PINT_UK
Used to specify UK pint unit.

See Also:
Constant Field Values

QUART_LIQUID_US

public static final int QUART_LIQUID_US
Used to specify US quart, liquid unit.

See Also:
Constant Field Values

QUART_DRY_US

public static final int QUART_DRY_US
Used to specify US quart, dry unit.

See Also:
Constant Field Values

QUART_UK

public static final int QUART_UK
Used to specify UK quart unit.

See Also:
Constant Field Values

MILLILITER

public static final int MILLILITER
Used to specify milliter unit.

See Also:
Constant Field Values

MILLILITRE

public static final int MILLILITRE
See Also:
Constant Field Values

CENTILITER

public static final int CENTILITER
Used to specify centiliter unit.

See Also:
Constant Field Values

CENTILITRE

public static final int CENTILITRE
See Also:
Constant Field Values

DECILITER

public static final int DECILITER
Used to specify deciliter unit.

See Also:
Constant Field Values

DECILITRE

public static final int DECILITRE
See Also:
Constant Field Values

CUBIC_MILLIMETER

public static final int CUBIC_MILLIMETER
Used to specify cubic millimeter unit.

See Also:
Constant Field Values

CUBIC_MILLIMETRE

public static final int CUBIC_MILLIMETRE
See Also:
Constant Field Values

CUBIC_CENTIMETER

public static final int CUBIC_CENTIMETER
Used to specify cubic centimeter unit.

See Also:
Constant Field Values

CUBIC_CENTIMETRE

public static final int CUBIC_CENTIMETRE
See Also:
Constant Field Values

CUBIC_DECIMETER

public static final int CUBIC_DECIMETER
Used to specify cubic decimeter unit.

See Also:
Constant Field Values

CUBIC_DECIMETRE

public static final int CUBIC_DECIMETRE
See Also:
Constant Field Values

CUBIC_DECAMETER

public static final int CUBIC_DECAMETER
Used to specify cubic decameter unit.

See Also:
Constant Field Values

CUBIC_DECAMETRE

public static final int CUBIC_DECAMETRE
See Also:
Constant Field Values

CUP_US

public static final int CUP_US
Used to specify US cup unit (= 8 US ounces).

See Also:
Constant Field Values

CUP_UK

public static final int CUP_UK
Used to specify UK cup unit (= 10 UK ounces).

See Also:
Constant Field Values

TABLESPOON_US

public static final int TABLESPOON_US
Used to specify US tablespoon unit.

See Also:
Constant Field Values

TABLESPOON_UK

public static final int TABLESPOON_UK
Used to specify UK tablespoon unit.

See Also:
Constant Field Values

TABLESPOON_AU

public static final int TABLESPOON_AU
Used to specify Australian tablespoon unit.

See Also:
Constant Field Values

MAAS

public static final int MAAS
Used to specify maas unit (Germany).

See Also:
Constant Field Values

DRACHM

public static final int DRACHM
Used to specify drachm, fluid unit (= 1/1280 UK Gallon).

See Also:
Constant Field Values

factors

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

Constructor Detail

Volume

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

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

Volume

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

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

Volume

public Volume(Length radius,
              Angle theta)
Volume constructor from a Length and an Angle (slice of a sphere). It returns the volume of the slice defined from the specified sphere radius and central angle.

Parameters:
radius - the sphere radius.
theta - the central solid angle.
Method Detail

getValue

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

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

setValue

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

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

add

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

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

substract

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

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

multiply

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

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

divide

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

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

divide

public Length divide(Area x)
Returns a Length whose value is (this / x).

Parameters:
x - the Area divisor.
Returns:
(this / x)
Throws:
ArithmeticException - x.getValue(SQUARE_METER) == 0.0

divide

public Area divide(Length x)
Returns an Area whose value is (this / x).

Parameters:
x - the Length divisor.
Returns:
(this / x)
Throws:
ArithmeticException - x.getValue(METER) == 0.0

multiply

public Mass multiply(Volume d)
Returns a Mass whose value is (this * d).

Parameters:
d - the volumetric density multiplier.
Returns:
(this * d)

compareTo

public int compareTo(Volume x)
Compares this Volume with the specified Volume. 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 - Volume to which this Volume is to be compared.
Returns:
-1, 0 or 1 as this Volume is numerically less than, equal to, or greater than x.

compareTo

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

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

getValueSI

protected double getValueSI()
Gets the volume in cubic meters.

Specified by:
getValueSI in class AbstractQuantity
Returns:
volume in cubic meters.

getDimensionSI

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

Specified by:
getDimensionSI in class AbstractQuantity
Returns:
3 * LENGTH