This commit is contained in:
Keith Donald
2008-03-06 05:32:45 +00:00
parent 4f95e0711a
commit 16ad62f2f7
2 changed files with 22 additions and 0 deletions

View File

@@ -133,6 +133,9 @@ public class OgnlExpressionParser implements ExpressionParser {
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException {
Assert.notNull(expressionString, "The expression string to parse is required");
if (expressionString.length() == 0) {
return parseEmptyExpressionString(context);
}
Expression[] expressions = parseExpressions(expressionString, context);
if (expressions.length == 1) {
return expressions[0];
@@ -192,6 +195,19 @@ public class OgnlExpressionParser implements ExpressionParser {
// helper methods
/**
* Helper that handles a empty expression string.
*/
private Expression parseEmptyExpressionString(ParserContext context) {
if (allowUndelimitedEvalExpressions) {
// let the parser handle it
return doParseExpression("", context);
} else {
// return a literal expression containing the empty string
return new LiteralExpression("");
}
}
/**
* Helper that parses given expression string using the configured parser. The expression string can contain any
* number of expressions all contained in "${...}" markers. For instance: "foo${expr0}bar${expr1}". The static