net.agmodel.physical
Class Composite

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

public class Composite
extends AbstractQuantity
implements Comparable

This class represents a combination of several quantities.

See Also:
Serialized Form

Field Summary
 
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
protected Composite(double valueSI, int dimensionSI)
          Composite constructor.
 
Method Summary
 Composite add(Composite x)
          Returns a Composite whose value is (this + x).
 int compareTo(Composite x)
          Compares this Composite with the specified Composite.
 int compareTo(Object o)
          Compares this Composite with the specified Object.
 Composite divide(double coefficient)
          Returns a Composite whose value is (this / coefficient).
protected  int getDimensionSI()
          Gets the SI dimension of this Composite.
 double getValueSI()
          Gets the quantity in SI units.
 Composite inverse()
          Returns the Composite whose value is (1 / this).
 Composite multiply(double coefficient)
          Returns a Composite whose value is (this * coefficient).
 Composite subtract(Composite x)
          Returns a Composite 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
 

Constructor Detail

Composite

protected Composite(double valueSI,
                    int dimensionSI)
Composite constructor.  It returns the Composite with the specified SI value and specified dimension.

Parameters:
valueSI - the value in SI unit.
dimensionSI - the SI dimension.
Method Detail

add

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

Parameters:
x - the Composite to be added.
Returns:
(this + x)
Throws:
UnitDimensionException - different unit dimensions

subtract

public Composite subtract(Composite x)
Returns a Composite whose value is (this - x).

Parameters:
x - the Composite to be subtracted.
Returns:
(this - x)
Throws:
UnitDimensionException - different unit dimensions

multiply

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

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

divide

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

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

inverse

public Composite inverse()
Returns the Composite whose value is (1 / this).

Returns:
(1 / this)
Throws:
ArithmeticException - this.getValueSI() == 0.0

compareTo

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

compareTo

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

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

getValueSI

public double getValueSI()
Gets the quantity in SI units.

Specified by:
getValueSI in class AbstractQuantity
Returns:
quantity in SI units.

getDimensionSI

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

Specified by:
getDimensionSI in class AbstractQuantity
Returns:
SI dimension of this Composite.