|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.units.UnitDBImpl
public class UnitDBImpl
Provides most of a concrete implementation of a database of units.
Constructor Summary | |
---|---|
protected |
UnitDBImpl(int nameCount,
int symbolCount)
Constructs from the expected number of names and symbols. |
Method Summary | |
---|---|
void |
add(UnitDBImpl that)
Adds all the entries in another UnitDBImpl to this database. |
void |
addAlias(String alias,
String name)
Adds an alias for a unit already in the database. |
void |
addAlias(String alias,
String name,
String symbol)
Adds an alias for a unit already in the database. |
void |
addAlias(String alias,
String name,
String symbol,
String plural)
Adds an alias for a unit already in the database. |
void |
addAlias(UnitID alias,
String name)
Adds an alias for a unit already in the database. |
void |
addSymbol(String symbol,
String name)
Adds a symbol for a unit already in the database. |
void |
addUnit(Unit unit)
Adds a unit to the database. |
Unit |
get(String id)
Gets a unit by either name, plural, or symbol. |
Unit |
getByName(String name)
Gets a unit by name. |
Unit |
getBySymbol(String symbol)
Gets a unit by symbol. |
Iterator |
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. |
String |
toString()
Returns the string representation of this database. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected UnitDBImpl(int nameCount, int symbolCount)
nameCount
- The expected number of names (including plurals and aliases).symbolCount
- The expected number of symbols.Method Detail |
---|
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 UnitDB
unit
- 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(String alias, String name) throws NoSuchUnitException, UnitExistsException
addAlias
in interface UnitDB
alias
- 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(String alias, String name, String symbol) throws NoSuchUnitException, UnitExistsException
addAlias
in interface UnitDB
alias
- 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(String symbol, String name) throws NoSuchUnitException, UnitExistsException
addSymbol
in interface UnitDB
symbol
- 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(String alias, String name, String symbol, String plural) throws NoSuchUnitException, UnitExistsException
addAlias
in interface UnitDB
alias
- 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, String name) throws NoSuchUnitException, UnitExistsException
addAlias
in interface UnitDB
alias
- 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(String id)
get
in interface UnitDB
id
- The id to be matched.
null
if no such unit was found.public Unit getByName(String name)
getByName
in interface UnitDB
name
- The name to be matched.
null
if no such unit was found.public Unit getBySymbol(String symbol)
getBySymbol
in interface UnitDB
symbol
- The symbol to be matched.
null
if no such unit was
found.public String toString()
toString
in interface UnitDB
toString
in class Object
public final Iterator getIterator()
getIterator
in interface UnitDB
next()
method returns objects of type
Unit
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |