org.springsource.loaded
Class ReflectionFieldReaderWriter

java.lang.Object
  extended by org.springsource.loaded.FieldReaderWriter
      extended by org.springsource.loaded.ReflectionFieldReaderWriter

public class ReflectionFieldReaderWriter
extends FieldReaderWriter

A FieldReaderWriter implementation that simply uses reflection to set/get the fields.

Since:
0.5.0

Field Summary
 
Fields inherited from class org.springsource.loaded.FieldReaderWriter
theField, typeDescriptor
 
Constructor Summary
ReflectionFieldReaderWriter(java.lang.reflect.Field findField)
           
 
Method Summary
 java.lang.Object getStaticFieldValue(java.lang.Class<?> type, SSMgr fieldAccessor)
           
 java.lang.Object getValue(java.lang.Object instance, ISMgr fieldAccessor)
          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 fieldAccessor)
           
 void setValue(java.lang.Object instance, java.lang.Object newValue, ISMgr fieldAccessor)
          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
 

Constructor Detail

ReflectionFieldReaderWriter

public ReflectionFieldReaderWriter(java.lang.reflect.Field findField)
Method Detail

getStaticFieldValue

public java.lang.Object getStaticFieldValue(java.lang.Class<?> type,
                                            SSMgr fieldAccessor)
                                     throws java.lang.IllegalAccessException,
                                            java.lang.IllegalArgumentException
Overrides:
getStaticFieldValue in class FieldReaderWriter
Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException

setStaticFieldValue

public void setStaticFieldValue(java.lang.Class<?> clazz,
                                java.lang.Object newValue,
                                SSMgr fieldAccessor)
                         throws java.lang.IllegalAccessException
Overrides:
setStaticFieldValue in class FieldReaderWriter
Throws:
java.lang.IllegalAccessException

setValue

public void setValue(java.lang.Object instance,
                     java.lang.Object newValue,
                     ISMgr fieldAccessor)
              throws java.lang.IllegalAccessException
Description copied from class: FieldReaderWriter
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.

Overrides:
setValue in class FieldReaderWriter
Parameters:
instance - the object instance upon which to set the field
newValue - the new value for that field
Throws:
java.lang.IllegalAccessException

getValue

public java.lang.Object getValue(java.lang.Object instance,
                                 ISMgr fieldAccessor)
                          throws java.lang.IllegalAccessException,
                                 java.lang.IllegalArgumentException
Description copied from class: FieldReaderWriter
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.

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

isStatic

public boolean isStatic()
Overrides:
isStatic in class FieldReaderWriter