ucar.units
Class UnitName

java.lang.Object
  extended by ucar.units.UnitID
      extended by ucar.units.UnitName
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public final class UnitName
extends UnitID
implements java.lang.Comparable

Provides support for unit names.

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

Constructor Summary
protected UnitName(java.lang.String name, java.lang.String symbol)
          Constructs from a name and a symbol.
protected UnitName(java.lang.String name, java.lang.String plural, java.lang.String symbol)
          Constructs from a name, a plural form of the unit name, and a symbol.
 
Method Summary
 int compareTo(java.lang.Object object)
          Compares this UnitName with another UnitName.
 boolean equals(java.lang.Object object)
          Indicates if this UnitName is semantically identical to an object.
 java.lang.String getName()
          Returns the name.
 java.lang.String getPlural()
          Returns the plural form of the unit name.
 java.lang.String getSymbol()
          Returns the symbol.
protected  java.lang.String makePlural(java.lang.String name)
          Returns the plural form of a name.
static UnitName newUnitName(java.lang.String name)
          Factory method for constructing a UnitName from a name.
static UnitName newUnitName(java.lang.String name, java.lang.String plural)
          Factory method for constructing a UnitName from a name and a plural form of the name.
static UnitName newUnitName(java.lang.String name, java.lang.String plural, java.lang.String symbol)
          Factory method for constructing a UnitName from a name, a plural form of the name, and a symbol.
 java.lang.String toString()
          Returns the string representation of this identifier.
 
Methods inherited from class ucar.units.UnitID
newUnitID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnitName

protected UnitName(java.lang.String name,
                   java.lang.String symbol)
            throws NameException
Constructs from a name and a symbol. Regular rules are use to construct the plural form of the unit name.

Parameters:
name - The name of the unit. Shall not be null.
symbol - The symbol for the unit. May be null .
Throws:
NameException - name == null.

UnitName

protected UnitName(java.lang.String name,
                   java.lang.String plural,
                   java.lang.String symbol)
            throws NameException
Constructs from a name, a plural form of the unit name, and a symbol.

Parameters:
name - The name of the unit. Shall not be null.
plural - The plural form of the name. May be null, in which case regular plural- forming rules are used to construct the plural form from the name.
symbol - The symbol for the unit. May be null .
Throws:
NameException - name == null.
Method Detail

newUnitName

public static UnitName newUnitName(java.lang.String name)
                            throws NameException
Factory method for constructing a UnitName from a name.

Parameters:
name - The name of the unit. Shall not be null.
Throws:
NameException - name == null.

newUnitName

public static UnitName newUnitName(java.lang.String name,
                                   java.lang.String plural)
                            throws NameException
Factory method for constructing a UnitName from a name and a plural form of the name.

Parameters:
name - The name of the unit. Shall not be null.
plural - The plural form of the name. May be null, in which case regular plural- forming rules are used to construct the plural form from the name.
Throws:
NameException - name == null.

newUnitName

public static UnitName newUnitName(java.lang.String name,
                                   java.lang.String plural,
                                   java.lang.String symbol)
                            throws NameException
Factory method for constructing a UnitName from a name, a plural form of the name, and a symbol.

Parameters:
name - The name of the unit. Shall not be null.
plural - The plural form of the name. May be null, in which case regular plural- forming rules are used to construct the plural form from the name.
symbol - The symbol for the unit. May be null .
Throws:
NameException - name == null.

getName

public final java.lang.String getName()
Returns the name.

Specified by:
getName in class UnitID
Returns:
The name. Won't be null.

getPlural

public java.lang.String getPlural()
Returns the plural form of the unit name.

Specified by:
getPlural in class UnitID
Returns:
The plural form of the unit name.

getSymbol

public final java.lang.String getSymbol()
Returns the symbol.

Specified by:
getSymbol in class UnitID
Returns:
The symbol. Might be null.

toString

public final java.lang.String toString()
Returns the string representation of this identifier.

Specified by:
toString in class UnitID
Returns:
The string representation of this identifier.

compareTo

public final int compareTo(java.lang.Object object)
Compares this UnitName with another UnitName.

Specified by:
compareTo in interface java.lang.Comparable

equals

public final boolean equals(java.lang.Object object)
Indicates if this UnitName is semantically identical to an object.

Overrides:
equals in class java.lang.Object

makePlural

protected java.lang.String makePlural(java.lang.String name)
Returns the plural form of a name. Regular rules are used to generate the plural form.

Parameters:
name - The name.
Returns:
The plural form of the name.