Cleaning up after Keith. :)
This commit is contained in:
@@ -23,6 +23,17 @@ package org.springframework.binding.expression;
|
||||
*/
|
||||
public interface ExpressionParser {
|
||||
|
||||
/**
|
||||
* Is the provided expression string an "eval" expression: meaning an expression that validates to a dynamic value,
|
||||
* and not a literal expression? "Eval" expressions are normally enclosed in delimiters like #{}, where literal
|
||||
* expressions are not delimited.
|
||||
*
|
||||
* TODO - candidate for removal in a future milestone: is this really needed?
|
||||
* @param string the string
|
||||
* @return true if the expression is an eval expression string, false otherwise.
|
||||
*/
|
||||
public boolean isEvalExpressionString(String string);
|
||||
|
||||
/**
|
||||
* Parse the provided expression string, returning an expression evaluator capable of evaluating it.
|
||||
* @param expressionString the parseable expression string; cannot be null
|
||||
|
||||
@@ -22,6 +22,16 @@ import org.springframework.binding.expression.ParserException;
|
||||
*/
|
||||
public class ELExpressionParser implements ExpressionParser {
|
||||
|
||||
/**
|
||||
* The expression prefix.
|
||||
*/
|
||||
private static final String EXPRESSION_PREFIX = "#{";
|
||||
|
||||
/**
|
||||
* The expression suffix.
|
||||
*/
|
||||
private static final String EXPRESSION_SUFFIX = "}";
|
||||
|
||||
/**
|
||||
* The ExpressionFactory for constructing EL expressions
|
||||
*/
|
||||
@@ -45,6 +55,10 @@ public class ELExpressionParser implements ExpressionParser {
|
||||
this.contextFactories.put(expressionTargetType, contextFactory);
|
||||
}
|
||||
|
||||
public boolean isEvalExpressionString(String expressionString) {
|
||||
return expressionString.startsWith(EXPRESSION_PREFIX) && expressionString.endsWith(EXPRESSION_SUFFIX);
|
||||
}
|
||||
|
||||
public Expression parseExpression(String expressionString, Class expressionTargetType,
|
||||
Class expectedEvaluationResultType, ExpressionVariable[] expressionVariables) throws ParserException {
|
||||
if (expectedEvaluationResultType == null) {
|
||||
|
||||
@@ -80,6 +80,10 @@ public abstract class AbstractExpressionParser implements ExpressionParser {
|
||||
this.expressionSuffix = expressionSuffix;
|
||||
}
|
||||
|
||||
public boolean isEvalExpressionString(String string) {
|
||||
return string.startsWith(expressionPrefix) && string.endsWith(expressionSuffix);
|
||||
}
|
||||
|
||||
public Expression parseExpression(String expressionString, Class expressionTargetType,
|
||||
Class expectedEvaluationResultType, ExpressionVariable[] expressionVariables) throws ParserException {
|
||||
Assert.notNull(expressionString, "The expression string to parse is required");
|
||||
|
||||
Reference in New Issue
Block a user