Package ucar.units
Class PrefixDBImpl
- java.lang.Object
-
- ucar.units.PrefixDBImpl
-
- All Implemented Interfaces:
Serializable
,PrefixDB
- Direct Known Subclasses:
StandardPrefixDB
public class PrefixDBImpl extends Object implements PrefixDB, Serializable
Provides a concrete implementation of a database of unit prefixes. Instances of this class are modifiable.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PrefixDBImpl()
Constructs from nothing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addName(String name, double value)
Adds a prefix to the database by name.void
addSymbol(String symbol, double value)
Adds a prefix symbol to the database.Prefix
getPrefixByName(String string)
Gets a prefix by name.Prefix
getPrefixBySymbol(String string)
Gets a prefix by symbol.Prefix
getPrefixByValue(double value)
Gets a prefix by value.Iterator<Prefix>
iterator()
Gets an iterator over the prefixes in the database.String
toString()
Returns a string representation of this database.
-
-
-
Method Detail
-
addName
public void addName(String name, double value) throws PrefixExistsException
Adds a prefix to the database by name.- Specified by:
addName
in interfacePrefixDB
- Parameters:
name
- The name of the prefix to be added.value
- The value of the prefix.- Throws:
PrefixExistsException
- Another prefix with the same name or value already exists in the database.
-
addSymbol
public void addSymbol(String symbol, double value) throws PrefixExistsException
Adds a prefix symbol to the database.- Specified by:
addSymbol
in interfacePrefixDB
- Parameters:
symbol
- The symbol of the prefix to be added.value
- The value of the prefix.- Throws:
PrefixExistsException
- Another prefix with the same symbol or value already exists in the database.
-
getPrefixByName
public Prefix getPrefixByName(String string)
Gets a prefix by name.- Specified by:
getPrefixByName
in interfacePrefixDB
- Parameters:
string
- The name to be matched.- Returns:
- The prefix whose name matches or null.
-
getPrefixBySymbol
public Prefix getPrefixBySymbol(String string)
Gets a prefix by symbol.- Specified by:
getPrefixBySymbol
in interfacePrefixDB
- Parameters:
string
- The symbol to be matched.- Returns:
- The prefix whose symbol matches or null.
-
getPrefixByValue
public Prefix getPrefixByValue(double value)
Gets a prefix by value.- Specified by:
getPrefixByValue
in interfacePrefixDB
- Parameters:
value
- The value to be matched.- Returns:
- The prefix whose value matches or null.
-
toString
public String toString()
Returns a string representation of this database.
-
-