ucar.units
Class UnitName

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

public final class UnitName
extends UnitID
implements Comparable<Object>

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(String name, String symbol)
          Constructs from a name and a symbol.
protected UnitName(String name, String plural, String symbol)
          Constructs from a name, a plural form of the unit name, and a symbol.
 
Method Summary
 int compareTo(Object object)
          Compares this UnitName with another UnitName.
 boolean equals(Object object)
          Indicates if this UnitName is semantically identical to an object.
 String getName()
          Returns the name.
 String getPlural()
          Returns the plural form of the unit name.
 String getSymbol()
          Returns the symbol.
 int hashCode()
          Returns the hash code of this instance.
protected  String makePlural(String name)
          Returns the plural form of a name.
static UnitName newUnitName(String name)
          Factory method for constructing a UnitName from a name.
static UnitName newUnitName(String name, String plural)
          Factory method for constructing a UnitName from a name and a plural form of the name.
static UnitName newUnitName(String name, String plural, String symbol)
          Factory method for constructing a UnitName from a name, a plural form of the name, and a symbol.
 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, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnitName

protected UnitName(String name,
                   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(String name,
                   String plural,
                   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(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(String name,
                                   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(String name,
                                   String plural,
                                   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 String getName()
Returns the name.

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

getPlural

public 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 String getSymbol()
Returns the symbol.

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

toString

public final 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(Object object)
Compares this UnitName with another UnitName.

Specified by:
compareTo in interface Comparable<Object>

equals

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

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hash code of this instance.

Overrides:
hashCode in class Object
Returns:
The hash code of this instance.

makePlural

protected String makePlural(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.


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