visad.data.netcdf
Class QuantityDBImpl

java.lang.Object
  extended by visad.data.netcdf.QuantityDB
      extended by visad.data.netcdf.QuantityDBImpl
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
StandardQuantityDB

public class QuantityDBImpl
extends QuantityDB
implements Serializable

Provides support for a database of quantities. Instances are modifiable.

Author:
Steven R. Emmerson
See Also:
Serialized Form

Nested Class Summary
protected  class QuantityDBImpl.Iterator
          Provides support for iterating over the database.
protected  class QuantityDBImpl.NameIterator
          Provides support for iterating over the names in the database.
protected static class QuantityDBImpl.NameKey
          Provides support for keys to the name map.
protected  class QuantityDBImpl.QuantityIterator
          Provides support for iterating over the quantities in the database.
protected static class QuantityDBImpl.UnitKey
          Provides support for keys to the unit map.
 
Field Summary
 
Fields inherited from class visad.data.netcdf.QuantityDB
emptyDB
 
Constructor Summary
QuantityDBImpl(QuantityDB nextDB)
          Constructs with another quantity database as the successor database.
 
Method Summary
 QuantityDB add(Quantity[] quantities)
          Adds given Quantity-s to the database.
 QuantityDB add(String[] definitions, String[] aliases)
          Adds the given quantities and aliases to the database.
 void add(String name, Quantity quantity)
          Adds a quantity to the database under a given name.
protected  void add(String name, String unitSpec)
          Adds a quantity to the database given a name and a display unit specification.
 Quantity get(String name)
          Returns the quantity in the database whose name matches a given name.
 Quantity[] get(Unit unit)
          Returns all quantities in the database whose default unit is convertible with a given unit.
 Iterator nameIterator()
          Returns an iterator of the names in the database.
 Iterator quantityIterator()
          Returns an iterator of the quantities in the database.
 
Methods inherited from class visad.data.netcdf.QuantityDB
add, get
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuantityDBImpl

public QuantityDBImpl(QuantityDB nextDB)
Constructs with another quantity database as the successor database.

Parameters:
nextDB - The quantity database to search after this one. May be null.
Method Detail

add

public QuantityDB add(String[] definitions,
                      String[] aliases)
               throws ParseException,
                      TypeException,
                      VisADException
Adds the given quantities and aliases to the database.

Parameters:
definitions - New quantities and their definitions. definitions[2*i] contains the name (e.g. "speed") of the quantity whose preferred unit specification (e.g. "m/s") is in definitions[2*i+1].
aliases - Aliases for quantities. aliases[2*i] contains the alias for the quantity named in aliases[2*i+1].
Returns:
The database resulting from the addition. May or may not be the original object.
Throws:
ParseException - A unit specification couldn't be parsed.
TypeException - An incompatible version of the quantity already exists.
VisADException - Couldn't create necessary VisAD object.

add

public void add(String name,
                Quantity quantity)
         throws VisADException
Adds a quantity to the database under a given name.

Specified by:
add in class QuantityDB
Parameters:
name - The name of the quantity (e.g. "length"). May be an alias for the quantity.
quantity - The quantity.
Throws:
VisADException - Couldn't create necessary VisAD object.

add

public QuantityDB add(Quantity[] quantities)
               throws VisADException
Adds given Quantity-s to the database.

Parameters:
quantities - The quantities to be added. The quantity will be added under it own name.
Returns:
The database resulting from the addition. May or may not be the original object.
Throws:
VisADException - Couldn't create necessary VisAD object.

add

protected void add(String name,
                   String unitSpec)
            throws ParseException,
                   TypeException,
                   VisADException
Adds a quantity to the database given a name and a display unit specification.

Parameters:
name - The name of the quantity (e.g. "length").
unitSpec - The preferred display unit for the quantity (e.g. "feet").
Throws:
ParseException - Couldn't decode unit specification.
TypeException - Incompatible ScalarType of same name already exists.
VisADException - Couldn't create necessary VisAD object.

quantityIterator

public Iterator quantityIterator()
Returns an iterator of the quantities in the database.

Specified by:
quantityIterator in class QuantityDB
Returns:
An iterator of the quantities in the database.

nameIterator

public Iterator nameIterator()
Returns an iterator of the names in the database.

Specified by:
nameIterator in class QuantityDB
Returns:
An iterator of the names in the database.

get

public Quantity get(String name)
Returns the quantity in the database whose name matches a given name.

Specified by:
get in class QuantityDB
Parameters:
name - The name of the quantity.
Returns:
The quantity in the loal database with name name.

get

public Quantity[] get(Unit unit)
Returns all quantities in the database whose default unit is convertible with a given unit.

Specified by:
get in class QuantityDB
Parameters:
unit - The unit of the quantity.
Returns:
The quantities in the database whose unit is convertible with unit.