public class FieldAccessor extends Object
This class allows read/write access to class fields based on their access level and any access methods defined. It uses basic JavaBeans naming convention to find appropriate get/set methods for fields with restricted access.
This class is used with reflection mechanism to get/set field values for an object.
Constructor and Description |
---|
FieldAccessor(Field field,
Object target)
Creates new instance of accessor for a given field inside a given object.
|
Modifier and Type | Method and Description |
---|---|
Object |
getFieldValue()
Returns current field value.
|
void |
setFieldValue(Object value)
Set field value to specified value.
|
public Object getFieldValue() throws IllegalAccessException, InvocationTargetException
IllegalAccessException
- if field cannot be accessedInvocationTargetException
- if an error occurs during method invocationpublic void setFieldValue(Object value) throws IllegalAccessException, InvocationTargetException
value
- value to setIllegalAccessException
- if field cannot be accessedInvocationTargetException
- if an error occurs during method executionCopyright © 2012-2014 Vektor Software. All Rights Reserved.