visad.data.netcdf
Class Quantity

java.lang.Object
  extended by visad.MathType
      extended by visad.ScalarType
          extended by visad.RealType
              extended by visad.data.netcdf.Quantity
All Implemented Interfaces:
Serializable, Comparable

public class Quantity
extends RealType

The following class represents a quantity -- usually a physical one such as energy, viscosity, or velocity (although an artificial one such as "money" should be possible). It extends RealType by carrying around a preferred unit as a string because a Unit is useless for doing that. A Quantity is immutable.

Author:
Steven R. Emmerson
See Also:
Serialized Form

Field Summary
protected  String unitSpec
          The specification of the preferred unit of the quantity.
 
Fields inherited from class visad.RealType
Altitude, Declination, Generic, INTERVAL, Latitude, Longitude, Radius, RightAscension, Time, TimeInterval, XAxis, YAxis, ZAxis
 
Constructor Summary
Quantity(String name, String unitSpec)
          Constructs from a name and a unit specification.
Quantity(String name, String unitSpec, SimpleSet set)
          Constructs from a name, a unit specification, and a sample set.
 
Method Summary
 String getDefaultUnitString()
          Return the default unit of this quantity as a string.
static Quantity getQuantity(String name, String unitSpec)
          create a new Quantity, or return it if it already exists
static Quantity getQuantity(String name, String unitSpec, SimpleSet set)
          create a new Quantity, or return it if it already exists
static Quantity getQuantityByName(String name)
          return any Quantity constructed in this JVM with name, or null
 
Methods inherited from class visad.RealType
binary, buildShadowType, cloneDerivative, equals, equalsExceptName, equalsExceptNameButUnits, getAttributeMask, getDefaultSet, getDefaultUnit, getRealType, getRealType, getRealType, getRealType, getRealType, getRealType, getRealTypeByName, isInterval, main, missingData, prettyString, setDefaultSet, unary
 
Methods inherited from class visad.ScalarType
alias, compareTo, getAlias, getName, getNameWithBlanks, getOriginalName, getScalarTypeByName, hashCode, readResolve, validateName
 
Methods inherited from class visad.MathType
addTimeAlias, findScalarType, guessMaps, prettyString, stringToType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

unitSpec

protected final String unitSpec
The specification of the preferred unit of the quantity.

Constructor Detail

Quantity

public Quantity(String name,
                String unitSpec,
                SimpleSet set)
         throws VisADException,
                ParseException
Constructs from a name, a unit specification, and a sample set.

Parameters:
name - The name of the quantity (e.g. "length").
unitSpec - The preferred unit for the quantity (e.g. "feet").
set - The default sample set for the quantity. May be null.
Throws:
ParseException - Couldn't decode unit specification.
VisADException - ScalarType of same name already exists.

Quantity

public Quantity(String name,
                String unitSpec)
         throws VisADException,
                ParseException
Constructs from a name and a unit specification.

Parameters:
name - The name of the quantity (e.g. "length").
unitSpec - The preferred unit for the quantity (e.g. "feet").
Throws:
VisADException - Can't create necessary VisAD object.
ParseException - Couldn't decode unit specification.
Method Detail

getDefaultUnitString

public String getDefaultUnitString()
Return the default unit of this quantity as a string.

Returns:
The default unit of this quantity or null if no such unit.

getQuantity

public static Quantity getQuantity(String name,
                                   String unitSpec,
                                   SimpleSet set)
                            throws ParseException
create a new Quantity, or return it if it already exists

Throws:
ParseException

getQuantity

public static Quantity getQuantity(String name,
                                   String unitSpec)
                            throws ParseException
create a new Quantity, or return it if it already exists

Throws:
ParseException

getQuantityByName

public static Quantity getQuantityByName(String name)
return any Quantity constructed in this JVM with name, or null