Save This Page
Home » openjdk-7 » net.sf.eBus » util » [javadoc | source]
net.sf.eBus.util
abstract public class: Enum [javadoc | source]
java.lang.Object
   net.sf.eBus.util.Enum

All Implemented Interfaces:
    Serializable, Comparable

Direct Known Subclasses:
    OpEnum, PriceType, MessageTypeEnum, ConnectStateEnum, SystemStatusEnum, ReportFrequencyEnum, Participant, DataTypeEnum

This is the base class for all enumerated classes. Subclasses are expected to create a java.lang.Map and an array to store the enumerated objects in the map using the object name as key and in the array using the object ordinal as the array index.

Extending Enum

Classes extending Enum should provide the following:

See net.sf.eBus.util.logging.ReportFrequencyEnum for an Enum example.

Serializing an Enum

Because all enumerated objects are statically instantiated and applications depending on == working for two separate references to the same enumeration object, serialization must reuse those existing enumeration objects and not create new ones. If you are extending Enum and need to serialize your enumeration objects, then do the following:

Field Summary
protected final transient  String _name    The enumerated object's unique name. 
protected final  Integer _ordinal    The enumerated object's unique integer index.
    serial: include -
 
Constructor:
 protected Enum(String name,
    int ordinal) 
    Sets the enumerated object's name and ordinal value.
    Parameters:
    name - the object's unique name.
    ordinal - the object's unique integer index.
Method from net.sf.eBus.util.Enum Summary:
compareTo,   equals,   getName,   getOrdinal,   hashCode,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from net.sf.eBus.util.Enum Detail:
 public int compareTo(Object obj) 
    Returns a value less than, equal to or greater than 0 if this Enum is less than, equal to or greater than obj.
 public boolean equals(Object obj) 
    Returns true if obj is equal to this ClassTypeEnum and false otherwise.
 public String getName() 
    Returns the enum's textual name.
 public int getOrdinal() 
    Returns this enum's ordinal value.
 public int hashCode() 
    Returns the ordinal value as the hash code.
 public String toString() 
    Returns the enum name.