Interface Expression
- All Known Implementing Classes:
CompositeStringExpression
,LiteralExpression
,SpelExpression
Encapsulates the details of a previously parsed expression string.
Provides a common abstraction for expression evaluation.
- Since:
- 3.0
- Author:
- Keith Donald, Andy Clement, Juergen Hoeller
-
Method Summary
Modifier and TypeMethodDescriptionReturn the original string used to create this expression (unmodified).getValue()
Evaluate this expression in the default context and return the result of evaluation.<T> T
Evaluate this expression in the default context and return the result of evaluation.Evaluate this expression in the default context against the specified root object and return the result of evaluation.<T> T
Evaluate this expression in the default context against the specified root object and return the result of evaluation.getValue
(EvaluationContext context) Evaluate this expression in the provided context and return the result of evaluation.<T> T
getValue
(EvaluationContext context, Class<T> desiredResultType) Evaluate this expression in the provided context and return the result of evaluation.getValue
(EvaluationContext context, Object rootObject) Evaluate this expression in the provided context against the specified root object and return the result of evaluation.<T> T
getValue
(EvaluationContext context, Object rootObject, Class<T> desiredResultType) Evaluate this expression in the provided context against the specified root object and return the result of evaluation.Class<?>
Return the most general type that can be passed to thesetValue(EvaluationContext, Object)
method using the default context.Class<?>
getValueType
(Object rootObject) Return the most general type that can be passed to thesetValue(Object, Object)
method using the default context.Class<?>
getValueType
(EvaluationContext context) Return the most general type that can be passed to thesetValue(EvaluationContext, Object)
method for the given context.Class<?>
getValueType
(EvaluationContext context, Object rootObject) Return the most general type that can be passed to thesetValue(EvaluationContext, Object, Object)
method for the given context.Return a descriptor for the most general type that can be passed to one of thesetValue(...)
methods using the default context.getValueTypeDescriptor
(Object rootObject) Return a descriptor for the most general type that can be passed to thesetValue(Object, Object)
method using the default context.getValueTypeDescriptor
(EvaluationContext context) Return a descriptor for the most general type that can be passed to thesetValue(EvaluationContext, Object)
method for the given context.getValueTypeDescriptor
(EvaluationContext context, Object rootObject) Return a descriptor for the most general type that can be passed to thesetValue(EvaluationContext, Object, Object)
method for the given context.boolean
isWritable
(Object rootObject) Determine if this expression can be written to, i.e.boolean
isWritable
(EvaluationContext context) Determine if this expression can be written to, i.e.boolean
isWritable
(EvaluationContext context, Object rootObject) Determine if this expression can be written to, i.e.void
Set this expression in the default context to the value provided.void
setValue
(EvaluationContext context, Object value) Set this expression in the provided context to the value provided.void
setValue
(EvaluationContext context, Object rootObject, Object value) Set this expression in the provided context to the value provided.
-
Method Details
-
getExpressionString
String getExpressionString()Return the original string used to create this expression (unmodified).- Returns:
- the original expression string
-
getValue
Evaluate this expression in the default context and return the result of evaluation.- Returns:
- the evaluation result
- Throws:
EvaluationException
- if there is a problem during evaluation
-
getValue
Evaluate this expression in the default context and return the result of evaluation.If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.
- Parameters:
desiredResultType
- the type the caller would like the result to be- Returns:
- the evaluation result
- Throws:
EvaluationException
- if there is a problem during evaluation
-
getValue
Evaluate this expression in the default context against the specified root object and return the result of evaluation.- Parameters:
rootObject
- the root object against which to evaluate the expression- Returns:
- the evaluation result
- Throws:
EvaluationException
- if there is a problem during evaluation
-
getValue
@Nullable <T> T getValue(@Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException Evaluate this expression in the default context against the specified root object and return the result of evaluation.If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.
- Parameters:
rootObject
- the root object against which to evaluate the expressiondesiredResultType
- the type the caller would like the result to be- Returns:
- the evaluation result
- Throws:
EvaluationException
- if there is a problem during evaluation
-
getValue
Evaluate this expression in the provided context and return the result of evaluation.- Parameters:
context
- the context in which to evaluate the expression- Returns:
- the evaluation result
- Throws:
EvaluationException
- if there is a problem during evaluation
-
getValue
@Nullable Object getValue(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException Evaluate this expression in the provided context against the specified root object and return the result of evaluation.The supplied root object will be used as an override for any default root object configured in the context.
- Parameters:
context
- the context in which to evaluate the expressionrootObject
- the root object against which to evaluate the expression- Returns:
- the evaluation result
- Throws:
EvaluationException
- if there is a problem during evaluation
-
getValue
@Nullable <T> T getValue(EvaluationContext context, @Nullable Class<T> desiredResultType) throws EvaluationException Evaluate this expression in the provided context and return the result of evaluation.If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.
- Parameters:
context
- the context in which to evaluate the expressiondesiredResultType
- the type the caller would like the result to be- Returns:
- the evaluation result
- Throws:
EvaluationException
- if there is a problem during evaluation
-
getValue
@Nullable <T> T getValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException Evaluate this expression in the provided context against the specified root object and return the result of evaluation.The supplied root object will be used as an override for any default root object configured in the context.
If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be thrown.
- Parameters:
context
- the context in which to evaluate the expressionrootObject
- the root object against which to evaluate the expressiondesiredResultType
- the type the caller would like the result to be- Returns:
- the evaluation result
- Throws:
EvaluationException
- if there is a problem during evaluation
-
getValueType
Return the most general type that can be passed to thesetValue(EvaluationContext, Object)
method using the default context.- Returns:
- the most general type of value that can be set in this context
- Throws:
EvaluationException
- if there is a problem determining the type
-
getValueType
Return the most general type that can be passed to thesetValue(Object, Object)
method using the default context.- Parameters:
rootObject
- the root object against which to evaluate the expression- Returns:
- the most general type of value that can be set in this context
- Throws:
EvaluationException
- if there is a problem determining the type
-
getValueType
Return the most general type that can be passed to thesetValue(EvaluationContext, Object)
method for the given context.- Parameters:
context
- the context in which to evaluate the expression- Returns:
- the most general type of value that can be set in this context
- Throws:
EvaluationException
- if there is a problem determining the type
-
getValueType
@Nullable Class<?> getValueType(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException Return the most general type that can be passed to thesetValue(EvaluationContext, Object, Object)
method for the given context.The supplied root object will be used as an override for any default root object configured in the context.
- Parameters:
context
- the context in which to evaluate the expressionrootObject
- the root object against which to evaluate the expression- Returns:
- the most general type of value that can be set in this context
- Throws:
EvaluationException
- if there is a problem determining the type
-
getValueTypeDescriptor
Return a descriptor for the most general type that can be passed to one of thesetValue(...)
methods using the default context.- Returns:
- a type descriptor for values that can be set in this context
- Throws:
EvaluationException
- if there is a problem determining the type
-
getValueTypeDescriptor
@Nullable TypeDescriptor getValueTypeDescriptor(@Nullable Object rootObject) throws EvaluationException Return a descriptor for the most general type that can be passed to thesetValue(Object, Object)
method using the default context.- Parameters:
rootObject
- the root object against which to evaluate the expression- Returns:
- a type descriptor for values that can be set in this context
- Throws:
EvaluationException
- if there is a problem determining the type
-
getValueTypeDescriptor
@Nullable TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException Return a descriptor for the most general type that can be passed to thesetValue(EvaluationContext, Object)
method for the given context.- Parameters:
context
- the context in which to evaluate the expression- Returns:
- a type descriptor for values that can be set in this context
- Throws:
EvaluationException
- if there is a problem determining the type
-
getValueTypeDescriptor
@Nullable TypeDescriptor getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException Return a descriptor for the most general type that can be passed to thesetValue(EvaluationContext, Object, Object)
method for the given context.The supplied root object will be used as an override for any default root object configured in the context.
- Parameters:
context
- the context in which to evaluate the expressionrootObject
- the root object against which to evaluate the expression- Returns:
- a type descriptor for values that can be set in this context
- Throws:
EvaluationException
- if there is a problem determining the type
-
isWritable
Determine if this expression can be written to, i.e. setValue() can be called.- Parameters:
rootObject
- the root object against which to evaluate the expression- Returns:
true
if the expression is writable;false
otherwise- Throws:
EvaluationException
- if there is a problem determining if it is writable
-
isWritable
Determine if this expression can be written to, i.e. setValue() can be called.- Parameters:
context
- the context in which the expression should be checked- Returns:
true
if the expression is writable;false
otherwise- Throws:
EvaluationException
- if there is a problem determining if it is writable
-
isWritable
boolean isWritable(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException Determine if this expression can be written to, i.e. setValue() can be called.The supplied root object will be used as an override for any default root object configured in the context.
- Parameters:
context
- the context in which the expression should be checkedrootObject
- the root object against which to evaluate the expression- Returns:
true
if the expression is writable;false
otherwise- Throws:
EvaluationException
- if there is a problem determining if it is writable
-
setValue
Set this expression in the default context to the value provided.- Parameters:
rootObject
- the root object against which to evaluate the expressionvalue
- the new value- Throws:
EvaluationException
- if there is a problem during evaluation
-
setValue
Set this expression in the provided context to the value provided.- Parameters:
context
- the context in which to set the value of the expressionvalue
- the new value- Throws:
EvaluationException
- if there is a problem during evaluation
-
setValue
void setValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value) throws EvaluationException Set this expression in the provided context to the value provided.The supplied root object will be used as an override for any default root object configured in the context.
- Parameters:
context
- the context in which to set the value of the expressionrootObject
- the root object against which to evaluate the expressionvalue
- the new value- Throws:
EvaluationException
- if there is a problem during evaluation
-