org.apache.cayenne.reflect
Class FieldAccessor

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

public class FieldAccessor
extends Object
implements Accessor

A PropertyAccessor that performs direct Field access.

Since:
1.2
Author:
Andrus Adamchik
See Also:
Serialized Form

Field Summary
protected  Field field
           
protected  Object nullValue
           
protected  String propertyName
           
 
Constructor Summary
FieldAccessor(Class objectClass, String propertyName, Class propertyType)
           
 
Method Summary
 String getName()
          Returns property name.
 Object getValue(Object object)
          Returns a property value of an object without disturbing the object fault status.
protected  Field lookupFieldInHierarchy(Class beanClass, String fieldName)
          Recursively looks for a named field in a class hierarchy.
protected  Field prepareField(Class beanClass, String propertyName, Class propertyType)
          Finds a field for the property, ensuring that direct access via reflection is possible.
 void setValue(Object object, 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 String propertyName

field

protected Field field

nullValue

protected Object nullValue
Constructor Detail

FieldAccessor

public FieldAccessor(Class objectClass,
                     String propertyName,
                     Class propertyType)
Method Detail

getName

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

Specified by:
getName in interface Accessor

getValue

public Object getValue(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(Object object,
                     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 Field prepareField(Class beanClass,
                             String propertyName,
                             Class propertyType)
Finds a field for the property, ensuring that direct access via reflection is possible.


lookupFieldInHierarchy

protected Field lookupFieldInHierarchy(Class beanClass,
                                       String fieldName)
                                throws SecurityException,
                                       NoSuchFieldException
Recursively looks for a named field in a class hierarchy.

Throws:
SecurityException
NoSuchFieldException


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