net.sourceforge.stripes.util.bean
Class JavaBeanPropertyAccessor

java.lang.Object
  extended by net.sourceforge.stripes.util.bean.JavaBeanPropertyAccessor
All Implemented Interfaces:
PropertyAccessor<Object>

public class JavaBeanPropertyAccessor
extends Object
implements PropertyAccessor<Object>

Implementation of PropertyAccessor for reading JavaBean properties from JavaBeans. Will attempt property access first using the standard PropertyDescriptor, but if no PropertyDescriptor is present then falls back to attempting Field access for public fields.

Since:
Stripes 1.4
Author:
Tim Fennell

Constructor Summary
JavaBeanPropertyAccessor()
           
 
Method Summary
 Object getValue(NodeEvaluation evaluation, Object bean)
          Fetches the specified property value from the bean if it exists.
 void setValue(NodeEvaluation evaluation, Object bean, Object value)
          Sets the specified property value to the supplied value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaBeanPropertyAccessor

public JavaBeanPropertyAccessor()
Method Detail

getValue

public Object getValue(NodeEvaluation evaluation,
                       Object bean)
                throws NoSuchPropertyException,
                       EvaluationException
Fetches the specified property value from the bean if it exists.

Specified by:
getValue in interface PropertyAccessor<Object>
Parameters:
evaluation - the current node evaluation
bean - the bean from which to fetch the property
Returns:
the value of the property
Throws:
NoSuchPropertyException - if there is no property with the supplied name
EvaluationException - if the value cannot be retrieved for any other reason

setValue

public void setValue(NodeEvaluation evaluation,
                     Object bean,
                     Object value)
Sets the specified property value to the supplied value.

Specified by:
setValue in interface PropertyAccessor<Object>
Parameters:
evaluation - the current node evaluation
bean - the bean on to which to set the property
value - the value of the property
Throws:
NoSuchPropertyException - if there is no property with the supplied name
EvaluationException - if the value cannot be set for any other reason


? Copyright 2005-2006, Stripes Development Team.