ConfigurableFieldHandler
, FieldHandler
public final class FieldHandlerImpl extends AbstractFieldHandler
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.
_properties
Constructor | Description |
---|---|
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).
|
FieldHandlerImpl(FieldHandler handler,
TypeInfo typeInfo) |
Construct a new field handler for the specified field.
|
Modifier and Type | Method | Description |
---|---|---|
TypeConvertor |
getConvertFrom() |
|
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
AbstractMappingLoader and
Introspector . |
void |
setEnumMethod(java.lang.reflect.Method method) |
Sets the enumeration method.
|
void |
setFieldDescriptor(FieldDescriptor fieldDesc) |
Sets the FieldDescriptor that this FieldHander is
responsibile for.
|
void |
setHasDeleteMethod(java.lang.reflect.Method hasMethod,
java.lang.reflect.Method deleteMethod) |
Mutator method used by
AbstractMappingLoader and
Introspector . |
void |
setIterMethod(java.lang.reflect.Method method) |
Sets the iteration method.
|
void |
setReadMethod(java.lang.reflect.Method method) |
Mutator method used by
Introspector . |
(package private) void |
setRequired(boolean required) |
Mutator method used by
AbstractMappingLoader . |
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() |
getFieldDescriptor, hasValue, setConfiguration
checkValidity
checkValidity
public FieldHandlerImpl(FieldHandler handler, TypeInfo typeInfo)
handler
- typeInfo
- Type informationpublic FieldHandlerImpl(java.lang.reflect.Field field, TypeInfo typeInfo) throws MappingException
field
- The field being describedtypeInfo
- Type informationMappingException
- 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 informationMappingException
- If the get or set method are not public,
are static, or do not specify the proper typespublic TypeConvertor getConvertFrom()
public TypeConvertor getConvertTo()
public java.lang.Object getValue(java.lang.Object object)
getValue
in interface FieldHandler
getValue
in class FieldHandlerFriend
object
- The objectFieldHandlerFriend.getValue(java.lang.Object)
public void setValue(java.lang.Object object, java.lang.Object value)
setValue
in interface FieldHandler
setValue
in class FieldHandlerFriend
object
- The objectvalue
- The new valueFieldHandlerFriend.setValue(java.lang.Object, java.lang.Object)
public void resetValue(java.lang.Object object)
FieldHandlerFriend
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 FieldHandlerFriend
object
- The objectpublic java.lang.Object newInstance(java.lang.Object parent) throws java.lang.IllegalStateException
newInstance
in interface FieldHandler
newInstance
in class FieldHandlerFriend
parent
- The object for which the field is createdjava.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 ExtendedFieldHandler
parent
- The object for which the field is createdargs
- the set of constructor argumentsjava.lang.IllegalStateException
- This field is a simple type and
cannot be instantiatedvoid setRequired(boolean required)
AbstractMappingLoader
.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
AbstractMappingLoader
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
AbstractMappingLoader
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 void setEnumMethod(java.lang.reflect.Method method) throws MappingException
MappingException
public void setIterMethod(java.lang.reflect.Method method) throws MappingException
MappingException
public boolean isCollection()
public java.lang.String toString()
toString
in class java.lang.Object
public void setFieldDescriptor(FieldDescriptor fieldDesc)
setFieldDescriptor
in class AbstractFieldHandler
fieldDesc
- the FieldDescriptor to setIntalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com