FileDocCategorySizeDatePackage
Enumerated.javaAPI DocJava SE 5 API5152Fri Aug 26 14:55:02 BST 2005com.sun.jmx.snmp

Enumerated

public abstract class Enumerated extends Object implements Serializable
This class is used for implementing enumerated values. An enumeration is represented by a class derived from Enumerated. The derived class defines what are the permitted values in the enumeration. An enumerated value is represented by an instance of the derived class. It can be represented : - as an integer - as a string

This API is a Sun Microsystems internal API and is subject to change without notice.

version
3.1 09/29/98
author
Sun Microsystems, Inc

Fields Summary
protected int
value
This variable keeps the integer form of the enumerated. The string form is retreived using getIntTable().
Constructors Summary
public Enumerated()
Construct an enumerated with a default value. The default value is the first available in getIntTable().

exception
IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate.

    Enumeration e =getIntTable().keys() ;
    if (e.hasMoreElements()) {
      value = ((Integer)e.nextElement()).intValue() ;
    }
    else {
      throw new IllegalArgumentException() ;
    }
  
public Enumerated(int valueIndex)
Construct an enumerated from its integer form.

param
valueIndex The integer form.
exception
IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate.

    if (getIntTable().get(new Integer(valueIndex)) == null) {
      throw new IllegalArgumentException() ;
    }
    value = valueIndex ;
  
public Enumerated(Integer valueIndex)
Construct an enumerated from its Integer form.

param
valueIndex The Integer form.
exception
IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate.

    if (getIntTable().get(valueIndex) == null) {
      throw new IllegalArgumentException() ;
    }
    value = valueIndex.intValue() ;
  
public Enumerated(String valueString)
Construct an enumerated from its string form.

param
valueString The string form.
exception
IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate.

    Integer index = (Integer)getStringTable().get(valueString) ;
    if (index == null) {
      throw new IllegalArgumentException() ;
    }
    else {
      value = index.intValue() ;
    }
  
Methods Summary
public booleanequals(java.lang.Object obj)
Compares this enumerated to the specified enumerated. The result is true if and only if the argument is not null and is of the same class.

param
obj The object to compare with.
return
True if this and obj are the same; false otherwise

    
    return ((obj != null) &&
            (getClass() == obj.getClass()) &&
            (value == ((Enumerated)obj).value)) ;
  
protected abstract java.util.HashtablegetIntTable()
Returns the hashtable of the integer forms. getIntTable().get(x) returns the string form associated to the integer x. This method must be implemented by the derived class.

return
An hashtable for read-only purpose

protected abstract java.util.HashtablegetStringTable()
Returns the hashtable of the string forms. getStringTable().get(s) returns the integer form associated to the string s. This method must be implemented by the derived class.

return
An hashtable for read-only purpose

public inthashCode()
Returns the hash code for this enumerated.

return
A hash code value for this object.

    String hashString = getClass().getName() + String.valueOf(value) ;
    return hashString.hashCode() ;
  
public intintValue()
Return the integer form of the enumerated.

return
The integer form

    return value ;
  
public java.lang.StringtoString()
Returns the string form of this enumerated.

return
The string for for this object.

    return (String)getIntTable().get(new Integer(value)) ;
  
public java.util.EnumerationvalueIndexes()
Returns an Java enumeration of the permitted integers.

return
An enumeration of Integer instances

    return getIntTable().keys() ;
  
public java.util.EnumerationvalueStrings()
Returns an Java enumeration of the permitted strings.

return
An enumeration of String instances

    return getStringTable().keys() ;