|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.japano.util.Enum
public class Enum
Base class for serialization-safe Enum-Classes.
Classes which are derived from this base class should have only private Constructors and should define all possible instances as public final static members.
Example:
This Enum implementation is used instead of java 1.5 enums to keep the japano
core java 1.4 compatible.
public class Color extends org.japano.util.Enum
{
public final static Color RED=new Color("red");
public final static Color BLUE=new Color("blue");
private Color(String name)
{
super(name);
}
}
| Constructor Summary | |
|---|---|
protected |
Enum(java.lang.Object identifier)
Creates a new enum instance. |
| Method Summary | |
|---|---|
protected static Enum |
fromIdentifier(java.lang.Class klass,
java.lang.Object identifier)
Returns the enum instance with the given identifier and the given type. |
protected java.lang.Object |
getIdentifier()
Returns the identifier of this enum instance |
int |
hashCode()
Returns the identifier's hashcode as hashcode of this enum instance. |
static java.util.Iterator |
instances(java.lang.Class klass)
Returns an iterator over all enum instances of the given type. |
protected java.lang.Object |
readResolve()
Replaces a deserialized enum instance with an already existing instance of the same type with the same identifier |
java.lang.String |
toString()
Returns a string representation of this enum instance |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected Enum(java.lang.Object identifier)
identifier - unique indentifier within all instances of the same type| Method Detail |
|---|
protected static Enum fromIdentifier(java.lang.Class klass,
java.lang.Object identifier)
java.lang.IllegalArgumentException - if no such instance existspublic static java.util.Iterator instances(java.lang.Class klass)
klass - type
protected java.lang.Object getIdentifier()
protected java.lang.Object readResolve()
throws java.io.InvalidObjectException
java.io.InvalidObjectException - if no such replacement exists.public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||