|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exolab.castor.mapping.loader.FieldHandlerFriend
org.exolab.castor.mapping.ExtendedFieldHandler
org.exolab.castor.mapping.AbstractFieldHandler
org.exolab.castor.mapping.loader.FieldHandlerImpl
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(Object)
) is the former field type.
Constructor Summary | |
---|---|
FieldHandlerImpl(FieldHandler handler,
TypeInfo typeInfo)
Construct a new field handler for the specified field. |
|
FieldHandlerImpl(java.lang.reflect.Field field,
TypeInfo typeInfo)
Construct a new field handler for the specified field. |
|
FieldHandlerImpl(java.lang.String fieldName,
java.lang.reflect.Method[] getSequence,
java.lang.reflect.Method[] setSequence,
java.lang.reflect.Method getMethod,
java.lang.reflect.Method setMethod,
TypeInfo typeInfo)
Construct a new field handler for the specified field that is accessed through the accessor methods (get/set). |
Method Summary | |
---|---|
TypeConvertor |
getConvertFrom()
|
java.lang.String |
getConvertParam()
|
TypeConvertor |
getConvertTo()
|
java.lang.Object |
getValue(java.lang.Object object)
Returns the value of the field from the object. |
boolean |
isCollection()
Return true if the field is a collection. |
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. |
void |
resetValue(java.lang.Object object)
Sets the value of the field to a default value. |
void |
setAddMethod(java.lang.reflect.Method method)
Mutator method used by Introspector . |
void |
setConvertFrom(TypeConvertor convertor)
Sets the TypeConvertor used during calls to getValue |
void |
setConvertTo(TypeConvertor convertor)
Sets the TypeConvertor used during calls to setValue |
void |
setCreateMethod(java.lang.reflect.Method method)
Mutator method used by MappingLoader and
Introspector . |
void |
setHasDeleteMethod(java.lang.reflect.Method hasMethod,
java.lang.reflect.Method deleteMethod)
Mutator method used by MappingLoader and
Introspector . |
void |
setReadMethod(java.lang.reflect.Method method)
Mutator method used by Introspector . |
(package private) void |
setRequired(boolean required)
Mutator method used by MappingLoader . |
void |
setValue(java.lang.Object object,
java.lang.Object value)
Sets the value of the field on the object. |
void |
setWriteMethod(java.lang.reflect.Method method)
Mutator method used by Introspector . |
java.lang.String |
toString()
|
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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FieldHandlerImpl(FieldHandler handler, TypeInfo typeInfo) throws MappingException
handler
- typeInfo
- Type information
MappingException
- If the field is not public, is static or
transientpublic FieldHandlerImpl(java.lang.reflect.Field field, TypeInfo typeInfo) throws MappingException
field
- The field being describedtypeInfo
- Type information
MappingException
- If the field is not public, is static or
transientpublic FieldHandlerImpl(java.lang.String fieldName, java.lang.reflect.Method[] getSequence, java.lang.reflect.Method[] setSequence, java.lang.reflect.Method getMethod, java.lang.reflect.Method setMethod, TypeInfo typeInfo) throws MappingException
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 parameter 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 typesMethod Detail |
---|
public TypeConvertor getConvertFrom()
public TypeConvertor getConvertTo()
public java.lang.String getConvertParam()
public java.lang.Object getValue(java.lang.Object object)
AbstractFieldHandler
getValue
in interface FieldHandler
getValue
in class AbstractFieldHandler
object
- The object
public void setValue(java.lang.Object object, java.lang.Object value)
AbstractFieldHandler
setValue
in interface FieldHandler
setValue
in class AbstractFieldHandler
object
- The objectvalue
- The new valuepublic void resetValue(java.lang.Object object)
AbstractFieldHandler
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 class AbstractFieldHandler
object
- The objectpublic java.lang.Object newInstance(java.lang.Object parent) throws java.lang.IllegalStateException
newInstance
in interface FieldHandler
newInstance
in class AbstractFieldHandler
parent
- The object for which the field is created
java.lang.IllegalStateException
- This field is a simple type and
cannot be instantiatedpublic java.lang.Object newInstance(java.lang.Object parent, java.lang.Object[] args) throws java.lang.IllegalStateException
newInstance
in class AbstractFieldHandler
parent
- The object for which the field is createdargs
- the set of constructor arguments
java.lang.IllegalStateException
- This field is a simple type and
cannot be instantiatedvoid setRequired(boolean required)
MappingLoader
.
public void setConvertFrom(TypeConvertor convertor)
convertor
- the TypeConvertor to use during calls
to getValuepublic void setConvertTo(TypeConvertor convertor)
convertor
- the TypeConvertor to use during calls
to setValuepublic void setCreateMethod(java.lang.reflect.Method method) throws MappingException
MappingLoader
and
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
MappingException
public void setHasDeleteMethod(java.lang.reflect.Method hasMethod, java.lang.reflect.Method deleteMethod) throws MappingException
MappingLoader
and
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
MappingException
public void setReadMethod(java.lang.reflect.Method method) throws MappingException
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
MappingException
public void setWriteMethod(java.lang.reflect.Method method) throws MappingException
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
MappingException
public void setAddMethod(java.lang.reflect.Method method) throws MappingException
Introspector
.
Please understand how this method is used before you start
playing with it! :-)
MappingException
public boolean isCollection()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |