Package org.exolab.castor.xml.handlers
Class EnumFieldHandler
java.lang.Object
org.exolab.castor.xml.handlers.EnumFieldHandler
- All Implemented Interfaces:
FieldHandler
A specialized FieldHandler for the XML Schema enumeration types.
- Version:
- $Revision: 7168 $ $Date: 2006-04-13 06:47:36 -0600 (Thu, 13 Apr 2006) $
- Author:
- Keith Visco
-
Constructor Summary
ConstructorsConstructorDescriptionEnumFieldHandler
(Class enumType, FieldHandler handler) Creates a new EnumFieldHandler with the given type and FieldHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkValidity
(Object object) Checks the field validity.boolean
Returns true if the given object is an XMLFieldHandler that is equivalent to the delegated handler.Returns the value of the field associated with this descriptor from the given target object.newInstance
(Object parent) Creates a new instance of the object described by this field.void
resetValue
(Object target) Sets the value of the field to a default value -- for enum, no action needed.void
Sets the value of the field associated with this descriptor.
-
Constructor Details
-
EnumFieldHandler
Creates a new EnumFieldHandler with the given type and FieldHandler.- Parameters:
enumType
- the Class type of the described fieldhandler
- the FieldHandler to delegate to
-
-
Method Details
-
getValue
Returns the value of the field associated with this descriptor from the given target object.- Specified by:
getValue
in interfaceFieldHandler
- Parameters:
target
- the object to get the value from- Returns:
- the value of the field associated with this descriptor from the given target object.
- Throws:
IllegalStateException
- The Java object has changed and is no longer supported by this handler, or the handler is not compatible with the Java object
-
setValue
Sets the value of the field associated with this descriptor.- Specified by:
setValue
in interfaceFieldHandler
- Parameters:
target
- the object in which to set the valuevalue
- the value of the field- Throws:
IllegalStateException
- The Java object has changed and is no longer supported by this handler, or the handler is not compatible with the Java object.
-
resetValue
Sets the value of the field to a default value -- for enum, no action needed.- Specified by:
resetValue
in interfaceFieldHandler
- Parameters:
target
- The object.
-
checkValidity
Checks the field validity. Returns successfully if the field can be stored, is valid, etc, throws an exception otherwise.- Specified by:
checkValidity
in interfaceFieldHandler
- Parameters:
object
- The object- Throws:
ValidityException
- The field is invalid, is required and null, or any other validity violationIllegalStateException
- The Java object has changed and is no longer supported by this handler, or the handler is not compatiable with the Java object
-
newInstance
Creates a new instance of the object described by this field.- Specified by:
newInstance
in interfaceFieldHandler
- Parameters:
parent
- The object for which the field is created- Returns:
- A new instance of the field's value
- Throws:
IllegalStateException
- This field is a simple type and cannot be instantiated
-
equals
Returns true if the given object is an XMLFieldHandler that is equivalent to the delegated handler. An equivalent XMLFieldHandler is an XMLFieldHandler that is an instances of the same class.
-