faa.tg.units
Class AUnits

java.lang.Object
  extended by faa.tg.units.AUnits
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AccelerationUnits, AngleUnits, AngularAccelerationUnits, AngularRateUnits, AreaUnits, DensityUnits, DistanceUnits, ForceUnits, FuelFlowRateUnits, IndicatedAirspeedRateUnits, MachRateUnits, MachUnits, MassRateUnits, MassUnits, OneOverTimeUnits, PressureUnits, SpeedUnits, TemperatureUnits, TimeUnits, TrueAirspeedRateUnits, VolumeUnits, WeightUnits

public class AUnits
extends java.lang.Object
implements java.io.Serializable

 AUnits is an abstract base class for all units of measure.  A different
 derived class is created for each kind of measurement.  For example,
 DistanceUnits could be derived for all measurements of length.  The
 specific units such as meters, kilometers, miles, feet, etc. would be
 static instances of DistanceUnits.  Generally these units would be included
 in the static class units and referenced like units.km or units.meters.

 Classes derived from AUnits are used to set and get values of classes
 derived from AMeasures descendants.  This provides type safety in that
 mixing different types of units would not be allowed.  For example, trying
 to construct a Distance object with a value of 3 pounds would trigger an
 error.  (Everyone knows that in the English system of measure 3 pounds
 should be a monetary value!)

 
See the source: AUnits.java See section 5.6 of the Detailed Design Document for a discussion of design issues.

Version:
$Id: AUnits.java,v 3.3 2008/11/24 22:13:10 lykensj Exp $
Author:
Tim Kimmet (modeled after Robert G. Oliver's Units Classes)
See Also:
DistanceUnits, MassUnits, AccelerationUnits, AngleUnits, TimeUnits, Serialized Form

Field Summary
private  AUnits canonicalUnit
          The canonical unit of this unit type.
static java.lang.String CVS_VERSION_ID
          The CVS Version ID
private  java.lang.String itsAbbr
          The abbreviation of the unit; for example, "m" may stand for a meter.
private  double itsConversionFactor
          The conversion factor to convert this unit to the base unit stored in.
private  java.lang.String itsName
          The complete name of the unit; for example, "meters".
(package private) static long serialVersionUID
           
 
Constructor Summary
protected AUnits(double theValue, AUnits conversionUnit, java.lang.String fullName, java.lang.String shortName)
          This constructor specifies units other than the canonical units.
protected AUnits(java.lang.String fullName, java.lang.String shortName)
          This constructor specifies the canonical units.
 
Method Summary
 java.lang.String abbr()
          Returns the abbreviation of the units this class specifies
 double convertFromCanonical(double theValue)
          Takes a value in canonical units and returns the value in units described by this class.
 double convertToCanonical(double theValue)
          Takes a value in the units described by this class and returns the value in canonical units.
 AUnits getCanonicalUnit()
          Returns this AUnits' canonical unit class.
 java.lang.Class<? extends AUnits> getUnitClass()
          Returns the AUnit Class.
 java.lang.String name()
          Returns the name of the units this class specifies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

CVS_VERSION_ID

public static final java.lang.String CVS_VERSION_ID
The CVS Version ID

See Also:
Constant Field Values

canonicalUnit

private AUnits canonicalUnit
The canonical unit of this unit type.


itsConversionFactor

private double itsConversionFactor
The conversion factor to convert this unit to the base unit stored in.


itsName

private java.lang.String itsName
The complete name of the unit; for example, "meters".


itsAbbr

private java.lang.String itsAbbr
The abbreviation of the unit; for example, "m" may stand for a meter.

Constructor Detail

AUnits

protected AUnits(java.lang.String fullName,
                 java.lang.String shortName)
This constructor specifies the canonical units. These are the units that AMeasure.itsValue is actually stored in. example: DistanceUnits meters = new DistanceUnits("meters","m");

Parameters:
fullName - the full name of the units (ex. "kilometers")
shortName - the abbreviated name of the units (ex. "km")

AUnits

protected AUnits(double theValue,
                 AUnits conversionUnit,
                 java.lang.String fullName,
                 java.lang.String shortName)
This constructor specifies units other than the canonical units. Other units must be specified in terms of either the canonical units or other previously specified units. example: DistanceUnits km = new DistanceUnits(1000.0, meters,"kilometers","km");

Parameters:
theValue - Value of one new unit in terms of canonical units.
conversionUnit - The base unit to create this new unit.
fullName - the full name of the units (ex. "kilometers")
shortName - the abbreviated name of the units (ex. "km")
Method Detail

getCanonicalUnit

public AUnits getCanonicalUnit()
Returns this AUnits' canonical unit class.

Returns:
The canonical unit of the subclass.

getUnitClass

public java.lang.Class<? extends AUnits> getUnitClass()
Returns the AUnit Class.

Returns:
The subclass of the AUnit.

convertToCanonical

public double convertToCanonical(double theValue)
Takes a value in the units described by this class and returns the value in canonical units.

Parameters:
theValue - a value in units of this class
Returns:
a value in canonical units

convertFromCanonical

public double convertFromCanonical(double theValue)
Takes a value in canonical units and returns the value in units described by this class.

Parameters:
theValue - a value in canonical units
Returns:
a value in units of this class

name

public java.lang.String name()
Returns the name of the units this class specifies

Returns:
the name of the units (ex: kilometers)

abbr

public java.lang.String abbr()
Returns the abbreviation of the units this class specifies

Returns:
the abbreviation of the units (ex: km)