org.drools.base
Class EvaluatorWrapper

java.lang.Object
  extended by org.drools.base.EvaluatorWrapper
All Implemented Interfaces:
Serializable, org.drools.runtime.rule.Evaluator

public class EvaluatorWrapper
extends Object
implements Evaluator

An EvaluatorWrapper is used when executing MVEL expressions that have operator calls rewritten as: operator.evaluate( leftArg, rightArg )

See Also:
Serialized Form

Constructor Summary
EvaluatorWrapper(Evaluator evaluator, Declaration leftBinding, Declaration rightBinding)
           
 
Method Summary
 boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, Object object, FieldValue value)
          Evaluates the expression using the provided parameters.
 boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor leftExtractor, Object left, InternalReadAccessor rightExtractor, Object right)
          Evaluates the expression using the provided parameters.
 boolean evaluate(Object left, Object right)
          This method is called when operators are rewritten as function calls.
 boolean evaluateCachedLeft(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, Object right)
          Evaluates the expression using the provided parameters.
 boolean evaluateCachedRight(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, Object left)
          Evaluates the expression using the provided parameters.
 ValueType getCoercedValueType()
          Returns the value type this evaluator will coerce operands to, during evaluation.
 Interval getInterval()
          In case this is a temporal evaluator, returns the interval in which this evaluator may match the target fact
 Declaration getLeftBinding()
           
 InternalFactHandle getLeftHandle()
           
 org.drools.runtime.rule.Operator getOperator()
          Returns the operator representation object for this evaluator
 Declaration getRightBinding()
           
 InternalFactHandle getRightHandle()
           
 ValueType getValueType()
          Returns the type of the values this evaluator operates upon.
 InternalWorkingMemory getWorkingMemory()
           
 boolean isTemporal()
          Returns true if this evaluator implements a temporal evaluation, i.e., a time sensitive evaluation whose properties of matching only events within an specific time interval can be used for determining event expirations automatically.
 Object prepareLeftObject(InternalFactHandle handle)
          There are evaluators that operate on fact attributes, there are evaluators that operate on fact handle attributes (metadata), and there are evaluators that can operate in either one.
 Object prepareRightObject(InternalFactHandle handle)
          There are evaluators that operate on fact attributes, there are evaluators that operate on fact handle attributes (metadata), and there are evaluators that can operate in either one.
 void setLeftBinding(Declaration leftBinding)
           
 EvaluatorWrapper setLeftHandle(InternalFactHandle leftHandle)
           
 void setRightBinding(Declaration rightBinding)
           
 EvaluatorWrapper setRightHandle(InternalFactHandle rightHandle)
           
 EvaluatorWrapper setWorkingMemory(InternalWorkingMemory workingMemory)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EvaluatorWrapper

public EvaluatorWrapper(Evaluator evaluator,
                        Declaration leftBinding,
                        Declaration rightBinding)
Method Detail

evaluate

public boolean evaluate(Object left,
                        Object right)
This method is called when operators are rewritten as function calls. For instance, x after y Is rewritten as after.evaluate( x, y )

Returns:

getValueType

public ValueType getValueType()
Description copied from interface: Evaluator
Returns the type of the values this evaluator operates upon.

Returns:
See Also:
Evaluator.getValueType()

getOperator

public org.drools.runtime.rule.Operator getOperator()
Description copied from interface: Evaluator
Returns the operator representation object for this evaluator

Specified by:
getOperator in interface org.drools.runtime.rule.Evaluator
Returns:
See Also:
Evaluator.getOperator()

getCoercedValueType

public ValueType getCoercedValueType()
Description copied from interface: Evaluator
Returns the value type this evaluator will coerce operands to, during evaluation. This is useful for operators like "memberOf", that always convert to Object when evaluating, independently of the source operand value type.

Returns:
See Also:
Evaluator.getCoercedValueType()

prepareLeftObject

public Object prepareLeftObject(InternalFactHandle handle)
Description copied from interface: Evaluator
There are evaluators that operate on fact attributes, there are evaluators that operate on fact handle attributes (metadata), and there are evaluators that can operate in either one. This method allows the evaluator to prepare the left object for evaluation. That includes, unwrapping the object from the handle, if necessary. It is important to note that the concept of left and right is based on the Rete notion of left and right, where right corresponds to the current pattern, while left is a binding to a previous pattern.

Parameters:
handle -
Returns:
See Also:
Evaluator.prepareLeftObject(org.drools.common.InternalFactHandle)

prepareRightObject

public Object prepareRightObject(InternalFactHandle handle)
Description copied from interface: Evaluator
There are evaluators that operate on fact attributes, there are evaluators that operate on fact handle attributes (metadata), and there are evaluators that can operate in either one. This method allows the evaluator to prepare the right object for evaluation. That includes, unwrapping the object from the handle, if necessary. It is important to note that the concept of left and right is based on the Rete notion of left and right, where right corresponds to the current pattern, while left is a binding to a previous pattern.

