|
Web Site | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.janino.util.enumerator.Enumerator
A class that represents an enumerated value. Its main feature is its
toString()
method, which reconstructs the clear text value
through reflection.
To use this class, derive from it and define one or more
public static final
fields, as follows:
public class Color extends Enumerator { public static final Color RED = new Color(0); public static final Color GREEN = new Color(1); public static final Color BLUE = new Color(2); public Color(String s) throws EnumeratorFormatException { super(s); } private Color(int value) { super(value); } }
Constructor Summary | |
protected |
Enumerator(int value)
Initialize the enumerator to the given value. |
protected |
Enumerator(String s)
Initialize an Enumerator from a string. |
Method Summary | |
boolean |
equals(Object that)
Check the object's value |
int |
hashCode()
|
String |
toString()
Convert an Enumerator into a clear-text string. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected Enumerator(int value)
protected Enumerator(String s) throws EnumeratorFormatException
Enumerator
from a string.
The given string is converted into a value by looking at the class's
public static final
fields which have the same type as the class itself.
EnumeratorFormatException
- if the string cannot be identifiedMethod Detail |
public boolean equals(Object that)
public int hashCode()
public String toString()
Enumerator
into a clear-text string.
Examine the object through reflection for public static final
fields that have the same type as this object, and return the name of the fields who's value
matches the object's value.
|
Web Site | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |