org.springsource.loaded
Class FieldReaderWriter

java.lang.Object
  extended by org.springsource.loaded.FieldReaderWriter
Direct Known Subclasses:
ReflectionFieldReaderWriter

public class FieldReaderWriter
extends java.lang.Object

Able to read or write a particular field in a type. Knows nothing about the instance upon which the read/write may be getting done.

Since:
0.5.0

Field Summary
protected  FieldMember theField
           
protected  TypeDescriptor typeDescriptor
          The type descriptor for the type that defines the field we want to access
 
Constructor Summary
protected FieldReaderWriter()
           
  FieldReaderWriter(FieldMember theField, TypeDescriptor typeDescriptor)
           
 
Method Summary
 java.lang.Object getStaticFieldValue(java.lang.Class<?> clazz, SSMgr stateManager)
           
 java.lang.Object getValue(java.lang.Object instance, ISMgr stateManager)
          Return the value of the field for which is reader-writer exists.
 boolean isStatic()
           
 void setStaticFieldValue(java.lang.Class<?> clazz, java.lang.Object newValue, SSMgr stateManager)
           
 void setValue(java.lang.Object instance, java.lang.Object newValue, ISMgr stateManager)
          Set the value of an instance field on the specified instance to the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeDescriptor

protected TypeDescriptor typeDescriptor
The type descriptor for the type that defines the field we want to access


theField

protected FieldMember theField
Constructor Detail

FieldReaderWriter

public FieldReaderWriter(FieldMember theField,
                         TypeDescriptor typeDescriptor)

FieldReaderWriter

protected FieldReaderWriter()
Method Detail

setValue

public void setValue(java.lang.Object instance,
                     java.lang.Object newValue,
                     ISMgr stateManager)
              throws java.lang.IllegalAccessException
Set the value of an instance field on the specified instance to the specified value. If a state manager is passed in things can be done in a more optimal way, otherwise the state manager has to be discovered from the instance.

Parameters:
instance - the object instance upon which to set the field
newValue - the new value for that field
the - optional state manager for this instance, which will be looked up (expensive) if not passed in
Throws:
java.lang.IllegalAccessException

setStaticFieldValue

public void setStaticFieldValue(java.lang.Class<?> clazz,
                                java.lang.Object newValue,
                                SSMgr stateManager)
                         throws java.lang.IllegalAccessException
Throws:
java.lang.IllegalAccessException

getValue

public java.lang.Object getValue(java.lang.Object instance,
                                 ISMgr stateManager)
                          throws java.lang.IllegalAccessException,
                                 java.lang.IllegalArgumentException
Return the value of the field for which is reader-writer exists. To improve performance a fieldAccessor can be supplied but if it is missing the code will go and discover it.

Parameters:
instance - the instance for which the field should be fetched
stateManager - an optional state manager containing the map of values (will be discovered if not supplied)
Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException

getStaticFieldValue

public java.lang.Object getStaticFieldValue(java.lang.Class<?> clazz,
                                            SSMgr stateManager)
                                     throws java.lang.IllegalAccessException,
                                            java.lang.IllegalArgumentException
Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException

isStatic

public boolean isStatic()