ucar.units
Class BaseUnit

java.lang.Object
  extended by ucar.units.UnitImpl
      extended by ucar.units.DerivedUnitImpl
          extended by ucar.units.BaseUnit
All Implemented Interfaces:
Serializable, Base, DerivableUnit, DerivedUnit, Unit
Direct Known Subclasses:
UnknownUnit

public class BaseUnit
extends DerivedUnitImpl
implements Base

Provides support for base units.

Version:
$Id: BaseUnit.java 64 2006-07-12 22:30:50Z edavis $
Author:
Steven R. Emmerson
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ucar.units.UnitImpl
UnitImpl.MyConverter
 
Field Summary
 
Fields inherited from class ucar.units.DerivedUnitImpl
DIMENSIONLESS
 
Constructor Summary
protected BaseUnit(UnitName id, BaseQuantity baseQuantity)
          Constructs from identifiers and a base quantity.
 
Method Summary
 BaseQuantity getBaseQuantity()
          Returns the base quantity associated with this base unit.
 String getID()
          Returns the identifier for this base unit.
static BaseUnit getOrCreate(UnitName id, BaseQuantity baseQuantity)
          Factory method for creating a new BaseUnit or obtaining a previously-created one.
 boolean isDimensionless()
          Indicates if this base unit is dimensionless.
static void main(String[] args)
          Tests this class.
 String toString()
          Returns the string representation of this base unit.
 
Methods inherited from class ucar.units.DerivedUnitImpl
clone, equals, fromDerivedUnit, fromDerivedUnit, fromDerivedUnit, fromDerivedUnit, getCanonicalString, getDerivedUnit, getDimension, getQuantityDimension, hashCode, isCompatible, isReciprocalOf, myDivideBy, myDivideInto, myMultiplyBy, myRaiseTo, setDimension, toDerivedUnit, toDerivedUnit, toDerivedUnit, toDerivedUnit
 
Methods inherited from class ucar.units.UnitImpl
convertTo, convertTo, convertTo, convertTo, convertTo, convertTo, divideBy, divideInto, getConverterTo, getName, getPlural, getSymbol, getUnitName, log, makeLabel, multiplyBy, multiplyBy, raiseTo, shiftTo, shiftTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ucar.units.Base
equals
 
Methods inherited from interface ucar.units.Unit
convertTo, convertTo, convertTo, convertTo, convertTo, convertTo, divideBy, divideInto, getConverterTo, getName, getPlural, getSymbol, getUnitName, log, makeLabel, multiplyBy, multiplyBy, raiseTo, shiftTo, shiftTo
 

Constructor Detail

BaseUnit

protected BaseUnit(UnitName id,
                   BaseQuantity baseQuantity)
            throws NameException
Constructs from identifiers and a base quantity.

Parameters:
id - The identifiers for the base unit. id.getSymbol() shall not return null.
baseQuantity - The base quantity of the base unit.
Throws:
NameException - id.getSymbol() returned null.
Method Detail

getOrCreate

public static BaseUnit getOrCreate(UnitName id,
                                   BaseQuantity baseQuantity)
                            throws NameException,
                                   UnitExistsException
Factory method for creating a new BaseUnit or obtaining a previously-created one.

Parameters:
id - The identifier for the base unit. id.getSymbol() shall not return null.
baseQuantity - The base quantity of the base unit.
Throws:
NameException - id.getSymbol() returned null.
UnitExistsException - Attempt to incompatibly redefine an existing base unit.

getBaseQuantity

public final BaseQuantity getBaseQuantity()
Returns the base quantity associated with this base unit.

Returns:
The base quantity associated with this base unit.

getID

public final String getID()
Returns the identifier for this base unit. This is identical to getSymbol().

Specified by:
getID in interface Base
Returns:
The identifier for this base unit.

toString

public final String toString()
Returns the string representation of this base unit. This is identical to getID().

Specified by:
toString in interface Unit
Overrides:
toString in class DerivedUnitImpl
Returns:
The string representation of this base unit.

isDimensionless

public boolean isDimensionless()
Indicates if this base unit is dimensionless.

Specified by:
isDimensionless in interface Base
Specified by:
isDimensionless in interface Unit
Overrides:
isDimensionless in class DerivedUnitImpl
Returns:
true if and only if this base unit is dimensionless (e.g. "radian").

main

public static void main(String[] args)
                 throws Exception
Tests this class.

Throws:
Exception


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.