|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvisad.data.units.UnitTable
visad.data.units.DefaultUnitsDB
public final class DefaultUnitsDB
Default units database. This database knows about approximately 500 different units. Users can also add new units to the database at runtime. The basis for this units database is the International System of Units (SI). This is a singleton class.
Nested Class Summary | |
---|---|
protected class |
DefaultUnitsDB.Prefixer
Inner (helper) class for parsing unit prefixes. |
Field Summary | |
---|---|
protected UnitPrefix[] |
prefixNames
The unit prefix names in order of lexicographic length: |
protected UnitPrefix[] |
prefixSymbols
The unit prefix symbols in order of lexicographic length: |
Method Summary | |
---|---|
Unit |
get(java.lang.String name)
Get a unit. |
static UnitsDB |
instance()
Gets an instance of this class. |
static void |
main(java.lang.String[] args)
Test this class. |
protected void |
pn(java.lang.String name,
java.lang.String unitID)
Adds a name and it's regular plural form to the database for a unit that's already in the database. |
protected void |
pn(java.lang.String name,
Unit unit)
Adds a name, the plural form of the name, and a new unit to the database. |
protected void |
ps(java.lang.String symbol,
java.lang.String unitID)
Adds a symbol to the database for a unit already in the database. |
protected void |
ps(java.lang.String symbol,
Unit unit)
Adds a symbol and a new unit to the database. |
protected void |
px(java.lang.String name,
java.lang.String unitID)
Adds a name that has no plural form to the database for a unit that's already in the database. |
protected void |
px(java.lang.String name,
Unit unit)
Adds a name that has no plural form and a new unit to the database. |
Methods inherited from class visad.data.units.UnitTable |
---|
getByName, getBySymbol, getNameEnumeration, getSymbolEnumeration, getUnitEnumeration, list, makePlural, put, putName, putSymbol, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final UnitPrefix[] prefixNames
protected final UnitPrefix[] prefixSymbols
Method Detail |
---|
public static UnitsDB instance() throws UnitException
UnitException
- Something went wrong in generating the singleton
instance of the database. This should not occur
and indicates an internal inconsistancy.public Unit get(java.lang.String name)
get
in interface UnitsDB
get
in class UnitTable
name
- The name of the unit to be retrieved. It may be
the plural form (e.g. "yards"). If an entry in the
database corresponding to the complete name is not
found and the given name ends with an `s', then a
search will be made for the singular form (e.g.
"yard"). The matching entry will be returned only if
the entry permits a plural form. The entry may also
have one or more SI prefixes (e.g. "mega", "M").
null
. The unit
will account for any SI prefixes in the name.protected void ps(java.lang.String symbol, java.lang.String unitID)
protected void ps(java.lang.String symbol, Unit unit) throws UnitException
UnitException
protected void pn(java.lang.String name, Unit unit) throws UnitException
UnitException
protected void pn(java.lang.String name, java.lang.String unitID)
protected void px(java.lang.String name, Unit unit) throws UnitException
UnitException
protected void px(java.lang.String name, java.lang.String unitID)
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
- A problem occurred.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |