{
parser.validate(expression);
}
catch (IllegalArgumentException e)
{
throw new InvalidExpressionException(expression, e.getMessage());
}
final AtomicBoolean valid = new AtomicBoolean(true);
final AtomicBoolean match = new AtomicBoolean(false);
final StringBuilder message = new StringBuilder();
parser.parse(new TemplateParser.TemplateCallback()
{
public Object match(String token)
{
match.set(true);
if (!isEvaluatorExpression(token))
{
if (valid.get())
{
try
{
expressionLanguage.validate(token);
}
catch (InvalidExpressionException e)
{
valid.compareAndSet(true, false);
message.append(token).append(" is invalid\n");
message.append(e.getMessage());
}
}
}
return null;
}
}, expression);
if (message.length() > 0)
{
throw new InvalidExpressionException(expression, message.toString());
}
else if (!match.get())
{
throw new InvalidExpressionException(expression,
"Expression string is not an expression. Use isExpression(String) to validate first");
}
}