public class BeanWrapperExpression extends java.lang.Object implements Expression
bean wrapper to evaluate or set a property of a context.
Also supports the configuration of a ConversionService to allow StringToObject type conversion to occur as
part of setting a property. The StringToObject ConversionExecutors are automatically adapted and registered as
PropertyEditors.
Mainly exists to take advantage of BeanWrapper's unique property access features as an Expression implementation,
notably the ability to infer types of generic collections and maps and perform type coersion on collection elements
when setting values.
Note that Spring's BeanWrapper is not a full-blown EL implementation: it only supports property access, and does not
support method invocation, arithmetic operations, or logic operations.| Constructor and Description |
|---|
BeanWrapperExpression(java.lang.String expression,
ConversionService conversionService)
Creates a new bean wrapper expression.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getExpressionString()
Returns the original string used to create this expression, unmodified.
|
java.lang.Object |
getValue(java.lang.Object context)
Evaluate this expression in the provided context and return the result of evaluation.
|
java.lang.Class<?> |
getValueType(java.lang.Object context)
Returns the most general type that can be passed to the
Expression.setValue(Object, Object) method for the given
context. |
int |
hashCode() |
void |
setAutoGrowCollectionLimit(int autoGrowCollectionLimit)
Specify a limit for array and collection auto-growing.
|
void |
setAutoGrowNestedPaths(boolean autoGrowNestedPaths)
Set whether this BeanWrapper should attempt to "auto-grow" a nested path that contains a null value.
|
void |
setValue(java.lang.Object context,
java.lang.Object value)
Set this expression in the provided context to the value provided.
|
java.lang.String |
toString() |
public BeanWrapperExpression(java.lang.String expression,
ConversionService conversionService)
expression - the property expression stringconversionService - the conversion service containing converters to use as PropertyEditors for type
conversionpublic void setAutoGrowNestedPaths(boolean autoGrowNestedPaths)
If "true", a null path location will be populated with a default object value and traversed
instead of resulting in a NullValueInNestedPathException. Turning this flag on also
enables auto-growth of collection elements when accessing an out-of-bounds index.
Default is "false" on a plain BeanWrapper.
public void setAutoGrowCollectionLimit(int autoGrowCollectionLimit)
Default is unlimited on a plain BeanWrapper.
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Object getValue(java.lang.Object context)
throws EvaluationException
ExpressiongetValue in interface Expressioncontext - the context to evaluate this expression inEvaluationException - an exception occurred during expression evaluationpublic void setValue(java.lang.Object context,
java.lang.Object value)
ExpressionsetValue in interface Expressioncontext - the context on which the new value should be setvalue - the new value to setpublic java.lang.Class<?> getValueType(java.lang.Object context)
ExpressionExpression.setValue(Object, Object) method for the given
context.getValueType in interface Expressioncontext - the context to evaluatenull if the type
information cannot be determinedpublic java.lang.String getExpressionString()
ExpressiongetExpressionString in interface Expressionpublic java.lang.String toString()
toString in class java.lang.Object