Package ucar.units
Interface UnitDB
-
- All Known Implementing Classes:
StandardUnitDB
,UnitDBImpl
public interface UnitDB
Interface for a unit database.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addAlias(String alias, String name)
Adds an alias for a unit to the database.void
addAlias(String alias, String name, String symbol)
Adds an alias for a unit to the database.void
addAlias(String alias, String name, String symbol, String plural)
Adds an alias for a unit to the database.void
addAlias(UnitID id, String name)
Adds an alias for a unit to the database.void
addSymbol(String symbol, String name)
Adds a symbol for a unit to the database.void
addUnit(Unit unit)
Adds a unit to the database.Unit
get(String id)
Gets the unit in the database whose name, plural, or symbol, match an identifier.Unit
getByName(String name)
Gets a unit in the database by name.Unit
getBySymbol(String symbol)
Gets a unit in the database by symbol.Iterator<?>
getIterator()
Returns an iterator over the units of the database.String
toString()
Returns the string representation of the database.
-
-
-
Method Detail
-
addUnit
void addUnit(Unit unit) throws UnitExistsException, UnitDBAccessException, NameException
Adds a unit to the database.- Parameters:
unit
- The unit to be added. Its getName() method must not return null. Its getPlural() and getSymbol() methods may return null.- Throws:
NameException
- Bad unit name.UnitExistsException
- The unit is already in the database.UnitDBAccessException
- Problem accessing unit database.
-
addAlias
void addAlias(String alias, String name) throws NoSuchUnitException, UnitExistsException, UnitDBAccessException, NameException
Adds an alias for a unit to the database.- Parameters:
alias
- The alias for the unit.name
- The name of the unit already in the database.- Throws:
NameException
- Bad unit name.UnitExistsException
- The unit is already in the database.UnitDBAccessException
- Problem accessing unit database.NoSuchUnitException
- The unit doesn't exist in the database.
-
addAlias
void addAlias(String alias, String name, String symbol) throws NoSuchUnitException, UnitExistsException, UnitDBAccessException, NameException
Adds an alias for a unit to the database.- Parameters:
alias
- The alias for the unit.name
- The name of the unit already in the database.symbol
- The symbol for the unit.- Throws:
NameException
- Bad unit name.UnitExistsException
- The unit is already in the database.UnitDBAccessException
- Problem accessing unit database.NoSuchUnitException
- The unit doesn't exist in the database.
-
addAlias
void addAlias(String alias, String name, String symbol, String plural) throws NoSuchUnitException, UnitExistsException, UnitDBAccessException, NameException
Adds an alias for a unit to the database.- Parameters:
alias
- The alias for the unit.name
- The name of the unit already in the database.symbol
- The symbol of the alias. May benull
.plural
- The plural form of the alias. May benull
in which case regular plural- forming rules are followed.- Throws:
NameException
- Bad unit name.UnitExistsException
- The unit is already in the database.UnitDBAccessException
- Problem accessing unit database.NoSuchUnitException
- The unit doesn't exist in the database.
-
addAlias
void addAlias(UnitID id, String name) throws NoSuchUnitException, UnitExistsException, UnitDBAccessException
Adds an alias for a unit to the database.- Parameters:
id
- The alias identifier.name
- The name of the unit already in the database.- Throws:
NoSuchUnitException
- The unit doesn't exist in the database.UnitExistsException
- The unit is already in the database.UnitDBAccessException
- Problem accessing unit database.
-
addSymbol
void addSymbol(String symbol, String name) throws NoSuchUnitException, UnitExistsException, UnitDBAccessException, NameException
Adds a symbol for a unit to the database.- Parameters:
symbol
- The symbol for the unit.name
- The name of the unit already in the database.- Throws:
NameException
- Bad unit name.UnitExistsException
- The unit is already in the database.UnitDBAccessException
- Problem accessing unit database.NoSuchUnitException
- The unit doesn't exist in the database.
-
get
Unit get(String id) throws UnitDBAccessException
Gets the unit in the database whose name, plural, or symbol, match an identifier. The order of matching is implementation defined.- Parameters:
id
- The identifier for the unit.- Returns:
- The matching unit in the database or
null
if no matching unit could be found. - Throws:
UnitDBAccessException
- Problem accessing unit database.
-
getByName
Unit getByName(String name) throws UnitDBAccessException
Gets a unit in the database by name.- Parameters:
name
- The name of the unit.- Returns:
- The matching unit in the database or
null
if no matching unit could be found. - Throws:
UnitDBAccessException
- Problem accessing unit database.
-
getBySymbol
Unit getBySymbol(String symbol) throws UnitDBAccessException
Gets a unit in the database by symbol.- Parameters:
symbol
- The symbol for the unit.- Returns:
- The matching unit in the database or
null
if no matching unit could be found. - Throws:
UnitDBAccessException
- Problem accessing unit database.
-
toString
String toString()
Returns the string representation of the database.
-
getIterator
Iterator<?> getIterator()
Returns an iterator over the units of the database.- Returns:
- An iterator over the units of the database. The
next()
of the iterator returns objects of typeUnit
.
-
-