visad
Class BaseQuantity

java.lang.Object
  extended by visad.BaseQuantity
All Implemented Interfaces:
Serializable

public final class BaseQuantity
extends Object
implements Serializable

This class represents a base quantity (e.g. "length"). This class is mutable but monotonic: new base quantities can be added but not removed.

See Also:
Serialized Form

Method Summary
static BaseQuantity add(String name)
          Add a base quantity to the database.
static BaseQuantity add(String name, String alias)
          Add a base quantity with an alias to the database.
static BaseQuantity add(String name, String[] aliases)
          Add a base quantity with aliases to the database.
static BaseQuantity get(int i)
          Retrieve the base quantity associated with a given index.
static BaseQuantity get(String name)
          Retrieve a base quantity from the database based on a match of either the name or an alias.
static BaseQuantity getByAlias(String name)
          Retrieve a base quantity from the database based on a match of an alias.
static BaseQuantity getByName(String name)
          Retrieve a base quantity from the database based on a match of the name.
 int getIndex()
          Return the index of this base quantity.
 String getName()
          Return the name of this base quantity.
static int size()
          Return the number of base qantities in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public static BaseQuantity add(String name)
                        throws VisADException
Add a base quantity to the database.

Parameters:
name - The name of the base quantity.
Throws:
VisADException - Attempt to redefine an existing base quantity.
Precondition:
name isn't already in the database.

add

public static BaseQuantity add(String name,
                               String alias)
                        throws VisADException
Add a base quantity with an alias to the database.

Parameters:
name - The name of the base quantity being added to the database (e.g. "plane angle", "foobility").
alias - An alias for the base quantity (e.g. "angle").
Returns:
A reference to the new base quantity in the database.
Throws:
VisADException - Attempt to redefine an existing base quantity or alias. If thrown, then the database is unmodified.
Precondition:
Neither name nor alias is in the database.

add

public static BaseQuantity add(String name,
                               String[] aliases)
                        throws VisADException
Add a base quantity with aliases to the database.

Parameters:
name - The name of the base quantity being added to the database (e.g. "plane angle", "foobility").
aliases - Aliases for the base quantity (e.g. "angle").
Returns:
A reference to the new base quantity in the database.
Throws:
VisADException - Attempt to redefine an existing base quantity or alias. If thrown, then the database is unmodified.
Precondition:
Neither name nor any name in aliases is in the database.
Postcondition:
size() will return one greater than on entry.

size

public static int size()
Return the number of base qantities in the database.

Returns:
The current number of base quantities in the database. This number is strictly monotonic: it will increase by one each time a new base quantity is added to the database.

getName

public String getName()
Return the name of this base quantity.

Returns:
The name of this base quantity.

getIndex

public int getIndex()
Return the index of this base quantity.

Returns:
The index of this base quantity.

getByName

public static BaseQuantity getByName(String name)
Retrieve a base quantity from the database based on a match of the name.

Parameters:
name - The name of the base quantity to be retrieved.
Returns:
The base quantity in the database corresponding to name or null if no such quantity exists.

getByAlias

public static BaseQuantity getByAlias(String name)
Retrieve a base quantity from the database based on a match of an alias.

Parameters:
name - An alias of the base quantity to be retrieved.
Returns:
The base quantity in the database corresponding to name or null if no such quantity exists.

get

public static BaseQuantity get(String name)
Retrieve a base quantity from the database based on a match of either the name or an alias. Try the name first.

Parameters:
name - The name or an alias of the base quantity to be retrieved.
Returns:
The base quantity in the database corresponding to name or null if no such quantity exists.

get

public static BaseQuantity get(int i)
Retrieve the base quantity associated with a given index.

Parameters:
i - The origin-0 index of the base quantity.
Returns:
The base quantity at index i.
Precondition:
i >= 0 && i < size().