com.virtualweaver.xotics.datamodel.datatype
Class XdtEnum

java.lang.Object
  extended bycom.virtualweaver.xotics.datamodel.datatype.XdtEnum
All Implemented Interfaces:
XoDataType

public abstract class XdtEnum
extends java.lang.Object
implements XoDataType

Base abstract class to implement two forms of enumeration : standard or partial. The standard form defines an enum type whose value belongs to a finite set of possible constant values. The partial form defines an enum type whose value can be either choosen from a set of possible constants or any other value of a predefined datatype. As for other datatypes in this package, value is set at instance creation only.

Version:
4.1

Constructor Summary
protected XdtEnum(boolean part, java.lang.Object val, XdtBidiMap v2s)
          Derived class can use this constructor to create a new instance whose value comes from param val .
protected XdtEnum(boolean part, XdtBidiMap v2s, java.lang.String strValue)
          Derived class can use this constructor to create a new instance whose value comes from string param strValue.
 
Method Summary
protected  java.lang.Object createValue(java.lang.String str)
          Converts param str into appropriate value.
 boolean equals(java.lang.Object o)
          Default implementation of equality.
protected  java.lang.String getAsString()
          Converts stored value into string representation.
static java.lang.Class getContentPropertyEditorClass()
          This method can be overriden for partial enum type wanting to give a specific PropertyEditor class to edit specific values.
static XdtEnum[] getEnumSpace()
          Returns the list of constant values of the enum type, as an array of enum constants.
 java.lang.Object getValueAsObject()
          Returns the internal value
abstract  java.lang.Class getValueClass()
          Returns the type class of internal value.
static boolean isPartEnum()
          This method returns null, but must be overriden to return true if derived type is a partial enum type.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XdtEnum

protected XdtEnum(boolean part,
                  XdtBidiMap v2s,
                  java.lang.String strValue)
           throws java.lang.IllegalArgumentException
Derived class can use this constructor to create a new instance whose value comes from string param strValue.

Parameters:
part - tells whether this enum type is partial
v2s - a bidi map containing mapping between enumeration values and their string representation.
strValue - string value of this
Throws:
java.lang.IllegalArgumentException - if strValue is invalid.

XdtEnum

protected XdtEnum(boolean part,
                  java.lang.Object val,
                  XdtBidiMap v2s)
Derived class can use this constructor to create a new instance whose value comes from param val .

Parameters:
part - tells whether this enum type is partial
v2s - a bidi map containing mapping between enumeration values and their string representation.
val - value of this
Method Detail

createValue

protected java.lang.Object createValue(java.lang.String str)
                                throws java.lang.IllegalArgumentException
Converts param str into appropriate value. If this is a standard enum, this method uses internal bidi map to find value. If this is a partial enum, this method must be overriden.

Parameters:
str - string to convert into value
Returns:
resulting value
Throws:
java.lang.IllegalArgumentException - if param str is invalid

getAsString

protected java.lang.String getAsString()
Converts stored value into string representation. This method needs to be overriden for partial enum type only.

Returns:
string version of internal value.

getContentPropertyEditorClass

public static java.lang.Class getContentPropertyEditorClass()
This method can be overriden for partial enum type wanting to give a specific PropertyEditor class to edit specific values. By default this method returns null as there is already a property editor assigned to edit standard enum type.

Returns:
null but derived class can return a class of type PropertyEditor.

isPartEnum

public static boolean isPartEnum()
This method returns null, but must be overriden to return true if derived type is a partial enum type.

Returns:
false, but derived class of type partial enum type must return true.

getValueClass

public abstract java.lang.Class getValueClass()
Returns the type class of internal value.

Returns:
the class of internal value

toString

public java.lang.String toString()

getValueAsObject

public java.lang.Object getValueAsObject()
Returns the internal value

Returns:
stored value

getEnumSpace

public static XdtEnum[] getEnumSpace()
Returns the list of constant values of the enum type, as an array of enum constants. This method must be overriden.

Returns:
an empty array, but derived class must return effective list of constants.

equals

public boolean equals(java.lang.Object o)
Default implementation of equality. This method checks that param type and value are the same as this.

Parameters:
o - external object to compare to
Returns:
true if equality.