public class UnitDBImpl extends java.lang.Object implements UnitDB, java.io.Serializable
| Modifier | Constructor and Description |
|---|---|
protected |
UnitDBImpl(int nameCount,
int symbolCount)
Constructs from the expected number of names and symbols.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(UnitDBImpl that)
Adds all the entries in another UnitDBImpl to this database.
|
void |
addAlias(java.lang.String alias,
java.lang.String name)
Adds an alias for a unit already in the database.
|
void |
addAlias(java.lang.String alias,
java.lang.String name,
java.lang.String symbol)
Adds an alias for a unit already in the database.
|
void |
addAlias(java.lang.String alias,
java.lang.String name,
java.lang.String symbol,
java.lang.String plural)
Adds an alias for a unit already in the database.
|
void |
addAlias(UnitID alias,
java.lang.String name)
Adds an alias for a unit already in the database.
|
void |
addSymbol(java.lang.String symbol,
java.lang.String name)
Adds a symbol for a unit already in the database.
|
void |
addUnit(Unit unit)
Adds a unit to the database.
|
Unit |
get(java.lang.String id)
Gets a unit by either name, plural, or symbol.
|
Unit |
getByName(java.lang.String name)
Gets a unit by name.
|
Unit |
getBySymbol(java.lang.String symbol)
Gets a unit by symbol.
|
java.util.Iterator<Unit> |
getIterator()
Gets an iterator over the units in the database.
|
int |
nameCount()
Return the number of names in this database
|
int |
symbolCount()
Return the number of symbols in this database.
|
java.lang.String |
toString()
Returns the string representation of this database.
|
protected UnitDBImpl(int nameCount,
int symbolCount)
nameCount - The expected number of names (including plurals and aliases).symbolCount - The expected number of symbols.public void add(UnitDBImpl that) throws UnitExistsException
that - The other UnitDBImpl.UnitExistsException - Attempt to redefine an existing entry.public int nameCount()
public int symbolCount()
public void addUnit(Unit unit) throws UnitExistsException, NameException
addUnit in interface UnitDBunit - The unit to be added.UnitExistsException - Another unit with the same name or symbol already exists in
the database.NameException - Bad unit name.public final void addAlias(java.lang.String alias,
java.lang.String name)
throws NoSuchUnitException,
UnitExistsException
addAlias in interface UnitDBalias - An alias for the unit.name - The name of the unit already in the database.UnitExistsException - Another unit with the same name or symbol already exists in
the database.NoSuchUnitException - The unit isn't in the database.public final void addAlias(java.lang.String alias,
java.lang.String name,
java.lang.String symbol)
throws NoSuchUnitException,
UnitExistsException
addAlias in interface UnitDBalias - An alias for the unit.name - The name of the unit already in the database.symbol - The symbol for the unit.UnitExistsException - Another unit with the same name or symbol already exists in
the database.NoSuchUnitException - The unit isn't in the database.public final void addSymbol(java.lang.String symbol,
java.lang.String name)
throws NoSuchUnitException,
UnitExistsException
addSymbol in interface UnitDBsymbol - The symbol for the unit.name - The name of the unit already in the database.UnitExistsException - Another unit with the same name or symbol already exists in
the database.NoSuchUnitException - The unit isn't in the database.public final void addAlias(java.lang.String alias,
java.lang.String name,
java.lang.String symbol,
java.lang.String plural)
throws NoSuchUnitException,
UnitExistsException
addAlias in interface UnitDBalias - The alias to be added to the database. May be null.name - The name of the unit to have an alias added to the database.symbol - The symbol to be added. May be null.plural - The plural form of the alias. If null
, then regular
plural-forming rules are followed.NoSuchUnitException - The unit is not in the database.UnitExistsException - Another unit with the same alias is already in the database.public final void addAlias(UnitID alias, java.lang.String name) throws NoSuchUnitException, UnitExistsException
addAlias in interface UnitDBalias - The alias to be added to the database.name - The name of the unit to have an alias added to the database.NoSuchUnitException - The unit is not in the database.UnitExistsException - Another unit with the same alias is already in the database.public Unit get(java.lang.String id)
public Unit getByName(java.lang.String name)
public Unit getBySymbol(java.lang.String symbol)
getBySymbol in interface UnitDBsymbol - The symbol to be matched.null
if no such unit was
found.public java.lang.String toString()
public final java.util.Iterator<Unit> getIterator()
getIterator in interface UnitDBnext() method returns objects of type
Unit.