|
Hyperic HQ Plugin API v. 4.4.0.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hyperic.util.HypericEnum
public abstract class HypericEnum
Utility class for typesafe enums. People implementing such enums should subclass this class. Enums have a code and a description. The code must be unique for enums of a specific class. This has great use in things like Web-UI where you need a code representation as well as a string (rendering a listbox) Each enumeration also provides a resource bundle and locale property to look up the 'value' of the enumeration in that bundle. This class can also be used as a dynamic enumeration as long as all the enumerations use a unique code. XXX: It would be good to implement the PersistentEnum stylee via a UserType in Hibernate, so we don't have to do the conversion in every class that uses an enum. Don't have the time now.. :-( http://www.hibernate.org/203.html
Constructor Summary | |
---|---|
protected |
HypericEnum(java.lang.Class c,
int code,
java.lang.String desc,
java.lang.String localeProp,
java.util.ResourceBundle bundle)
|
protected |
HypericEnum(int code,
java.lang.String desc,
java.lang.String localeProp,
java.util.ResourceBundle bundle)
|
Method Summary | |
---|---|
static HypericEnum |
findByCode(java.lang.Class c,
int code)
Find an enum of a specific class type by code. |
static HypericEnum |
findByDescription(java.lang.Class c,
java.lang.String description)
Find an enum of a specific class type by description. |
static java.util.List |
getAll(java.lang.Class c)
Return a list of HypericEnum objects for a specific class,
sorted by their code. |
static HypericEnum |
getByCode(java.lang.Class c,
int code)
Like findByCode(Class, int) except returns null instead of
throwing an exception |
int |
getCode()
|
java.lang.String |
getDescription()
|
java.lang.String |
getJsonName()
|
java.lang.String |
getValue()
Returns the localized value of this enumeration. |
org.json.JSONObject |
toJSON()
Convert the object to a Json object |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected HypericEnum(int code, java.lang.String desc, java.lang.String localeProp, java.util.ResourceBundle bundle)
protected HypericEnum(java.lang.Class c, int code, java.lang.String desc, java.lang.String localeProp, java.util.ResourceBundle bundle)
Method Detail |
---|
public int getCode()
public java.lang.String getValue()
public java.lang.String getDescription()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getJsonName()
getJsonName
in interface JSON
public org.json.JSONObject toJSON()
JSON
toJSON
in interface JSON
public static HypericEnum getByCode(java.lang.Class c, int code)
findByCode(Class, int)
except returns null instead of
throwing an exception
public static HypericEnum findByCode(java.lang.Class c, int code)
c
- A subclass of HypericEnum
code
- The integer code represented by the enum
public static HypericEnum findByDescription(java.lang.Class c, java.lang.String description)
c
- A subclass of HypericEnum
description
- The description represented by the enum.
public static java.util.List getAll(java.lang.Class c)
HypericEnum
objects for a specific class,
sorted by their code.
c
- Class to find enums for
|
Hyperic HQ Plugin API v. 4.4.0.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |