com.foxsmart.ic.lang
Class Enum

java.lang.Object
  extended by com.foxsmart.ic.lang.Enum
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DscpEnum, FrameRelayEndToEndKeepaliveModeEnum, FrameRelayInterfaceQueuePriorityEnum, FrameRelayRateAdjustmentEnum, IcmpTypeEnum, IgmpTypeEnum, InputOutputEnum, InterfaceTypeEnum, IpProtocolEnum, LapbEncapsulationEnum, MatchProtocolEnum, PrecedenceEnum, RandomDetectPrecedenceEnum, SubInterfaceTypeEnum, TcpPortEnum, TosEnum, UdpPortEnum, ValidationMechanismEnum, VlanInterfaceTypeEnum, X25EncapsulationEnum

public abstract class Enum
extends java.lang.Object
implements java.io.Serializable

This class provides infrastructure needed to implement a generic value to name mapping (i.e. an Enum).

See Also:
Serialized Form

Field Summary
protected static java.util.Map enumMap
          The enum map.
protected  java.lang.Object value
           
 
Constructor Summary
protected Enum(EnumEntry enumEntry)
          Construct an Enum based on an EnumEntry.
  Enum(java.lang.Object value)
          Constructs a Enum based on a value.
  Enum(java.lang.String name)
          Constructs a Enum based on a name.
 
Method Summary
protected static com.foxsmart.ic.lang.Enum.Entry createEntry()
          Returns a newly created Entry.
 boolean equals(java.lang.Object enumObject)
          Determines if two enums are equal.
 EnumEntry getEntry()
          Returns the entry for the value.
static EnumEntry getEntry(java.lang.Class enumClass, java.lang.Object value)
          Returns the entry for the value.
static EnumEntry getEntry(java.lang.Class enumClass, java.lang.String name)
          Returns the entry for the name.
protected  java.lang.Class getEnumClass()
          Retrieves the Class of this Enum.
 java.lang.String getLongDescription()
          Gets the long description.
protected static java.lang.String getLongDescription(EnumEntry entry)
          Gets the long description.
static java.lang.Comparable getMaxValue()
          Returns null to indicate there is no maximum value.
static java.lang.Comparable getMinValue()
          Returns null to indicate there is no minimum value.
 java.lang.String getName()
          Gets the name.
static java.lang.String getName(java.lang.Class enumClass, java.lang.Object value)
          Gets the name based on a value.
protected static java.lang.String getName(EnumEntry entry)
          Gets the name.
 java.lang.String getShortDescription()
          Gets the short description.
protected static java.lang.String getShortDescription(EnumEntry entry)
          Gets the short description.
 java.lang.Object getValue()
          Gets the value.
static java.lang.Object getValue(java.lang.Class enumClass, java.lang.String name)
          Gets the value based on a name.
protected static java.lang.Object getValue(EnumEntry entry)
          Gets the value based on a name.
 boolean hasEntry()
          Returns whether a name exists for the value.
 int hashCode()
          Returns the hash code for this enum.
 java.lang.String toString()
          Generates a string representation of this object.
 java.lang.String toString(EnumEntry entry)
          Generates a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected java.lang.Object value

enumMap

protected static java.util.Map enumMap
The enum map. This map is keyed by the classname obtained from getEnumClass() and maps to an Entry.

Constructor Detail

Enum

protected Enum(EnumEntry enumEntry)
Construct an Enum based on an EnumEntry. Sub-classes should call this constructor to add official enum entries. Only this constructor will add official enum entries.

Parameters:
enumEntry - The entry entry to add.

Enum

public Enum(java.lang.String name)
     throws java.lang.IllegalArgumentException
Constructs a Enum based on a name.

Parameters:
name - The name
Throws:
java.lang.IllegalArgumentException - if the name is invalid.

Enum

public Enum(java.lang.Object value)
     throws java.lang.IllegalArgumentException
Constructs a Enum based on a value.

Parameters:
value - The value
Throws:
java.lang.IllegalArgumentException - if the value is out of range.
Method Detail

getEnumClass

protected java.lang.Class getEnumClass()
Retrieves the Class of this Enum.

