dsto.dfc.util
Class StringEnumerationValue

java.lang.Object
  extended by dsto.dfc.util.AbstractEnumerationValue
      extended by dsto.dfc.util.StringEnumerationValue
All Implemented Interfaces:
EnumerationValue, Serializable
Direct Known Subclasses:
IconicEnumerationValue, IconicEnumerationValue

public abstract class StringEnumerationValue
extends AbstractEnumerationValue
implements EnumerationValue, Serializable

Base class for enumerated types that have a string representation. Provides sensible defaults for toString(), hashCode() and equals(). Also provides intelligent serialization support via a readResolve () that resolves serialized enum values to their equivalent instance in getEnumValues (). Superclasses that wish to use this feature must provide a readResolve() implementation that calls super.readResolve().

Version:
$Revision$
See Also:
Serialized Form

Field Summary
protected  String name
           
protected  String text
           
 
Constructor Summary
StringEnumerationValue()
          For beans compliance only.
StringEnumerationValue(String name)
          Create a new string enumeration value.
StringEnumerationValue(String name, String text)
          Create a new string enumeration value.
 
Method Summary
 boolean equals(Object o)
           
 int findIndex(String enumName)
          Find the index of an enum value with a given name.
 EnumerationValue findValue(String enumName)
          Find the enumeration value with a given name.
abstract  EnumerationValue[] getEnumValues()
          Get the list of values within the enumeration.
 String getName()
           
 String getText()
          Get the human readable text for the value.
 int hashCode()
           
 void setName(String newValue)
          Use only during construction.
 String toString()
           
 
Methods inherited from class dsto.dfc.util.AbstractEnumerationValue
findIndex, findIndex, readResolve
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

text

protected transient String text
Constructor Detail

StringEnumerationValue

public StringEnumerationValue()
For beans compliance only.


StringEnumerationValue

public StringEnumerationValue(String name)
Create a new string enumeration value.

Parameters:
name - The human readable name of the value.
See Also:
StringEnumerationValue(String,String)

StringEnumerationValue

public StringEnumerationValue(String name,
                              String text)
Create a new string enumeration value.

Parameters:
name - The logical name of the value.
text - The human readable text for the value. The text may change without affecting the identity of the value, which is determined by the name property.
See Also:
StringEnumerationValue(String,String)
Method Detail

getEnumValues

public abstract EnumerationValue[] getEnumValues()
Description copied from interface: EnumerationValue
Get the list of values within the enumeration.

Specified by:
getEnumValues in interface EnumerationValue
Specified by:
getEnumValues in class AbstractEnumerationValue

findValue

public EnumerationValue findValue(String enumName)
Find the enumeration value with a given name.

Parameters:
enumName - The name to find.
Returns:
The matching value, or null if not found.

findIndex

public int findIndex(String enumName)
Find the index of an enum value with a given name.

Parameters:
enumName - The name to find.
Returns:
The index of the matching value in the enum values array, or -1 if not found.

getName

public String getName()

setName

public void setName(String newValue)
Use only during construction.


getText

public String getText()
Get the human readable text for the value.


toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class AbstractEnumerationValue


Copyright © 2008 Commonwealth of Australia