org.jurvis.patterns
Class JvEnumerator

java.lang.Object
  extended by org.jurvis.patterns.JvEnumerator
All Implemented Interfaces:
Serializable

public abstract class JvEnumerator
extends Object
implements Serializable

Base class for enumerators within a C++ style enumeration. Derived classes are expected to define each of the enumerators as public and static members of the derived class.

Author:
Neil W. Weber
See Also:
Serialized Form

Constructor Summary
protected JvEnumerator(Object value, String string)
          Constructs an instance of the Enumerator class with the specified value and string.
 
Method Summary
 boolean equals(Object o)
          Indicates whether some other object is "equal to" this one.
 String getDisplay()
          Return the human-readable string representation of this enumerator.
protected static Object getObject(Class clazz, Object value)
          Return the enumerator defined within clazz having the specified value.
protected static Object[] getObjects(Class clazz)
          Return an array containing all of the enumerators defined within the specified class.
 Object getValue()
          Returns the value for the enumerator.
 int hashCode()
          Returns a hash code value for the object.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JvEnumerator

protected JvEnumerator(Object value,
                       String string)
Constructs an instance of the Enumerator class with the specified value and string.

Parameters:
value - The value for the enumeration instance.
string - The string value of the enumeration.
Method Detail

getDisplay

public String getDisplay()
Return the human-readable string representation of this enumerator.

Returns:
the human-readable string representation

getObjects

protected static Object[] getObjects(Class clazz)
Return an array containing all of the enumerators defined within the specified class.

Parameters:
clazz - the class containing the enumerators
Returns:
an array (of type clazz) of the enumerators

getObject

protected static Object getObject(Class clazz,
                                  Object value)
Return the enumerator defined within clazz having the specified value.

Parameters:
clazz - the class containing the enumerators
value - the value of the desired enumerator
Returns:
the enumerator with value value or null if no such enumerator

getValue

public Object getValue()
Returns the value for the enumerator.

Returns:
the value for the enumerator.

equals

public boolean equals(Object o)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class Object
Parameters:
o - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object
See Also:
Object.hashCode()

toString

public String toString()
Returns a string representation of the object.

Overrides:
toString in class Object
Returns:
a string representation of the object


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.