public class ObjectAccessWrapper extends java.lang.Object implements AttributeReadWriteAccess
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String[] |
EMPTY_STRING_ARRAY |
protected static ReflectUtil |
RU |
Constructor and Description |
---|
ObjectAccessWrapper(java.lang.Object object)
Initialize the new instance with an object.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(java.lang.String fieldName)
Returns the return value of the getter method of the given field name
or null in any case of reflection problem.
|
java.lang.String[] |
getAttributeNames()
Returns the names of all attributes that can be accessed by the
method getAttributeValue().
|
java.lang.Object |
getAttributeValue(java.lang.String name)
Returns the current value of the attribute (field) with the given name.
|
java.lang.Object |
getObject() |
java.lang.Class<?> |
getObjectType()
Returns the type of the wrapped object.
|
java.lang.Object |
getValueOfField(java.lang.String fieldName)
Returns the value of the field with the given field name or
null in any case of reflection error.
|
protected void |
handleException(java.lang.Exception e)
Handles all exceptions that might occur due to reflection access.
|
void |
set(java.lang.String fieldName,
java.lang.Object value)
Invokes the setter method of the given field name and passes the
specified value as parameter to it.
|
void |
setAttributeValue(java.lang.String name,
java.lang.Object value)
Sets the current value of the attribute (field) with the given name.
|
void |
setObject(java.lang.Object object)
Set the underlying object.
|
void |
setValueOfField(java.lang.String fieldName,
java.lang.Object value)
Modifies the field with the given name directly to the specified value
without calling the setter.
|
protected static final java.lang.String[] EMPTY_STRING_ARRAY
protected static final ReflectUtil RU
public ObjectAccessWrapper(java.lang.Object object)
object
- The object to be accessed by this wrapper (must not be null)public java.lang.Object get(java.lang.String fieldName)
public void set(java.lang.String fieldName, java.lang.Object value)
public java.lang.Object getValueOfField(java.lang.String fieldName)
public void setValueOfField(java.lang.String fieldName, java.lang.Object value)
public java.lang.Object getAttributeValue(java.lang.String name) throws UnknownFieldException
getAttributeValue
in interface AttributeReadAccess
name
- The attribute's name ( case sensitive )UnknownFieldException
- If there is no attribute with the given namepublic void setAttributeValue(java.lang.String name, java.lang.Object value) throws UnknownFieldException
setAttributeValue
in interface AttributeReadWriteAccess
name
- The attribute's name ( case sensitive )value
- The value to be put into the attribute's 'slot'UnknownFieldException
- If there is no attribute with the given namepublic java.lang.String[] getAttributeNames()
getAttributeNames
in interface AttributeReadAccess
public java.lang.Object getObject()
public void setObject(java.lang.Object object)
object
- The object to be accessed by this wrapper (must not be null)public java.lang.Class<?> getObjectType()
Void.TYPE
.protected void handleException(java.lang.Exception e)