1 17 18 19 20 package org.apache.lenya.workflow.impl; 21 22 import org.apache.lenya.workflow.Situation; 23 import org.apache.lenya.workflow.WorkflowException; 24 import org.apache.lenya.workflow.WorkflowInstance; 25 import org.apache.log4j.Category; 26 27 30 public class BooleanVariableCondition extends AbstractCondition { 31 32 private static final Category log = Category.getInstance(BooleanVariableCondition.class); 33 34 private String variableName; 35 private boolean value; 36 37 41 protected boolean getValue() { 42 return value; 43 } 44 45 49 protected String getVariableName() { 50 return variableName; 51 } 52 53 56 public void setExpression(String expression) throws WorkflowException { 57 super.setExpression(expression); 58 String [] sides = expression.split("="); 59 if (sides.length != 2) { 60 throw new WorkflowException( 61 "The expression '" + expression + "' must be of the form 'name = [true|false]'"); 62 } 63 64 variableName = sides[0].trim(); 65 value = Boolean.valueOf(sides[1].trim()).booleanValue(); 66 67 if (log.isDebugEnabled()) { 68 log.debug("Expression: [" + sides[1].trim() + "]"); 69 log.debug("Setting value: [" + value + "]"); 70 } 71 } 72 73 76 public boolean isComplied(Situation situation, WorkflowInstance instance) throws WorkflowException { 77 if (log.isDebugEnabled()) { 78 log.debug("Checking boolean variable condition"); 79 log.debug(" Condition value: [" + getValue() + "]"); 80 log.debug(" Variable value: [" + instance.getValue(getVariableName()) + "]"); 81 } 82 return instance.getValue(getVariableName()) == getValue(); 83 } 84 85 } 86 | Popular Tags |