Class CompositeStringExpression
- All Implemented Interfaces:
Expression
Each piece will be an Expression, but pure text parts of the
template will be represented as LiteralExpression objects. An example
of a template expression might be:
"Hello ${getName()}"
which will be represented as a CompositeStringExpression of two parts:
the first part being a LiteralExpression representing 'Hello ' and the
second part being a real expression that will call getName() when invoked.- Since:
- 3.0
- Author:
- Andy Clement, Juergen Hoeller
-
Constructor Summary
ConstructorsConstructorDescriptionCompositeStringExpression(String expressionString, Expression[] expressions) -
Method Summary
Modifier and TypeMethodDescriptionfinal Expression[]final StringReturn the original string used to create this expression (unmodified).getValue()Evaluate this expression in the default context and return the result of evaluation.<T> @Nullable TEvaluate 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> @Nullable TEvaluate 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> @Nullable TgetValue(EvaluationContext context, @Nullable Class<T> expectedResultType) Evaluate this expression in the provided context and return the result of evaluation.getValue(EvaluationContext context, @Nullable Object rootObject) Evaluate this expression in the provided context against the specified root object and return the result of evaluation.<T> @Nullable TgetValue(EvaluationContext context, @Nullable Object rootObject, @Nullable 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 theExpression.setValue(EvaluationContext, Object)method using the default context.Class<?> getValueType(@Nullable Object rootObject) Return the most general type that can be passed to theExpression.setValue(Object, Object)method using the default context.Class<?> getValueType(EvaluationContext context) Return the most general type that can be passed to theExpression.setValue(EvaluationContext, Object)method for the given context.Class<?> getValueType(EvaluationContext context, @Nullable Object rootObject) Return the most general type that can be passed to theExpression.setValue(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(@Nullable Object rootObject) Return a descriptor for the most general type that can be passed to theExpression.setValue(Object, Object)method using the default context.getValueTypeDescriptor(EvaluationContext context) Return a descriptor for the most general type that can be passed to theExpression.setValue(EvaluationContext, Object)method for the given context.getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject) Return a descriptor for the most general type that can be passed to theExpression.setValue(EvaluationContext, Object, Object)method for the given context.booleanisWritable(@Nullable Object rootObject) Determine if this expression can be written to, i.e.booleanisWritable(EvaluationContext context) Determine if this expression can be written to, i.e.booleanisWritable(EvaluationContext context, @Nullable Object rootObject) Determine if this expression can be written to, i.e.voidSet this expression in the default context to the value provided.voidsetValue(EvaluationContext context, @Nullable Object value) Set this expression in the provided context to the value provided.voidSet this expression in the provided context to the value provided.
-
Constructor Details
-
CompositeStringExpression
-
-
Method Details
-
getExpressionString
Description copied from interface:ExpressionReturn the original string used to create this expression (unmodified).- Specified by:
getExpressionStringin interfaceExpression- Returns:
- the original expression string
-
getExpressions
-
getValue
Description copied from interface:ExpressionEvaluate this expression in the default context and return the result of evaluation.- Specified by:
getValuein interfaceExpression- Returns:
- the evaluation result
- Throws:
EvaluationException- if there is a problem during evaluation
-
getValue
Description copied from interface:ExpressionEvaluate 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.
- Specified by:
getValuein interfaceExpression- Parameters:
expectedResultType- the type the caller would like the result to be- Returns:
- the evaluation result
- Throws:
EvaluationException- if there is a problem during evaluation
-
getValue
Description copied from interface:ExpressionEvaluate this expression in the default context against the specified root object and return the result of evaluation.- Specified by:
getValuein interfaceExpression- 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
public <T> @Nullable T getValue(@Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException Description copied from interface:ExpressionEvaluate 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.
- Specified by:
getValuein interfaceExpression- 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
Description copied from interface:ExpressionEvaluate this expression in the provided context and return the result of evaluation.- Specified by:
getValuein interfaceExpression- Parameters:
context- the context in which to evaluate the expression- Returns:
- the evaluation result
- Throws:
EvaluationException- if there is a problem during evaluation
-
getValue
public <T> @Nullable T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException Description copied from interface:ExpressionEvaluate 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.
- Specified by:
getValuein interfaceExpression- Parameters:
context- the context in which to evaluate the expressionexpectedResultType- the type the caller would like the result to be- Returns:
- the evaluation result
- Throws:
EvaluationException- if there is a problem during evaluation
-
getValue
public String getValue(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException Description copied from interface:ExpressionEvaluate 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.
- Specified by:
getValuein interfaceExpression- 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
public <T> @Nullable T getValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException Description copied from interface:ExpressionEvaluate 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.
- Specified by:
getValuein interfaceExpression- 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
Description copied from interface:ExpressionReturn the most general type that can be passed to theExpression.setValue(EvaluationContext, Object)method using the default context.- Specified by:
getValueTypein interfaceExpression- Returns:
- the most general type of value that can be set in this context
-
getValueType
Description copied from interface:ExpressionReturn the most general type that can be passed to theExpression.setValue(EvaluationContext, Object)method for the given context.- Specified by:
getValueTypein interfaceExpression- Parameters:
context- the context in which to evaluate the expression- Returns:
- the most general type of value that can be set in this context
-
getValueType
Description copied from interface:ExpressionReturn the most general type that can be passed to theExpression.setValue(Object, Object)method using the default context.- Specified by:
getValueTypein interfaceExpression- 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
public Class<?> getValueType(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException Description copied from interface:ExpressionReturn the most general type that can be passed to theExpression.setValue(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.
- Specified by:
getValueTypein interfaceExpression- 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
Description copied from interface:ExpressionReturn a descriptor for the most general type that can be passed to one of thesetValue(...)methods using the default context.- Specified by:
getValueTypeDescriptorin interfaceExpression- Returns:
- a type descriptor for values that can be set in this context
-
getValueTypeDescriptor
public TypeDescriptor getValueTypeDescriptor(@Nullable Object rootObject) throws EvaluationException Description copied from interface:ExpressionReturn a descriptor for the most general type that can be passed to theExpression.setValue(Object, Object)method using the default context.- Specified by:
getValueTypeDescriptorin interfaceExpression- 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
Description copied from interface:ExpressionReturn a descriptor for the most general type that can be passed to theExpression.setValue(EvaluationContext, Object)method for the given context.- Specified by:
getValueTypeDescriptorin interfaceExpression- Parameters:
context- the context in which to evaluate the expression- Returns:
- a type descriptor for values that can be set in this context
-
getValueTypeDescriptor
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException Description copied from interface:ExpressionReturn a descriptor for the most general type that can be passed to theExpression.setValue(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.
- Specified by:
getValueTypeDescriptorin interfaceExpression- 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
Description copied from interface:ExpressionDetermine if this expression can be written to, i.e. setValue() can be called.- Specified by:
isWritablein interfaceExpression- Parameters:
rootObject- the root object against which to evaluate the expression- Returns:
trueif the expression is writable;falseotherwise- Throws:
EvaluationException- if there is a problem determining if it is writable
-
isWritable
Description copied from interface:ExpressionDetermine if this expression can be written to, i.e. setValue() can be called.- Specified by:
isWritablein interfaceExpression- Parameters:
context- the context in which the expression should be checked- Returns:
trueif the expression is writable;falseotherwise
-
isWritable
public boolean isWritable(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException Description copied from interface:ExpressionDetermine 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.
- Specified by:
isWritablein interfaceExpression- Parameters:
context- the context in which the expression should be checkedrootObject- the root object against which to evaluate the expression- Returns:
trueif the expression is writable;falseotherwise- Throws:
EvaluationException- if there is a problem determining if it is writable
-
setValue
public void setValue(@Nullable Object rootObject, @Nullable Object value) throws EvaluationException Description copied from interface:ExpressionSet this expression in the default context to the value provided.- Specified by:
setValuein interfaceExpression- Parameters:
rootObject- the root object against which to evaluate the expressionvalue- the new value- Throws:
EvaluationException- if there is a problem during evaluation
-
setValue
Description copied from interface:ExpressionSet this expression in the provided context to the value provided.- Specified by:
setValuein interfaceExpression- 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
public void setValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value) throws EvaluationException Description copied from interface:ExpressionSet 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.
- Specified by:
setValuein interfaceExpression- 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
-