01: package org.concern.library.generic;
02:
03: import org.concern.controller.AbstractCondition;
04: import org.concern.controller.ConditionEvaluationException;
05: import ognl.Ognl;
06: import ognl.OgnlException;
07:
08: /**
09: * @author hengels
10: * @version $Revision$
11: */
12: public class BooleanCondition extends AbstractCondition {
13: String expression;
14:
15: public String getExpression() {
16: return expression;
17: }
18:
19: public void setExpression(String expression) {
20: this .expression = expression;
21: }
22:
23: public boolean eval(Object subject)
24: throws ConditionEvaluationException {
25: try {
26: Boolean result = (Boolean) Ognl.getValue(expression,
27: subject);
28: if (result == null)
29: throw new ConditionEvaluationException(expression
30: + " is null");
31: return result;
32: } catch (OgnlException e) {
33: throw new ConditionEvaluationException(e.getMessage());
34: }
35: }
36: }
|