Returns:
the Class of the enum.

createEntry

protected static com.foxsmart.ic.lang.Enum.Entry createEntry()
Returns a newly created Entry.

Returns:
the newly created entry.

getMinValue

public static java.lang.Comparable getMinValue()
Returns null to indicate there is no minimum value. Specific enums should extend this method to return a value if a minimum value is desired.

Returns:
null.

getMaxValue

public static java.lang.Comparable getMaxValue()
Returns null to indicate there is no maximum value. Specific enums should extend this method to return a value if a maximum value is desired.

Returns:
null.

getValue

protected static java.lang.Object getValue(EnumEntry entry)
Gets the value based on a name. Null is returned if the name does not exist.

Parameters:
entry - The enum entry.
Returns:
The value.

getName

protected static java.lang.String getName(EnumEntry entry)
Gets the name. Null is returned if an entry doesn't exist for the value.

Parameters:
entry - The enum entry
Returns:
the name.

getShortDescription

protected static java.lang.String getShortDescription(EnumEntry entry)
Gets the short description. Null is returned if an entry doesn't exist for the value.

Parameters:
entry - The enum entry
Returns:
The short description

getLongDescription

protected static java.lang.String getLongDescription(EnumEntry entry)
Gets the long description. Null is returned if an entry doesn't exist for the value.

Parameters:
entry - The enum entry
Returns:
The long description

getEntry

public EnumEntry getEntry()
Returns the entry for the value. Null is returned if an entry doesn't exist for the value.

Returns:
The enum entry

hasEntry

public boolean hasEntry()
Returns whether a name exists for the value.

Returns:
True if a name exists or false if not.

equals

public boolean equals(java.lang.Object enumObject)
Determines if two enums are equal.

Overrides:
equals in class java.lang.Object
Parameters:
enumObject - The enum to compare.
Returns:
True if the enums are equal or false if not.

hashCode

public int hashCode()
Returns the hash code for this enum. The hash code is the hash code associated with the value associated with this enum.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.

toString

public java.lang.String toString()
Generates a string representation of this object. The name will be returned if one exists. Otherwise, the string version of the value will be returned.

Overrides:
toString in class java.lang.Object
Returns:
The string.

toString

public java.lang.String toString(EnumEntry entry)
Generates a string representation of this object. The name will be returned if one exists. Otherwise, the string version of the value will be returned.

Parameters:
entry - The enum entry
Returns:
The string.

getEntry

public static EnumEntry getEntry(java.lang.Class enumClass,
                                 java.lang.String name)
Returns the entry for the name. Null is returned if an entry doesn't exist for the name.

Parameters:
enumClass - the class of the enum to use
name - The name to get an entry for
Returns:
The EnumEntry.

getEntry

public static EnumEntry getEntry(java.lang.Class enumClass,
                                 java.lang.Object value)
Returns the entry for the value. Null is returned if an entry doesn't exist for the value.

Parameters:
enumClass - the class of the enum to use
value - The value to get an entry for
Returns:
The EnumEntry.

getValue

public java.lang.Object getValue()
Gets the value.

Returns:
The value.

getName

public java.lang.String getName()
Gets the name. Null is returned if an entry doesn't exist for the value.

Returns:
the name.

getShortDescription

public java.lang.String getShortDescription()
Gets the short description. Null is returned if an entry doesn't exist for the value.

Returns:
the short description.

getLongDescription

public java.lang.String getLongDescription()
Gets the long description. Null is returned if an entry doesn't exist for the value.

Returns:
the long description.

getValue

public static java.lang.Object getValue(java.lang.Class enumClass,
                                        java.lang.String name)
Gets the value based on a name. Null is returned if the name does not exist.

Parameters:
enumClass - the class of the enum to use
name - The name to lookup.
Returns:
The value.

getName

public static java.lang.String getName(java.lang.Class enumClass,
                                       java.lang.Object value)
Gets the name based on a value. Null is returned if the value is not associated with a name.

Parameters:
enumClass - the class of the enum to use
value - The value to lookup.
Returns:
the name.


Copyright © 2005-2008 Fox Smart, Inc. All Rights Reserved.