org.exolab.castor.mapping.loader
Class FieldHandlerImpl
- FieldHandler
public final class FieldHandlerImpl
A field handler that knows how to get/set the values of a field
directly or through the get/set methods. Uses reflection.
Note: the field Java type is obtained from
TypeInfo.getFieldType()
,
but if the field is a collection, the actual field/accessor type is
obtained from
TypeInfo.getCollectionHandler()
and the object to create
(with
newInstance
) is the former field type.
$Revision: 1.2 $ $Date: 2003/04/16 07:15:35 $FieldHandlerImpl(Field field, TypeInfo typeInfo) - Construct a new field handler for the specified field.
|
FieldHandlerImpl(String fieldName, Method[] getSequence, Method[] setSequence, Method getMethod, Method setMethod, TypeInfo typeInfo) - Construct a new field handler for the specified field that
is accessed through the accessor methods (get/set).
|
FieldHandlerImpl(FieldHandler handler, TypeInfo typeInfo) - Construct a new field handler for the specified field.
|
FieldHandlerImpl
public FieldHandlerImpl(Field field,
TypeInfo typeInfo)
throws MappingException
Construct a new field handler for the specified field. The field must
be public, and may not be static or transient. The field name is
determined from the Java field, the type from the type information.
field
- The field being describedtypeInfo
- Type information
FieldHandlerImpl
public FieldHandlerImpl(String fieldName,
Method[] getSequence,
Method[] setSequence,
Method getMethod,
Method setMethod,
TypeInfo typeInfo)
throws MappingException
Construct a new field handler for the specified field that
is accessed through the accessor methods (get/set). The accessor
methods must be public and not static. The field name is
required for descriptive purposes. The field type must match
the return value of the get method and the single parameter of
the set method. Either get or set methods are optional.
fieldName
- The field being describedgetMethod
- The method used to retrieve the field value,
must accept no parameters and have a return type castable to
the field typesetMethod
- The method used to set the field value, must
accept a single paramater that is castable to the field typetypeInfo
- Type information
MappingException
- If the get or set method are not public,
are static, or do not specify the proper types
FieldHandlerImpl
public FieldHandlerImpl(FieldHandler handler,
TypeInfo typeInfo)
throws MappingException
Construct a new field handler for the specified field. The field must
be public, and may not be static or transient. The field name is
determined from the Java field, the type from the type information.
typeInfo
- Type information
getConvertParam
public String getConvertParam()
isCollection
public boolean isCollection()
Return true if the field is a collection.
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 void resetValue(Object object)
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
setAddMethod
public void setAddMethod(Method method)
throws MappingException
Mutator method used by
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
setConvertFrom
public void setConvertFrom(TypeConvertor convertor)
Sets the TypeConvertor used during calls to getValue
convertor
- the TypeConvertor to use during calls
to getValue
setConvertTo
public void setConvertTo(TypeConvertor convertor)
Sets the TypeConvertor used during calls to setValue
convertor
- the TypeConvertor to use during calls
to setValue
setCreateMethod
public void setCreateMethod(Method method)
throws MappingException
Mutator method used by
MappingLoader
and
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
setHasDeleteMethod
public void setHasDeleteMethod(Method hasMethod,
Method deleteMethod)
throws MappingException
Mutator method used by
MappingLoader
and
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
setReadMethod
public void setReadMethod(Method method)
throws MappingException
Mutator method used by
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
setRequired
(package private) void setRequired(boolean required)
setWriteMethod
public void setWriteMethod(Method method)
throws MappingException
Mutator method used by
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
toString
public String toString()
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com