public class ExpressionUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ExpressionUtil.ExpressionMethodResolver
This class contains several utility methods that can be called from within
expressions.
|
Constructor and Description |
---|
ExpressionUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
evaluateExpressions(String textWithExpressions,
Map<String,String> params,
boolean recursive)
This method will evaluate any expressions within the given textWithExpressions,
using the given parameter map as evaluation context.
|
public static final String evaluateExpressions(String textWithExpressions, Map<String,String> params, boolean recursive)
This method will evaluate any expressions within the given textWithExpressions, using the given parameter map as evaluation context. Expressions need to be delimited by double exclamation marks, i.e. 'regularText !!expression!! moreRegularText !!otherExpression'.
Expressions can reference entries from the given parameter map by key, i.e. for a map with key 'mapKey' and corresponding value 'mapValue', the expression '!!mapKey!!' will evaluate to 'mapValue'.
Expressions can also use the methods as defined in ExpressionUtil.ExpressionMethodResolver
,
for example '!!prefix("a","b")!!' will evaluate to 'ab'.
If the recursive parameter is set to true, expressions will be evaluated recursively. I.e. if the parameter map contains a key 'myKey' with value '!!otherKey!!', and another entry 'otherKey' mapped to 'otherValue', the expression '!!myKey!!' will evaluate to 'otherValue' if recursive is set to true, or '!!otherKey!!' if recursive is set to false.
Expressions use the Spring Expression Language syntax; please refer to the Spring framework documentation for more details.
textWithExpressions
- params
- recursive
- Copyright © 2013. All rights reserved.