|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.exolab.castor.mapping.loader.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(java.lang.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 | |
void |
checkValidity(java.lang.Object object)
Deprecated. |
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 object)
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 |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public FieldHandlerImpl(FieldHandler handler,
TypeInfo typeInfo)
throws MappingException
typeInfo - Type information
MappingException - If the field is not public, is static or
transient
public 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
transient
public 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 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| Method Detail |
public TypeConvertor getConvertFrom()
public TypeConvertor getConvertTo()
public java.lang.String getConvertParam()
public java.lang.Object getValue(java.lang.Object object)
FieldHandler
getValue in interface FieldHandlerobject - The object
public void setValue(java.lang.Object object,
java.lang.Object value)
FieldHandler
setValue in interface FieldHandlerobject - The objectvalue - The new valuepublic void resetValue(java.lang.Object object)
FieldHandlerReference fields are set to null, primitive fields are set to their default value, collection fields are emptied of all elements.
resetValue in interface FieldHandlerobject - The object
public void checkValidity(java.lang.Object object)
throws ValidityException
checkValidity in interface FieldHandlerValidityException
public java.lang.Object newInstance(java.lang.Object object)
throws java.lang.IllegalStateException
FieldHandler
newInstance in interface FieldHandlerobject - The object for which the field is created
java.lang.IllegalStateException - This field is a simple type and
cannot be instantiatedvoid setRequired(boolean required)
MappingLoader.
public 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! :-)
MappingExceptionpublic boolean isCollection()
public java.lang.String toString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||