org.exolab.castor.mapping.handlers
Class EnumFieldHandler

java.lang.Object
  extended by org.exolab.castor.mapping.loader.FieldHandlerFriend
      extended by org.exolab.castor.mapping.ExtendedFieldHandler
          extended by org.exolab.castor.mapping.AbstractFieldHandler
              extended by org.exolab.castor.mapping.GeneralizedFieldHandler
                  extended by org.exolab.castor.mapping.handlers.EnumFieldHandler
All Implemented Interfaces:
FieldHandler

public class EnumFieldHandler
extends GeneralizedFieldHandler

A specialized FieldHandler for the type-safe enum style classes. Adapted from org.exolab.castor.xml.handlers.EnumFieldHandler which is used for the generated source code.

Version:
$Revision: 1.3 $ $Date: 2005/05/02 20:58:58 $
Author:
Keith Visco

Constructor Summary
EnumFieldHandler(java.lang.Class enumType, FieldHandler handler, java.lang.reflect.Method createMethod)
          Creates a new EnumFieldHandler with the given type and FieldHandler
 
Method Summary
 java.lang.Object convertUponGet(java.lang.Object value)
          This method is used to convert the value when the getValue method is called.
 java.lang.Object convertUponSet(java.lang.Object value)
          This method is used to convert the value when the setValue method is called.
 boolean equals(java.lang.Object obj)
          Returns true if the given object is an XMLFieldHandler that is equivalent to the delegated handler.
 java.lang.Class getFieldType()
          Returns the class type for the field that this GeneralizedFieldHandler converts to and from.
 java.lang.Object newInstance(java.lang.Object parent)
          Creates a new instance of the object described by this field.
 java.lang.Object newInstance(java.lang.Object parent, java.lang.Object[] args)
          Creates a new instance of the object described by this field.
 
Methods inherited from class org.exolab.castor.mapping.GeneralizedFieldHandler
getValue, resetValue, setCollectionIteration, setFieldHandler, setValue
 
Methods inherited from class org.exolab.castor.mapping.AbstractFieldHandler
getFieldDescriptor, hasValue, setFieldDescriptor
 
Methods inherited from class org.exolab.castor.mapping.ExtendedFieldHandler
checkValidity
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumFieldHandler

public EnumFieldHandler(java.lang.Class enumType,
                        FieldHandler handler,
                        java.lang.reflect.Method createMethod)
Creates a new EnumFieldHandler with the given type and FieldHandler

Parameters:
enumType - the Class type of the described field
handler - the FieldHandler to delegate to
Method Detail

convertUponGet

public java.lang.Object convertUponGet(java.lang.Object value)
Description copied from class: GeneralizedFieldHandler
This method is used to convert the value when the getValue method is called. The getValue method will obtain the actual field value from given 'parent' object. This convert method is then invoked with the field's value. The value returned from this method will be the actual value returned by getValue method.

Specified by:
convertUponGet in class GeneralizedFieldHandler
Parameters:
value - the object value to convert after performing a get operation
Returns:
the converted value.

convertUponSet

public java.lang.Object convertUponSet(java.lang.Object value)
                                throws java.lang.IllegalStateException
Description copied from class: GeneralizedFieldHandler
This method is used to convert the value when the setValue method is called. The setValue method will call this method to obtain the converted value. The converted value will then be used as the value to set for the field.

Specified by:
convertUponSet in class GeneralizedFieldHandler
Parameters:
value - the object value to convert before performing a set operation
Returns:
the converted value.
Throws:
java.lang.IllegalStateException

getFieldType

public java.lang.Class getFieldType()
Description copied from class: GeneralizedFieldHandler
Returns the class type for the field that this GeneralizedFieldHandler converts to and from. This should be the type that is used in the object model.

Specified by:
getFieldType in class GeneralizedFieldHandler
Returns:
the class type of of the field

newInstance

public java.lang.Object newInstance(java.lang.Object parent)
                             throws java.lang.IllegalStateException
Description copied from class: GeneralizedFieldHandler
Creates a new instance of the object described by this field.

Specified by:
newInstance in interface FieldHandler
Overrides:
newInstance in class GeneralizedFieldHandler
Parameters:
parent - The object for which the field is created
Returns:
A new instance of the field's value
Throws:
java.lang.IllegalStateException - This field is a simple type and cannot be instantiated

newInstance

public java.lang.Object newInstance(java.lang.Object parent,
                                    java.lang.Object[] args)
                             throws java.lang.IllegalStateException
Description copied from class: GeneralizedFieldHandler
Creates a new instance of the object described by this field.

Overrides:
newInstance in class GeneralizedFieldHandler
Parameters:
parent - The object for which the field is created
args - the set of constructor arguments
Returns:
A new instance of the field's value
Throws:
java.lang.IllegalStateException - This field is a simple type and cannot be instantiated

equals

public boolean equals(java.lang.Object obj)
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.

Overrides:
equals in class java.lang.Object
Returns:
true if the given object is an XMLFieldHandler that is equivalent to this one.


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com