public class BeanUtil
extends java.lang.Object
Provides a simple way to manipulate properties and nested properties specified by complex
property expressions. It should be noted that while the interface to this class is simple it
will be more efficient to use PropertyExpressionEvaluation
directly if you plan
to call more than one of the methods in this class with the same exact expression.
Constructor and Description |
---|
BeanUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Class<?> |
getPropertyType(java.lang.String expression,
java.lang.Object bean)
Attempts to determine the type of the property specified by the property expression
in the context of the supplied bean.
|
static java.lang.Object |
getPropertyValue(java.lang.String expression,
java.lang.Object bean)
Attempts to fetch the property specified by the property expression
in the context of the supplied bean.
|
static void |
setPropertyToNull(java.lang.String expression,
java.lang.Object bean)
Attempts to set the property to null or an equivalent value.
|
static void |
setPropertyValue(java.lang.String expression,
java.lang.Object bean,
java.lang.Object value)
Attempts to set the property specified by the property expression
in the context of the supplied bean.
|
public static java.lang.Class<?> getPropertyType(java.lang.String expression, java.lang.Object bean) throws ParseException, EvaluationException
expression
- an expression representing a property or nested/indexed propertybean
- the bean against which to evaluate the expressiongetPropertyValue(String, Object)
were invoked with the same parametersParseException
- if the expression is invalid and cannot be parsedEvaluationException
- if the expression is valid, but cannot be evaluated against
this beanpublic static java.lang.Object getPropertyValue(java.lang.String expression, java.lang.Object bean) throws ParseException, EvaluationException
expression
- an expression representing a property or nested/indexed propertybean
- the bean against which to evaluate the expressionParseException
- if the expression is invalid and cannot be parsedEvaluationException
- if the expression is valid, but cannot be evaluated against
this beanpublic static void setPropertyValue(java.lang.String expression, java.lang.Object bean, java.lang.Object value) throws ParseException, EvaluationException
expression
- an expression representing a property or nested/indexed propertybean
- the bean against which to evaluate the expressionvalue
- the value to be set for the property, may be nullParseException
- if the expression is invalid and cannot be parsedEvaluationException
- if the expression is valid, but cannot be evaluated against
this beanpublic static void setPropertyToNull(java.lang.String expression, java.lang.Object bean) throws ParseException, EvaluationException
expression
- an expression representing a property or nested/indexed propertybean
- the bean against which to evaluate the expressionParseException
- if the expression is invalid and cannot be parsedEvaluationException
- if the expression is valid, but cannot be evaluated against
this bean? Copyright 2005-2006, Stripes Development Team.