Openfire 3.6.0 Javadoc

org.jivesoftware.util
Class IntEnum

java.lang.Object
  extended by org.jivesoftware.util.Enum
      extended by org.jivesoftware.util.IntEnum
Direct Known Subclasses:
RosterItem.AskType, RosterItem.RecvType, RosterItem.SubType

public class IntEnum
extends Enum

A type safe enumeration object that is keyed by an Int value for switch statements and storage in DBs.

Used for indicating distinct states in a generic manner where each enum should have an associated int value. The given int should be unique for each enum value as hashCode and equals depends solely on the int value given. Most child classes should extend IntEnum and create static instances.

Author:
Iain Shigeoka

Field Summary
protected static Hashtable enumTypes
           
 
Constructor Summary
protected IntEnum(String name, int val)
           
 
Method Summary
 boolean equals(Object object)
           
protected static IntEnum getEnumFromInt(Class enumClass, int value)
          Obtain the enum associated with the given value.
 int getValue()
          Returns the int value associated with the enum.
 int hashCode()
           
protected static void register(IntEnum enumeration)
          Checks in an enum for use in the getEnumFromInt() method.
 String toString()
           
 
Methods inherited from class org.jivesoftware.util.Enum
getName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

enumTypes

protected static Hashtable enumTypes
Constructor Detail

IntEnum

protected IntEnum(String name,
                  int val)
Method Detail

getValue

public int getValue()
Returns the int value associated with the enum.

Returns:
the int value of the enum.

equals

public boolean equals(Object object)
Overrides:
equals in class Enum

register

protected static void register(IntEnum enumeration)

Checks in an enum for use in the getEnumFromInt() method.

Parameters:
enumeration - The enum to be registered

getEnumFromInt

protected static IntEnum getEnumFromInt(Class enumClass,
                                        int value)

Obtain the enum associated with the given value.

Values must be registered earlier using the register() method.

Parameters:
value - the value to lookup the enum for
Returns:
The associated enum or null if no matching enum exists

hashCode

public int hashCode()
Overrides:
hashCode in class Enum

toString

public String toString()
Overrides:
toString in class Enum

Openfire 3.6.0 Javadoc

Copyright © 2003-2008 Jive Software.