net.agmodel.physical
Class Frequency

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

public final class Frequency
extends AbstractQuantity
implements Comparable

This class represents the number of times a specified phenomenon occurs within a specified interval.

See Also:
Duration, Serialized Form

Field Summary
protected static double[] factors
          Conversion table.
static int GIGAHERTZ
          Used to specify kilohertz unit.
static int HERTZ
          Used to specify hertz unit.
static int KILOHERTZ
          Used to specify kilohertz unit.
static int MEGAHERTZ
          Used to specify kilohertz unit.
static int TERAHERTZ
          Used to specify terahertz 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
Frequency(Composite c)
          Frequency constructor from Composite quantity.
Frequency(double value, int unit)
          Frequency constructor.
 
Method Summary
 Frequency add(Frequency x)
          Returns a Frequency whose value is (this + x).
 int compareTo(Frequency x)
          Compares this Frequency with the specified Frequency.
 int compareTo(Object o)
          Compares this Frequency with the specified Object.
 Frequency divide(double coefficient)
          Returns a Frequency whose value is (this / coefficient).
protected  int getDimensionSI()
          Gets the SI dimension of this Frequency.
 double getValue(int unit)
          Gets the frequency in the specified unit.
protected  double getValueSI()
          Gets the frequency in SI units.
 Duration inverse()
          Returns the Duration period corresponding to this frequency.
 Frequency multiply(double coefficient)
          Returns a Frequency whose value is (this * coefficient).
 void setValue(double value, int unit)
          Sets this Frequency using the specified unit.
 Frequency substract(Frequency x)
          Returns a Frequency 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

HERTZ

public static final int HERTZ
Used to specify hertz unit.

See Also:
Constant Field Values

KILOHERTZ

public static final int KILOHERTZ
Used to specify kilohertz unit.

See Also:
Constant Field Values

MEGAHERTZ

public static final int MEGAHERTZ
Used to specify kilohertz unit.

See Also:
Constant Field Values

GIGAHERTZ

public static final int GIGAHERTZ
Used to specify kilohertz unit.

See Also:
Constant Field Values

TERAHERTZ

public static final int TERAHERTZ
Used to specify terahertz unit.

See Also:
Constant Field Values

factors

protected static final double[] factors
Conversion table. For each unit, it specifies the equivalent value using SI units.

Constructor Detail

Frequency

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

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

Frequency

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

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

getValue

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

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

setValue

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

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

add

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

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

substract

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

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

multiply

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

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

divide

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

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

inverse

public Duration inverse()
Returns the Duration period corresponding to this frequency.

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

compareTo

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

compareTo

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

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

getValueSI

protected double getValueSI()
Gets the frequency in SI units.

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

getDimensionSI

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

Specified by:
getDimensionSI in class AbstractQuantity
Returns:
- TIME