org.drools.semantics.groovy
Class GroovyCondition

java.lang.Object
  extended by org.drools.semantics.groovy.GroovyInterp
      extended by org.drools.semantics.groovy.GroovyCondition
All Implemented Interfaces:
Serializable, Condition, SemanticComponent

public class GroovyCondition
extends GroovyInterp
implements Condition

Groovy expression semantics Condition.

Author:
bob mcwhirter , James Strachan
See Also:
Serialized Form

Constructor Summary
GroovyCondition(String text, Rule rule)
          Construct.
 
Method Summary
 Iterator declarationIterator()
          GroovyInterp needs a declaration iterator.
 boolean equals(Object object)
           
protected  Object evaluate(groovy.lang.Binding locals)
          Evaluate.
 Object evaluate(Tuple tuple)
          Evaluate.
 Declaration[] getRequiredTupleMembers()
          Retrieve the array of Declaration s required by this condition to perform its duties.
 int hashCode()
           
 boolean isAllowed(Tuple tuple)
          Determine if the supplied Tuple is allowed by this condition.
 
Methods inherited from class org.drools.semantics.groovy.GroovyInterp
getCode, getRule, getText, setUpDictionary
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovyCondition

public GroovyCondition(String text,
                       Rule rule)
                throws Exception
Construct.

Throws:
Exception
Method Detail

evaluate

public Object evaluate(Tuple tuple)
Evaluate.

Parameters:
tuple - Tuple containing variable bindings.
Returns:
The result of evaluation.

evaluate

protected Object evaluate(groovy.lang.Binding locals)
Evaluate.

Parameters:
locals - The evaluation dictionary.
Returns:
The result of evaluation.

getRequiredTupleMembers

public Declaration[] getRequiredTupleMembers()
Retrieve the array of Declaration s required by this condition to perform its duties.

Specified by:
getRequiredTupleMembers in interface Condition
Returns:
The array of Declarations expected on incoming Tuples.

isAllowed

public boolean isAllowed(Tuple tuple)
                  throws ConditionException
Determine if the supplied Tuple is allowed by this condition.

Specified by:
isAllowed in interface Condition
Parameters:
tuple - The Tuple to test.
Returns:
true if the Tuple passes this condition, else false.
Throws:
ConditionException - if an error occurs during filtering.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

declarationIterator

public Iterator declarationIterator()
GroovyInterp needs a declaration iterator. BlockConsequence uses the Iterator from Set. So we emulate Iterator here so GroovyInterp can be used for both.

Returns:


Copyright © 2001-2005 The Codehaus. All Rights Reserved.