org.apache.cayenne.reflect
Class FieldAccessor

java.lang.Object
  extended by org.apache.cayenne.reflect.FieldAccessor
All Implemented Interfaces:
java.io.Serializable, Accessor

public class FieldAccessor
extends java.lang.Object
implements Accessor

A PropertyAccessor that performs direct Field access.

Since:
1.2
See Also:
Serialized Form

Field Summary
protected  java.lang.reflect.Field field
           
protected  java.lang.Object nullValue
           
protected  java.lang.String propertyName
           
 
Constructor Summary
FieldAccessor(java.lang.Class<?> objectClass, java.lang.String propertyName, java.lang.Class<?> propertyType)
           
 
Method Summary
 java.lang.String getName()
          Returns property name.
 java.lang.Object getValue(java.lang.Object object)
          Returns a property value of an object without disturbing the object fault status.
protected  java.lang.reflect.Field lookupFieldInHierarchy(java.lang.Class<?> beanClass, java.lang.String fieldName)
          Recursively looks for a named field in a class hierarchy.
protected  java.lang.reflect.Field prepareField(java.lang.Class<?> beanClass, java.lang.String propertyName, java.lang.Class<?> propertyType)
          Finds a field for the property, ensuring that direct access via reflection is possible.
 void setValue(java.lang.Object object, java.lang.Object newValue)
          Sets a property value of an object without disturbing the object fault status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyName

protected java.lang.String propertyName

field

protected java.lang.reflect.Field field

nullValue

protected java.lang.Object nullValue
Constructor Detail

FieldAccessor

public FieldAccessor(java.lang.Class<?> objectClass,
                     java.lang.String propertyName,
                     java.lang.Class<?> propertyType)
Method Detail

getName

public java.lang.String getName()
Description copied from interface: Accessor
Returns property name.

Specified by:
getName in interface Accessor

getValue

public java.lang.Object getValue(java.lang.Object object)
                          throws PropertyException
Description copied from interface: Accessor
Returns a property value of an object without disturbing the object fault status.

Specified by:
getValue in interface Accessor
Throws:
PropertyException

setValue

public void setValue(java.lang.Object object,
                     java.lang.Object newValue)
              throws PropertyException
Description copied from interface: Accessor
Sets a property value of an object without disturbing the object fault status. Old value of the property is specified as a hint.

Specified by:
setValue in interface Accessor
Throws:
PropertyException
Since:
3.0

prepareField

protected java.lang.reflect.Field prepareField(java.lang.Class<?> beanClass,
                                               java.lang.String propertyName,
                                               java.lang.Class<?> propertyType)
Finds a field for the property, ensuring that direct access via reflection is possible.


lookupFieldInHierarchy

protected java.lang.reflect.Field lookupFieldInHierarchy(java.lang.Class<?> beanClass,
                                                         java.lang.String fieldName)
                                                  throws java.lang.SecurityException,
                                                         java.lang.NoSuchFieldException
Recursively looks for a named field in a class hierarchy.

Throws:
java.lang.SecurityException
java.lang.NoSuchFieldException


Copyright © 2001-2012 Apache Cayenne. All Rights Reserved.