public class SpelExpression extends java.lang.Object implements Expression
SpelExpression represents a parsed (valid) expression that is ready to be
evaluated in a specified context. An expression can be evaluated standalone or in a
specified context. During expression evaluation the context may be asked to resolve
references to types, beans, properties, and methods.| Constructor and Description |
|---|
SpelExpression(java.lang.String expression,
SpelNodeImpl ast,
SpelParserConfiguration configuration)
Construct an expression, only used by the parser.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
compileExpression()
Perform expression compilation.
|
SpelNode |
getAST()
Return the Abstract Syntax Tree for the expression.
|
EvaluationContext |
getEvaluationContext()
Return the default evaluation context that will be used if none is supplied on an evaluation call.
|
java.lang.String |
getExpressionString()
Return the original string used to create this expression (unmodified).
|
java.lang.Object |
getValue()
Evaluate this expression in the default standard context.
|
<T> T |
getValue(java.lang.Class<T> expectedResultType)
Evaluate the expression in the default context.
|
java.lang.Object |
getValue(EvaluationContext context)
Evaluate this expression in the provided context and return the result
of evaluation.
|
<T> T |
getValue(EvaluationContext context,
java.lang.Class<T> expectedResultType)
Evaluate the expression in a specified context which can resolve references
to properties, methods, types, etc.
|
java.lang.Object |
getValue(EvaluationContext context,
java.lang.Object rootObject)
Evaluate this expression in the provided context and return the result
of evaluation, but use the supplied root context as an override for any
default root object specified in the context.
|
<T> T |
getValue(EvaluationContext context,
java.lang.Object rootObject,
java.lang.Class<T> expectedResultType)
Evaluate the expression in a specified context which can resolve references
to properties, methods, types, etc.
|
java.lang.Object |
getValue(java.lang.Object rootObject)
Evaluate this expression against the specified root object.
|
<T> T |
getValue(java.lang.Object rootObject,
java.lang.Class<T> expectedResultType)
Evaluate the expression in the default context against the specified root
object.
|
java.lang.Class<?> |
getValueType()
Return the most general type that can be passed to a
Expression.setValue(java.lang.Object, java.lang.Object)
method using the default context. |
java.lang.Class<?> |
getValueType(EvaluationContext context)
Return the most general type that can be passed to the
Expression.setValue(EvaluationContext, Object) method for the given context. |
java.lang.Class<?> |
getValueType(EvaluationContext context,
java.lang.Object rootObject)
Return the most general type that can be passed to the
Expression.setValue(EvaluationContext, Object, Object) method for the given
context. |
java.lang.Class<?> |
getValueType(java.lang.Object rootObject)
Return the most general type that can be passed to the
Expression.setValue(Object, Object) method using the default context. |
org.springframework.core.convert.TypeDescriptor |
getValueTypeDescriptor()
Return the most general type that can be passed to a
Expression.setValue(java.lang.Object, java.lang.Object)
method using the default context. |
org.springframework.core.convert.TypeDescriptor |
getValueTypeDescriptor(EvaluationContext context)
Return the most general type that can be passed to the
Expression.setValue(EvaluationContext, Object) method for the given context. |
org.springframework.core.convert.TypeDescriptor |
getValueTypeDescriptor(EvaluationContext context,
java.lang.Object rootObject)
Return the most general type that can be passed to the
Expression.setValue(EvaluationContext, Object, Object) method for the given
context. |
org.springframework.core.convert.TypeDescriptor |
getValueTypeDescriptor(java.lang.Object rootObject)
Return the most general type that can be passed to the
Expression.setValue(Object, Object) method using the default context. |
boolean |
isWritable(EvaluationContext context)
Determine if an expression can be written to, i.e.
|
boolean |
isWritable(EvaluationContext context,
java.lang.Object rootObject)
Determine if an expression can be written to, i.e.
|
boolean |
isWritable(java.lang.Object rootObject)
Determine if an expression can be written to, i.e.
|
void |
revertToInterpreted()
Cause an expression to revert to being interpreted if it has been using a compiled
form.
|
void |
setEvaluationContext(EvaluationContext evaluationContext)
Set the evaluation context that will be used if none is specified on an evaluation call.
|
void |
setValue(EvaluationContext context,
java.lang.Object value)
Set this expression in the provided context to the value provided.
|
void |
setValue(EvaluationContext context,
java.lang.Object rootObject,
java.lang.Object value)
Set this expression in the provided context to the value provided.
|
void |
setValue(java.lang.Object rootObject,
java.lang.Object value)
Set this expression in the provided context to the value provided.
|
java.lang.String |
toStringAST()
Produce a string representation of the Abstract Syntax Tree for the expression.
|
public SpelExpression(java.lang.String expression,
SpelNodeImpl ast,
SpelParserConfiguration configuration)
public void setEvaluationContext(EvaluationContext evaluationContext)
evaluationContext - the evaluation context to usepublic EvaluationContext getEvaluationContext()
public java.lang.String getExpressionString()
ExpressiongetExpressionString in interface Expressionpublic java.lang.Object getValue()
throws EvaluationException
ExpressiongetValue in interface ExpressionEvaluationException - if there is a problem during evaluationpublic <T> T getValue(java.lang.Class<T> expectedResultType)
throws EvaluationException
ExpressiongetValue in interface ExpressionexpectedResultType - the class the caller would like the result to beEvaluationException - if there is a problem during evaluationpublic java.lang.Object getValue(java.lang.Object rootObject)
throws EvaluationException
ExpressiongetValue in interface ExpressionrootObject - the root object against which to evaluate the expressionEvaluationException - if there is a problem during evaluationpublic <T> T getValue(java.lang.Object rootObject,
java.lang.Class<T> expectedResultType)
throws EvaluationException
ExpressiongetValue in interface ExpressionrootObject - the root object against which to evaluate the expressionexpectedResultType - the class the caller would like the result to beEvaluationException - if there is a problem during evaluationpublic java.lang.Object getValue(EvaluationContext context) throws EvaluationException
ExpressiongetValue in interface Expressioncontext - the context in which to evaluate the expressionEvaluationException - if there is a problem during evaluationpublic <T> T getValue(EvaluationContext context, java.lang.Class<T> expectedResultType) throws EvaluationException
ExpressiongetValue in interface Expressioncontext - the context in which to evaluate the expressionexpectedResultType - the class the caller would like the result to beEvaluationException - if there is a problem during evaluationpublic java.lang.Object getValue(EvaluationContext context, java.lang.Object rootObject) throws EvaluationException
ExpressiongetValue in interface Expressioncontext - the context in which to evaluate the expressionrootObject - the root object against which to evaluate the expressionEvaluationException - if there is a problem during evaluationpublic <T> T getValue(EvaluationContext context, java.lang.Object rootObject, java.lang.Class<T> expectedResultType) throws EvaluationException
ExpressiongetValue in interface Expressioncontext - the context in which to evaluate the expressionrootObject - the root object against which to evaluate the expressionexpectedResultType - the class the caller would like the result to beEvaluationException - if there is a problem during evaluationpublic java.lang.Class<?> getValueType()
throws EvaluationException
ExpressionExpression.setValue(java.lang.Object, java.lang.Object)
method using the default context.getValueType in interface ExpressionEvaluationException - if there is a problem determining the typepublic java.lang.Class<?> getValueType(java.lang.Object rootObject)
throws EvaluationException
ExpressionExpression.setValue(Object, Object) method using the default context.getValueType in interface ExpressionrootObject - the root object against which to evaluate the expressionEvaluationException - if there is a problem determining the typepublic java.lang.Class<?> getValueType(EvaluationContext context) throws EvaluationException
ExpressionExpression.setValue(EvaluationContext, Object) method for the given context.getValueType in interface Expressioncontext - the context in which to evaluate the expressionEvaluationException - if there is a problem determining the typepublic java.lang.Class<?> getValueType(EvaluationContext context, java.lang.Object rootObject) throws EvaluationException
ExpressionExpression.setValue(EvaluationContext, Object, Object) method for the given
context. The supplied root object overrides any specified in the context.getValueType in interface Expressioncontext - the context in which to evaluate the expressionrootObject - the root object against which to evaluate the expressionEvaluationException - if there is a problem determining the typepublic org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor()
throws EvaluationException
ExpressionExpression.setValue(java.lang.Object, java.lang.Object)
method using the default context.getValueTypeDescriptor in interface ExpressionEvaluationException - if there is a problem determining the typepublic org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(java.lang.Object rootObject)
throws EvaluationException
ExpressionExpression.setValue(Object, Object) method using the default context.getValueTypeDescriptor in interface ExpressionrootObject - the root object against which to evaluate the expressionEvaluationException - if there is a problem determining the typepublic org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException
ExpressionExpression.setValue(EvaluationContext, Object) method for the given context.getValueTypeDescriptor in interface Expressioncontext - the context in which to evaluate the expressionEvaluationException - if there is a problem determining the typepublic org.springframework.core.convert.TypeDescriptor getValueTypeDescriptor(EvaluationContext context, java.lang.Object rootObject) throws EvaluationException
ExpressionExpression.setValue(EvaluationContext, Object, Object) method for the given
context. The supplied root object overrides any specified in the context.getValueTypeDescriptor in interface Expressioncontext - the context in which to evaluate the expressionrootObject - the root object against which to evaluate the expressionEvaluationException - if there is a problem determining the typepublic boolean isWritable(java.lang.Object rootObject)
throws EvaluationException
ExpressionisWritable in interface ExpressionrootObject - the root object against which to evaluate the expressiontrue if the expression is writable; false otherwiseEvaluationException - if there is a problem determining if it is writablepublic boolean isWritable(EvaluationContext context) throws EvaluationException
ExpressionisWritable in interface Expressioncontext - the context in which the expression should be checkedtrue if the expression is writable; false otherwiseEvaluationException - if there is a problem determining if it is writablepublic boolean isWritable(EvaluationContext context, java.lang.Object rootObject) throws EvaluationException
ExpressionisWritable in interface Expressioncontext - the context in which the expression should be checkedrootObject - the root object against which to evaluate the expressiontrue if the expression is writable; false otherwiseEvaluationException - if there is a problem determining if it is writablepublic void setValue(java.lang.Object rootObject,
java.lang.Object value)
throws EvaluationException
ExpressionsetValue in interface ExpressionrootObject - the root object against which to evaluate the expressionvalue - the new valueEvaluationException - if there is a problem during evaluationpublic void setValue(EvaluationContext context, java.lang.Object value) throws EvaluationException
ExpressionsetValue in interface Expressioncontext - the context in which to set the value of the expressionvalue - the new valueEvaluationException - if there is a problem during evaluationpublic void setValue(EvaluationContext context, java.lang.Object rootObject, java.lang.Object value) throws EvaluationException
ExpressionsetValue in interface Expressioncontext - the context in which to set the value of the expressionrootObject - the root object against which to evaluate the expressionvalue - the new valueEvaluationException - if there is a problem during evaluationpublic boolean compileExpression()
public void revertToInterpreted()
public SpelNode getAST()
public java.lang.String toStringAST()