|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfaa.tg.units.AUnits
public class AUnits
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.
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 |
|---|
static final long serialVersionUID
public static final java.lang.String CVS_VERSION_ID
private AUnits canonicalUnit
private double itsConversionFactor
private java.lang.String itsName
private java.lang.String itsAbbr
| Constructor Detail |
|---|
protected AUnits(java.lang.String fullName,
java.lang.String shortName)
fullName - the full name of the units (ex. "kilometers")shortName - the abbreviated name of the units (ex. "km")
protected AUnits(double theValue,
AUnits conversionUnit,
java.lang.String fullName,
java.lang.String shortName)
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 |
|---|
public AUnits getCanonicalUnit()
public java.lang.Class<? extends AUnits> getUnitClass()
public double convertToCanonical(double theValue)
theValue - a value in units of this class
public double convertFromCanonical(double theValue)
theValue - a value in canonical units
public java.lang.String name()
public java.lang.String abbr()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||