|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectblackboard.base.BbEnum
public abstract class BbEnum
Base enumeration class for fixed enumerations. Any type-safe enumerations defined in the API will inherit from this class. Transformation to and from string form are supported to support persistence operations. This class also implements comparable to allow enumeration elements to be sorted.
Note: This class is typically only used by Blackboard code, and should be treated as unstable. Third party
interaction with enumerations will be with the various sub-classes, e.g., User.Gender.
| Constructor Summary | |
|---|---|
protected |
BbEnum(java.lang.String enumFieldName)
Constructor |
| Method Summary | |
|---|---|
int |
compareTo(java.lang.Object obj)
The sole method of the Comparable interface. |
protected static BbEnum |
defineAlias(BbEnum element)
Define a value as a pointer to another value. |
protected static BbEnum |
defineDefault(BbEnum element)
Sets the default object for the enumeration. |
static BbEnum |
fromExternalString(java.lang.String externalString,
java.lang.Class<?> enumClass)
Returns the BbEnum element specified by the externalString
in the target enumeration class, enumClass. |
static BbEnum |
fromFieldName(java.lang.String fieldName,
java.lang.Class<?> enumClass)
Returns the BbEnum element specified by the fieldName
in the target enumeration class, enumClass. |
static BbEnum |
fromFieldName(java.lang.String fieldName,
java.lang.Class<?> enumClass,
boolean returnDefault)
Returns the BbEnum element specified by the fieldName
in the target enumeration class, enumClass. |
static BbEnum |
getDefaultElement(java.lang.Class<?> enumClass)
Returns the first element in the enumeration where isDefault() is true. |
java.lang.String |
getFieldName()
A simple bean-based wrapper around the method toFieldName()
which allows the field name to be accessed as a bean property. |
static BbEnum[] |
getValues(java.lang.Class<?> enumClass)
Returns an array of all of the elements in the target enumeration class specified by enumClass. |
boolean |
isDefault()
Returns true if this is a default element. |
java.lang.Object |
readResolve()
Serialization over-ride to ensure that a serialized object obeys object identify as defined for the BbEnum class. |
java.lang.String |
toExternalString()
Returns an external representation of this element in the enumeration. |
java.lang.String |
toFieldName()
Returns the short representation of this element in the enumeration. |
java.lang.String |
toString()
Returns the String representation of this element in the enumeration. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected BbEnum(java.lang.String enumFieldName)
| Method Detail |
|---|
public static BbEnum[] getValues(java.lang.Class<?> enumClass)
enumClass. The array will be of the same
type as the given enumeration class.
public static BbEnum fromExternalString(java.lang.String externalString,
java.lang.Class<?> enumClass)
externalString
in the target enumeration class, enumClass.
java.lang.IllegalArgumentException - if the given string is not an external
representation of one of the elements in the target enumeration class.
java.lang.IllegalArgumentException - if the given enumeration class does
not extend BbEnum
public static BbEnum fromFieldName(java.lang.String fieldName,
java.lang.Class<?> enumClass)
fieldName
in the target enumeration class, enumClass. This should be
used ONLY when the container class is well-defined externally.
java.lang.IllegalArgumentException - if the given string is not a short
representation of one of the elements in the target enumeration class.
java.lang.IllegalArgumentException - if the given enumeration class does
not extend BbEnum
public static BbEnum fromFieldName(java.lang.String fieldName,
java.lang.Class<?> enumClass,
boolean returnDefault)
fieldName
in the target enumeration class, enumClass. This should be
used ONLY when the container class is well-defined externally.
java.lang.IllegalArgumentException - if the given string is not a short
representation of one of the elements in the target enumeration class.
java.lang.IllegalArgumentException - if the given enumeration class does
not extend BbEnumpublic java.lang.String toExternalString()
fromExternalString()
method.
public java.lang.String toFieldName()
fromFieldName()
method. This should be used ONLY when the container class is well-defined externally.
public java.lang.String getFieldName()
toFieldName()
which allows the field name to be accessed as a bean property.
public java.lang.String toString()
toString in class java.lang.Object
public int compareTo(java.lang.Object obj)
throws java.lang.ClassCastException
Comparable interface.
BbEnum elements are sorted by their external string representation in
alphabetical order.
compareTo in interface java.lang.Comparable<java.lang.Object>obj - the object to be compared to.
java.lang.ClassCastException - thrown if the specified object's type
prevents it from being compared to this Objectpublic java.lang.Object readResolve()
public boolean isDefault()
protected static BbEnum defineDefault(BbEnum element)
element - Object to set as default.
protected static BbEnum defineAlias(BbEnum element)
public static final CourseMembership.Role NONE = (CourseMembership.Role) defineAlias( STUDENT );
The end result is simply that CourseMembership.Role.NONE == CourseMembership.Role.STUDENT
element - Object to alias
element parameter.
public static BbEnum getDefaultElement(java.lang.Class<?> enumClass)
throws java.lang.IllegalArgumentException
isDefault() is true.
enumClass - Enumeration class to get default value for.
null is returned.
java.lang.IllegalArgumentException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||