org.drools.base.evaluators
Class StartsEvaluatorDefinition.StartsEvaluator

java.lang.Object
  extended by org.drools.base.BaseEvaluator
      extended by org.drools.base.evaluators.StartsEvaluatorDefinition.StartsEvaluator
All Implemented Interfaces:
Externalizable, Serializable, org.drools.runtime.rule.Evaluator
Enclosing class:
StartsEvaluatorDefinition

public static class StartsEvaluatorDefinition.StartsEvaluator
extends BaseEvaluator

Implements the 'starts' evaluator itself

See Also:
Serialized Form

Constructor Summary
StartsEvaluatorDefinition.StartsEvaluator()
           
StartsEvaluatorDefinition.StartsEvaluator(ValueType type, boolean isNegated, Long[] params, String paramText)
           
 
Method Summary
 boolean equals(Object obj)
           
 boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, Object object1, FieldValue object2)
          Evaluates the expression using the provided parameters.
 boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor1, Object object1, InternalReadAccessor extractor2, Object object2)
          Evaluates the expression using the provided parameters.
 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.
 Interval getInterval()
          In case this is a temporal evaluator, returns the interval in which this evaluator may match the target fact
 int hashCode()
           
 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)
          Most evaluators operate on the fact attributes, so, by default, the implementation unwraps it, but subclasses can override this behaviour.
 void readExternal(ObjectInput in)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.base.BaseEvaluator
getCoercedValueType, getOperator, getValueType, prepareRightObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StartsEvaluatorDefinition.StartsEvaluator

public StartsEvaluatorDefinition.StartsEvaluator(ValueType type,
                                                 boolean isNegated,
                                                 Long[] params,
                                                 String paramText)

StartsEvaluatorDefinition.StartsEvaluator

public StartsEvaluatorDefinition.StartsEvaluator()
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class BaseEvaluator
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class BaseEvaluator
Throws:
IOException

prepareLeftObject

public Object prepareLeftObject(InternalFactHandle handle)
Description copied from class: BaseEvaluator
Most evaluators operate on the fact attributes, so, by default, the implementation unwraps it, but subclasses can override this behaviour.

Overrides:
prepareLeftObject in class BaseEvaluator
Returns:

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
Overrides:
isTemporal in class BaseEvaluator
Returns:
true if the evaluator is a temporal evaluator.

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

Overrides:
getInterval in class BaseEvaluator
Returns:

evaluate

public boolean evaluate(InternalWorkingMemory workingMemory,
                        InternalReadAccessor extractor,
                        Object object1,
                        FieldValue object2)
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 - The current working memory
extractor - The extractor used to get the field value from the object
object1 - The source object to evaluate, i.e., the fact
object2 - The actual value to compare to, i.e., the constant value.
Returns:
Returns true if evaluation is successful. false otherwise.

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 - The current working memory
context - The previously cached context, including the right value and the extractor for the left value.
left - The left object, from where to extract the bound variable. In the above example, that is the "$someName" variable value.
Returns:
Returns true if evaluation is successful. false otherwise.

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 - The current working memory
context - The previously cached context, including the left value and the extractor for the right value.
right - The right object, from where to extract the value. In the above example, that is the "Person" instance from where to extract the "name" attribute.
Returns:
Returns true if evaluation is successful. false otherwise.

evaluate

public boolean evaluate(InternalWorkingMemory workingMemory,
                        InternalReadAccessor extractor1,
                        Object object1,
                        InternalReadAccessor extractor2,
                        Object object2)
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 - The current working memory
extractor1 - The extractor to read the left value. In the above example, the "$someName" variable value.
object1 - The source object from where the value of the variable is extracted.
extractor2 - The extractor to read the right value. In the above example, the "name" attribute value.
object2 - The right object from where to extract the value. In the above example, that is the "Person" instance from where to extract the "name" attribute.
Returns:
Returns true if evaluation is successful. false otherwise.

toString

public String toString()
Overrides:
toString in class BaseEvaluator

hashCode

public int hashCode()
Overrides:
hashCode in class BaseEvaluator

equals

public boolean equals(Object obj)
Overrides:
equals in class BaseEvaluator


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