|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvisad.data.units.UnitTable
public class UnitTable
Provides support for a table of units.
| Constructor Summary | |
|---|---|
UnitTable(int numNames)
Construct. |
|
UnitTable(int numNames,
int numSymbols)
Construct. |
|
| Method Summary | |
|---|---|
Unit |
get(String name)
Get a unit. |
protected Unit |
getByName(String name)
Get a unit by name. |
protected Unit |
getBySymbol(String symbol)
Get a unit by symbol. |
Enumeration |
getNameEnumeration()
Get an enumeration of the unit names in the table. |
Enumeration |
getSymbolEnumeration()
Get an enumeration of the unit symbols in the table. |
Enumeration |
getUnitEnumeration()
Get an enumeration of the units in the table. |
void |
list()
List the units in the database. |
static void |
main(String[] args)
Test this class. |
protected String |
makePlural(String name)
Returns the plural form of a name. |
void |
put(BaseUnit unit)
Adds a base unit. |
void |
putName(String name,
Unit unit)
Adds a name and a unit to the name table. |
void |
putSymbol(String symbol,
Unit unit)
Adds a symbol and a unit to the symbol table. |
String |
toString()
Return a string representation of this instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public UnitTable(int numNames)
throws IllegalArgumentException
numNames - Anticipated minimum number of names in the
database.
IllegalArgumentException - numNames < 0.
public UnitTable(int numNames,
int numSymbols)
throws IllegalArgumentException
numNames - Anticipated minimum number of names in the
database.numSymbols - Anticipated minimum number of symbols in the
database.
IllegalArgumentException - numNames < 0 || numSymbols < 0
.| Method Detail |
|---|
public Unit get(String name)
get in interface UnitsDBname - The exact name of the unit to be retrieved. If it is
the empty string, then the dimensionless, unity
unit
will be returned.
name is non-null.protected Unit getByName(String name)
name - The name of the unit to be retrieved. If it is
the empty string, then the dimensionless, unity
unit
will be returned.
name is non-null.protected Unit getBySymbol(String symbol)
symbol - The exact symbol of the unit to be retrieved. If it is
the empty string, then the dimensionless, unity
unit
will be returned.
name is non-null.
public void put(BaseUnit unit)
throws IllegalArgumentException
put in interface UnitsDBunit - The base unit to be added.
IllegalArgumentException - The base unit argument is invalid.protected String makePlural(String name)
name - The name.
public void putName(String name,
Unit unit)
putName in interface UnitsDBname - The name to be added.unit - The unit to be added.
IllegalArgumentException - Invalid argument.
public void putSymbol(String symbol,
Unit unit)
putSymbol in interface UnitsDBsymbol - The symbol to be added.unit - The unit to be added.
IllegalArgumentException - Invalid argument.public Enumeration getNameEnumeration()
getNameEnumeration in interface UnitsDBpublic Enumeration getSymbolEnumeration()
getSymbolEnumeration in interface UnitsDBpublic Enumeration getUnitEnumeration()
getUnitEnumeration in interface UnitsDBpublic String toString()
toString in class Object
public static void main(String[] args)
throws Exception
Exception - A problem occurred.public void list()
list in interface UnitsDB
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||