org.exolab.castor.mapping
Class GeneralizedFieldHandler
- FieldHandler
public abstract class GeneralizedFieldHandler
An extended version of the FieldHandler interface which is
used for making generic libraries of FieldHandlers which
can be used for more than one field or class, but have
similar conversion algorithms.
$Revision: 1.2 $ $Date: 2003/04/16 07:15:57 $
abstract Object | convertUponGet(Object value) - This method is used to convert the value when the getValue method
is called.
|
abstract Object | convertUponSet(Object value) - This method is used to convert the value when the setValue method
is called.
|
abstract Class | getFieldType() - Returns the class type for the field that this GeneralizedFieldHandler
converts to and from.
|
Object | getValue(Object object) - Returns the value of the field from the object.
|
Object | newInstance(Object parent) - Creates a new instance of the object described by this field.
|
Object | newInstance(Object parent, Object[] args) - Creates a new instance of the object described by this field.
|
void | resetValue(Object object) - Sets the value of the field to a default value.
|
void | setFieldHandler(FieldHandler handler) - Sets the FieldHandler that this FieldHander delegates to.
|
void | setValue(Object object, Object value) - Sets the value of the field on the object.
|
GeneralizedFieldHandler
protected GeneralizedFieldHandler()
Creates a new default GeneralizedFieldHandler. This method
should be called by all extending classes so that any
important initialization code will be executed.
convertUponGet
public abstract Object convertUponGet(Object value)
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.
value
- the object value to convert after performing a get
operation
convertUponSet
public abstract Object convertUponSet(Object value)
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.
value
- the object value to convert before performing a set
operation
getFieldType
public abstract Class getFieldType()
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.
- the class type of of the field
newInstance
public Object newInstance(Object parent)
throws IllegalStateException
Creates a new instance of the object described by this field.
- newInstance in interface FieldHandler
- newInstance in interface AbstractFieldHandler
parent
- The object for which the field is created
- A new instance of the field's value
newInstance
public Object newInstance(Object parent,
Object[] args)
throws IllegalStateException
Creates a new instance of the object described by this field.
- newInstance in interface AbstractFieldHandler
parent
- The object for which the field is createdargs
- the set of constructor arguments
- A new instance of the field's value
resetValue
public final void resetValue(Object object)
throws IllegalStateException,
IllegalArgumentException
Sets the value of the field to a default value.
Reference fields are set to null, primitive fields are set to
their default value, collection fields are emptied of all
elements.
- resetValue in interface FieldHandler
- resetValue in interface AbstractFieldHandler
setFieldHandler
public final void setFieldHandler(FieldHandler handler)
Sets the FieldHandler that this FieldHander delegates to.
A call to this method must be made with a non-null
FieldHandler before this GeneralizedFieldHandler can be used.
handler
- the FieldHandler to delegate to
setValue
public final void setValue(Object object,
Object value)
throws IllegalStateException,
IllegalArgumentException
Sets the value of the field on the object.
- setValue in interface FieldHandler
- setValue in interface AbstractFieldHandler
object
- The objectvalue
- The new value
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com