org.jcreme.enumerations
Class Enumeration

java.lang.Object
  extended byorg.jcreme.enumerations.Enumeration
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
AccessType, CachePolicy, ComparatorType, ComparisonOperator, Domain, IsolationLevel, ObjectType, Purpose, Role, SortOrder, Subject, TableColorModelType, TableColumnType, Task, User

public abstract class Enumeration
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

This is the base class for enumerated types. It presents an id (Integer) that may be used to different purpose and a name (String) that enables to handle inputs and outputs of the values. Both are unique for an Enumeration subclass instances. To ensure this uniqueness, subclasses must enable access to two hashtables. One links the names to the enumerated values, the other links the id to the enumerated value.

Version:
$Revision: 1.3 $
Author:
$Author: dbregeon $
See Also:
Serialized Form

Field Summary
(package private) static long serialVersionUID
           
 
Constructor Summary
protected Enumeration(java.lang.String name)
          Creates new Enumeration
 
Method Summary
 int compareTo(java.lang.Object o)
          This method enables to compare two enmerated values.
protected abstract  java.util.Hashtable getFromName()
          This method is for internal use only.
 java.lang.String getName()
           
static Enumeration[] getValues()
          This method enables to retrieve all the possible values of an Enumeration class.
protected  java.lang.Object readResolve()
          This method enables to ensure the uniqueness of an Enumeration value.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

Enumeration

protected Enumeration(java.lang.String name)
               throws java.security.InvalidParameterException
Creates new Enumeration

Parameters:
name - the name of this enumerated value. It cannot be null.
Throws:
java.security.InvalidParameterException - if one of the parameters is null.
Method Detail

getName

public java.lang.String getName()
Returns:
the name of the enumerated value.

toString

public java.lang.String toString()
Returns:
a String representation (actually the name).

compareTo

public int compareTo(java.lang.Object o)
This method enables to compare two enmerated values. The purpose of this method is to enable to sort the values in alphabetical order when displayed.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the object to compare. It must be an Enumeration instance.
Returns:
the result of the toString results comparison.
Throws:
java.lang.ClassCastException - if the parameter is not an Enumeration instance.

getFromName

protected abstract java.util.Hashtable getFromName()
This method is for internal use only.

Returns:
the Hashtable that links the enumerated values names with the actual enumerated value.

getValues

public static Enumeration[] getValues()
This method enables to retrieve all the possible values of an Enumeration class. This method should be overriden in the subclasses to have the desired result. The method in this class returns an empty array.

Returns:
the values for this class.

readResolve

protected java.lang.Object readResolve()
This method enables to ensure the uniqueness of an Enumeration value. This method is called on a newly created Enumeration whenever an Enumeration is received on an ObjectStream. The unique value in the VM is then returned. If no value already exists, a new one is created. Priority is given to the name to retrieve the existing value.

Returns:
the value associated with the transmitted value.


Copyright 2006 null. All Rights Reserved.