Parameters:
handle -
Returns:
See Also:
Evaluator.prepareRightObject(org.drools.common.InternalFactHandle)

evaluate

public boolean evaluate(InternalWorkingMemory workingMemory,
                        InternalReadAccessor extractor,
                        Object object,
                        FieldValue value)
Description copied from interface: Evaluator
Evaluates the expression using the provided parameters. This method is used when evaluating alpha-constraints, i.e., a fact attribute against a constant value. For instance: Person( name == "Bob" ) So, it uses a constant value "Bob" that is sent into the method as the FieldValue (value), and compares it to the value of the name field, read by using the extractor on the fact instance (object1).

Parameters:
workingMemory -
extractor -
object -
value -
Returns:
See Also:
Evaluator.evaluate(org.drools.common.InternalWorkingMemory, org.drools.spi.InternalReadAccessor, java.lang.Object, org.drools.spi.FieldValue)

evaluate

public boolean evaluate(InternalWorkingMemory workingMemory,
                        InternalReadAccessor leftExtractor,
                        Object left,
                        InternalReadAccessor rightExtractor,
                        Object right)
Description copied from interface: Evaluator
Evaluates the expression using the provided parameters. This method is used for internal indexing and hashing, when drools needs to extract and evaluate both left and right values at once. For instance: Person( name == $someName ) This method will be used to extract and evaluate both the "name" attribute and the "$someName" variable at once.

Parameters:
workingMemory -
leftExtractor -
left -
rightExtractor -
right -
Returns:
See Also:
Evaluator.evaluate(org.drools.common.InternalWorkingMemory, org.drools.spi.InternalReadAccessor, java.lang.Object, org.drools.spi.InternalReadAccessor, java.lang.Object)

evaluateCachedLeft

public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory,
                                  VariableRestriction.VariableContextEntry context,
                                  Object right)
Description copied from interface: Evaluator
Evaluates the expression using the provided parameters. This method is used when evaluating left-activated beta-constraints, i.e., a fact attribute against a variable value, that is activated from the left. For instance: Person( name == $someName ) This method will be used when a new $someName variable is bound. So it will cache the value of $someName and will iterate over the right memory (Person instances) evaluating each occurrence.

Parameters:
workingMemory -
context -
right -
Returns:
See Also:
Evaluator.evaluateCachedLeft(org.drools.common.InternalWorkingMemory, org.drools.rule.VariableRestriction.VariableContextEntry, java.lang.Object)

evaluateCachedRight

public boolean evaluateCachedRight(InternalWorkingMemory workingMemory,
                                   VariableRestriction.VariableContextEntry context,
                                   Object left)
Description copied from interface: Evaluator
Evaluates the expression using the provided parameters. This method is used when evaluating right-activated beta-constraints, i.e., a fact attribute against a variable value, that is activated from the right. For instance: Person( name == $someName ) This method will be used when a new Person instance is evaluated. So it will cache the value of the "Person" instance and will iterate over the left memory comparing it to each "$someName" bound values.

Parameters:
workingMemory -
context -
left -
Returns:
See Also:
Evaluator.evaluateCachedRight(org.drools.common.InternalWorkingMemory, org.drools.rule.VariableRestriction.VariableContextEntry, java.lang.Object)

isTemporal

public boolean isTemporal()
Description copied from interface: Evaluator
Returns true if this evaluator implements a temporal evaluation, i.e., a time sensitive evaluation whose properties of matching only events within an specific time interval can be used for determining event expirations automatically.

Specified by:
isTemporal in interface org.drools.runtime.rule.Evaluator
Returns:
See Also:
Evaluator.isTemporal()

getInterval

public Interval getInterval()
Description copied from interface: Evaluator
In case this is a temporal evaluator, returns the interval in which this evaluator may match the target fact

Returns:
See Also:
Evaluator.getInterval()

getWorkingMemory

public InternalWorkingMemory getWorkingMemory()
Returns:
the workingMemory

setWorkingMemory

public EvaluatorWrapper setWorkingMemory(InternalWorkingMemory workingMemory)
Parameters:
workingMemory - the workingMemory to set

getLeftHandle

public InternalFactHandle getLeftHandle()
Returns:
the leftHandle

setLeftHandle

public EvaluatorWrapper setLeftHandle(InternalFactHandle leftHandle)
Parameters:
leftHandle - the leftHandle to set

getRightHandle

public InternalFactHandle getRightHandle()
Returns:
the rightHandle

setRightHandle

public EvaluatorWrapper setRightHandle(InternalFactHandle rightHandle)
Parameters:
rightHandle - the rightHandle to set

getLeftBinding

public Declaration getLeftBinding()
Returns:
the leftBinding

setLeftBinding

public void setLeftBinding(Declaration leftBinding)
Parameters:
leftBinding - the leftBinding to set

getRightBinding

public Declaration getRightBinding()
Returns:
the rightBinding

setRightBinding

public void setRightBinding(Declaration rightBinding)
Parameters:
rightBinding - the rightBinding to set

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.