public class UnitTable extends Object implements UnitsDB, Serializable
Constructor and Description |
---|
UnitTable(int numNames)
Construct.
|
UnitTable(int numNames,
int numSymbols)
Construct.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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
.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.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.public void put(BaseUnit unit) throws IllegalArgumentException
put
in interface UnitsDB
unit
- 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 UnitsDB
name
- The name to be added.unit
- The unit to be added.IllegalArgumentException
- Invalid argument.public void putSymbol(String symbol, Unit unit)
putSymbol
in interface UnitsDB
symbol
- The symbol to be added.unit
- The unit to be added.IllegalArgumentException
- Invalid argument.public Enumeration getNameEnumeration()
getNameEnumeration
in interface UnitsDB
public Enumeration getSymbolEnumeration()
getSymbolEnumeration
in interface UnitsDB
public Enumeration getUnitEnumeration()
getUnitEnumeration
in interface UnitsDB
public String toString()
public static void main(String[] args) throws Exception
Exception
- A problem occurred.Copyright © 1996–2023 The SSEC Visualization Project. All rights reserved.