BooleanCondition.java :  » Workflow-Engines » osbl-1_0 » org » concern » library » generic » Java Open Source

Java Open Source » Workflow Engines » osbl 1_0 
osbl 1_0 » org » concern » library » generic » BooleanCondition.java
package org.concern.library.generic;

import org.concern.controller.AbstractCondition;
import org.concern.controller.ConditionEvaluationException;
import ognl.Ognl;
import ognl.OgnlException;

/**
 * @author hengels
 * @version $Revision$
 */
public class BooleanCondition
    extends AbstractCondition
{
    String expression;

    public String getExpression() {
        return expression;
    }

    public void setExpression(String expression) {
        this.expression = expression;
    }

    public boolean eval(Object subject) throws ConditionEvaluationException {
        try {
            Boolean result = (Boolean)Ognl.getValue(expression, subject);
            if (result == null)
                throw new ConditionEvaluationException(expression + " is null");
            return result;
        }
        catch (OgnlException e) {
            throw new ConditionEvaluationException(e.getMessage());
        }
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.