|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.reflect.ObjectAccessWrapper
org.pfsw.reflect.ObjectOrMapAccessWrapper
public class ObjectOrMapAccessWrapper
A wrapper that is capable to read and write object fields via getter and
setter methods or directly. The access is possible for all visibilities.
However, if the underlying object is an implementor of the interface
java.util.Map then getter and setter method access is simulated to access
entries in the Map and attribute access by name is also done by accessing
Map entries.
The only constraint is, that the keys in the Map are all of type String.
Field Summary |
---|
Fields inherited from class org.pfsw.reflect.ObjectAccessWrapper |
---|
EMPTY_STRING_ARRAY, RU |
Constructor Summary | |
---|---|
ObjectOrMapAccessWrapper(java.lang.Object object)
Initialize the new instance with an object to wrap. |
Method Summary | |
---|---|
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. |
protected java.util.Map |
getMap()
|
java.lang.Object |
getValueOfField(java.lang.String name)
Returns the value of the field with the given field name or null in any case of reflection error. |
boolean |
isMap()
|
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. |
protected void |
setIsMap(boolean newValue)
|
void |
setObject(java.lang.Object object)
Set the underlying object. |
void |
setValueOfField(java.lang.String name,
java.lang.Object value)
Modifies the field with the given name directly to the specified value without calling the setter. |
Methods inherited from class org.pfsw.reflect.ObjectAccessWrapper |
---|
getObject, handleException, makeAccessMethodName, makeGetterName, makeSetterName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ObjectOrMapAccessWrapper(java.lang.Object object)
object
- The object to be accessed by this wrapper (must not be null)Method Detail |
---|
public boolean isMap()
protected void setIsMap(boolean newValue)
public java.lang.String[] getAttributeNames()
getAttributeNames
in interface AttributeReadAccess
getAttributeNames
in class ObjectAccessWrapper
public java.lang.Object get(java.lang.String fieldName)
get
in class ObjectAccessWrapper
public void set(java.lang.String fieldName, java.lang.Object value)
set
in class ObjectAccessWrapper
public java.lang.Object getAttributeValue(java.lang.String name) throws java.lang.NoSuchFieldException
getAttributeValue
in interface AttributeReadAccess
getAttributeValue
in class ObjectAccessWrapper
name
- The attribute's name ( case sensitive )
java.lang.NoSuchFieldException
- If there is no attribute with the given namepublic void setAttributeValue(java.lang.String name, java.lang.Object value) throws java.lang.NoSuchFieldException
setAttributeValue
in interface AttributeReadWriteAccess
setAttributeValue
in class ObjectAccessWrapper
name
- The attribute's name ( case sensitive )value
- The value to be put into the attribute's 'slot'
java.lang.NoSuchFieldException
- If there is no attribute with the given namepublic java.lang.Object getValueOfField(java.lang.String name)
getValueOfField
in class ObjectAccessWrapper
public void setValueOfField(java.lang.String name, java.lang.Object value)
setValueOfField
in class ObjectAccessWrapper
public void setObject(java.lang.Object object)
setObject
in class ObjectAccessWrapper
object
- The object to be accessed by this wrapper (must not be null)protected java.util.Map getMap()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |