ptolemy.data.unit
Class UnitLibrary

java.lang.Object
  extended byptolemy.data.unit.UnitLibrary

public class UnitLibrary
extends java.lang.Object

A Library containing definitions of commonly used units. Currently, the Unit library is static in the sense that it is loaded when the system starts and is hard-wired to a particular Unit System (the System International Unit System). However, it should be easy to change the architecture so that multiple Unit Systems can be accommodated, and loaded on-the-fly.

Since:
Ptolemy II 4.0
Version:
$Id: UnitLibrary.java,v 1.18 2004/04/13 16:55:41 cxh Exp $
Author:
Rowland R Johnson
Accepted Rating:
Red (rowland)
Proposed Rating:
Red (rowland)

Field Summary
static Unit Identity
           
 
Constructor Summary
UnitLibrary()
           
 
Method Summary
static void addToLibrary(Unit unit)
          Add a unit to the Library.
static Unit getBaseUnit(int catNum)
          Find the Unit in the library that is basic (scale equal to 1), singular (all but one dimensions equal to 0), XXXXX
static Unit getClosestUnit(Unit unit)
          Search Library to find Unit that has the same type and is the closest to a unit in terms of the scalars.
static java.util.Vector getLibrary()
          Return the Library.
static int getNumCategories()
          Return the number of categories.
static UParser getParser()
          Return the Parser.
static Unit getUnit(Unit unit)
          Search Library for Unit equal to a particular unit.
static Unit getUnitByName(java.lang.String name)
          Search the Library for a unit with a particular name.
static java.util.Vector getUnitsByType(Unit unit)
          Search Library for all Units with type equal to this one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Identity

public static Unit Identity
Constructor Detail

UnitLibrary

public UnitLibrary()
Method Detail

addToLibrary

public static void addToLibrary(Unit unit)
Add a unit to the Library.

Parameters:
unit - Unit to add to the library.

getBaseUnit

public static Unit getBaseUnit(int catNum)
Find the Unit in the library that is basic (scale equal to 1), singular (all but one dimensions equal to 0), XXXXX

Parameters:
catNum -
Returns:
The basic, singular unit.

getClosestUnit

public static Unit getClosestUnit(Unit unit)
Search Library to find Unit that has the same type and is the closest to a unit in terms of the scalars.

Returns:
The Unit closest to this the argument. Null, if there are no Units in the Library with the same type.

getLibrary

public static java.util.Vector getLibrary()
Return the Library.

Returns:
The Library

getNumCategories

public static int getNumCategories()
Return the number of categories.

Returns:
Number of categories.

getParser

public static UParser getParser()
Return the Parser.

Returns:
The Parser.

getUnit

public static Unit getUnit(Unit unit)
Search Library for Unit equal to a particular unit. That is, both the type and scalar must be equal to the argument.

Returns:
Unit in Library equal to this one. Null if none found.

getUnitByName

public static Unit getUnitByName(java.lang.String name)
Search the Library for a unit with a particular name.

Parameters:
name - The name of the desired unit.
Returns:
The unit with name equal to the argument. Null, if the Library doesn't have a unit with that name.

getUnitsByType

public static java.util.Vector getUnitsByType(Unit unit)
Search Library for all Units with type equal to this one.

Parameters:
unit -
Returns:
Vector of Units with type equal to the argument.