has delimited expression

This commit is contained in:
Keith Donald
2008-01-19 17:00:34 +00:00
parent 0a09290635
commit c181b5d075
5 changed files with 33 additions and 6 deletions

View File

@@ -25,11 +25,13 @@ public interface ExpressionParser {
/**
* Is the provided string an explicitly delimited expression this parser knows how to parse? For example, this
* method might return true if the string provided is enclosed in ${}.
* method may return true if the string provided is enclosed in "${}". It may also return true if the string
* provided is a mix of literal text and delimited expression syntax, for example "hello world ${name}!" The exact
* semantics are determined by the parser implementation.
* @param string the string
* @return true if the string is a delimited expression, false otherwise.
*/
public boolean isDelimitedExpression(String string);
public boolean hasDelimitedExpression(String string);
/**
* Parse the provided expression string, returning an expression evaluator capable of evaluating it.

View File

@@ -65,7 +65,7 @@ public class ELExpressionParser implements ExpressionParser {
contextFactories.put(contextType, contextFactory);
}
public boolean isDelimitedExpression(String expressionString) {
public boolean hasDelimitedExpression(String expressionString) {
return (expressionString.startsWith(EXPRESSION_PREFIX_DEFERRED) && expressionString.endsWith(EXPRESSION_SUFFIX))
|| (expressionString.startsWith(EXPRESSION_PREFIX_IMMEDIATE) && expressionString
.endsWith(EXPRESSION_SUFFIX));

View File

@@ -80,7 +80,7 @@ public abstract class AbstractExpressionParser implements ExpressionParser {
this.expressionSuffix = expressionSuffix;
}
public boolean isDelimitedExpression(String string) {
public boolean hasDelimitedExpression(String string) {
int prefixIndex = string.indexOf(getExpressionPrefix());
if (prefixIndex == -1) {
return false;