1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springmodules.validation.util.cel.valang;
18
19 import org.springmodules.validation.util.cel.CelParseException;
20 import org.springmodules.validation.util.cel.ConditionExpressionParser;
21 import org.springmodules.validation.util.condition.Condition;
22 import org.springmodules.validation.util.condition.adapter.CommonsPredicateCondition;
23 import org.springmodules.validation.valang.parser.ParseException;
24 import org.springmodules.validation.valang.parser.SimpleValangBased;
25
26 /**
27 * A {@link ConditionExpressionParser} implementation that knows how to parse valang boolean expressions.
28 *
29 * @author Uri Boness
30 */
31 public class ValangConditionExpressionParser extends SimpleValangBased implements ConditionExpressionParser {
32
33 public Condition parse(String expression) throws CelParseException {
34 try {
35 return new CommonsPredicateCondition(createValangParser(expression).parseExpression());
36 } catch (ParseException pe) {
37 throw new CelParseException("Could not parse valang expression '" + expression + "'", pe);
38 }
39 }
40
41 }