ucar.units
Class PrefixDBImpl

java.lang.Object
  extended by 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.

Version:
$Id: PrefixDBImpl.java 64 2006-07-12 22:30:50Z edavis $
Author:
Steven R. Emmerson
See Also:
Serialized Form

Constructor Summary
PrefixDBImpl()
          Constructs from nothing.
 
Method Summary
 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 iterator()
          Gets an iterator over the prefixes in the database.
static void main(String[] args)
          Tests this class.
 String toString()
          Returns a string representation of this database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrefixDBImpl

public PrefixDBImpl()
Constructs from nothing.

Method Detail

addName

public void addName(String name,
                    double value)
             throws PrefixExistsException
Adds a prefix to the database by name.

Specified by:
addName in interface PrefixDB
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 interface PrefixDB
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 interface PrefixDB
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 interface PrefixDB
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 interface PrefixDB
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.

Specified by:
toString in interface PrefixDB
Overrides:
toString in class Object
Returns:
A string representation of this database.

iterator

public Iterator iterator()
Gets an iterator over the prefixes in the database.

Specified by:
iterator in interface PrefixDB
Returns:
An iterator over the entries in the database. The objects returned by the iterator will be of type Prefix.

main

public static void main(String[] args)
                 throws Exception
Tests this class.

Throws:
Exception


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.