org.drools.base.evaluators
Class StartedByEvaluatorDefinition

java.lang.Object
  extended by org.drools.base.evaluators.StartedByEvaluatorDefinition
All Implemented Interfaces:
Externalizable, Serializable, org.drools.runtime.rule.EvaluatorDefinition

public class StartedByEvaluatorDefinition
extends Object
implements EvaluatorDefinition

The implementation of the startedby evaluator definition.

The startedby evaluator correlates two events and matches when the correlating event's end timestamp happens before the current event's end timestamp, but both start timestamps occur at the same time.

Lets look at an example:

$eventA : EventA( this startedby $eventB )

The previous pattern will match if and only if the $eventB finishes before $eventA finishes and starts at the same time $eventB starts. In other words:

 
 $eventA.startTimestamp == $eventB.startTimestamp &&
 $eventA.endTimestamp > $eventB.endTimestamp 
 

The startedby evaluator accepts one optional parameter. If it is defined, it determines the maximum distance between the start timestamp of both events in order for the operator to match. Example:

$eventA : EventA( this startedby[ 5s ] $eventB )
Will match if and only if:
 
 abs( $eventA.startTimestamp - $eventB.startTimestamp ) <= 5s &&
 $eventA.endTimestamp > $eventB.endTimestamp 
 

NOTE: it makes no sense to use a negative interval value for the parameter and the engine will raise an exception if that happens.

See Also:
Serialized Form

Nested Class Summary
static class StartedByEvaluatorDefinition.StartedByEvaluator
          Implements the 'startedby' evaluator itself
 
Nested classes/interfaces inherited from interface org.drools.base.evaluators.EvaluatorDefinition
EvaluatorDefinition.Target
 
Field Summary
static Operator NOT_STARTED_BY
           
static Operator STARTED_BY
           
 
Constructor Summary
StartedByEvaluatorDefinition()
           
 
Method Summary
 Evaluator getEvaluator(ValueType type, Operator operator)
          Returns the evaluator instance for the given type and the defined parameterText
 Evaluator getEvaluator(ValueType type, Operator operator, String parameterText)
          Returns the evaluator instance for the given type and the defined parameterText
 Evaluator getEvaluator(ValueType type, String operatorId, boolean isNegated, String parameterText)
          Returns the evaluator instance for the given type and the defined parameterText
 Evaluator getEvaluator(ValueType type, String operatorId, boolean isNegated, String parameterText, EvaluatorDefinition.Target left, EvaluatorDefinition.Target right)
          Returns the evaluator instance for the given type and the defined parameterText
 String[] getEvaluatorIds()
          Returns the list of identifies this evaluator implementation supports
 EvaluatorDefinition.Target getTarget()
          There are evaluators that operate on *fact* attributes, evaluators that operate on *fact handle* attributes, and evaluators that operate on both.
 boolean isNegatable()
          My apologies to English speakers if the word "negatable" does not exist. :) This method returns true if this evaluator supports negation.
 void readExternal(ObjectInput in)
           
 boolean supportsType(ValueType type)
          Returns true in case this evaluator supports operations over values of that specific type.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STARTED_BY

public static final Operator STARTED_BY

NOT_STARTED_BY

public static final Operator NOT_STARTED_BY
Constructor Detail

StartedByEvaluatorDefinition

public StartedByEvaluatorDefinition()
Method Detail

readExternal

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

writeExternal

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

getEvaluator

public Evaluator getEvaluator(ValueType type,
                              Operator operator)
Description copied from interface: EvaluatorDefinition
Returns the evaluator instance for the given type and the defined parameterText

Parameters:
type - the type of the attributes this evaluator will operate on. This is important because the evaluator may do optimisations and type coercion based on the types it is evaluating. It is also possible that this evaluator does not support a given type.
operator - the operator implemented by the evaluator
Returns:
an Evaluator instance capable of evaluating expressions between values of the given type, or null in case the type is not supported.

getEvaluator

public Evaluator getEvaluator(ValueType type,
                              Operator operator,
                              String parameterText)
Description copied from interface: EvaluatorDefinition
Returns the evaluator instance for the given type and the defined parameterText

Parameters:
type - the type of the attributes this evaluator will operate on. This is important because the evaluator may do optimisations and type coercion based on the types it is evaluating. It is also possible that this evaluator does not support a given type.
operator - the operator implemented by the evaluator
parameterText - some evaluators support parameters and these parameters are defined as a String that is parsed by the evaluator itself.
Returns:
an Evaluator instance capable of evaluating expressions between values of the given type, or null in case the type is not supported.

getEvaluator

public Evaluator getEvaluator(ValueType type,
                              String operatorId,
                              boolean isNegated,
                              String parameterText)
Description copied from interface: EvaluatorDefinition
Returns the evaluator instance for the given type and the defined parameterText

Parameters:
type - the type of the attributes this evaluator will operate on. This is important because the evaluator may do optimisations and type coercion based on the types it is evaluating. It is also possible that this evaluator does not support a given type.
operatorId - the string identifier of the evaluator
isNegated - true if the evaluator instance to be returned is the negated version of the evaluator.
parameterText - some evaluators support parameters and these parameters are defined as a String that is parsed by the evaluator itself.
Returns:
an Evaluator instance capable of evaluating expressions between values of the given type, or null in case the type is not supported.

getEvaluator

public Evaluator getEvaluator(ValueType type,
                              String operatorId,
                              boolean isNegated,
                              String parameterText,
                              EvaluatorDefinition.Target left,
                              EvaluatorDefinition.Target right)
Description copied from interface: EvaluatorDefinition
Returns the evaluator instance for the given type and the defined parameterText

Parameters:
type - the type of the attributes this evaluator will operate on. This is important because the evaluator may do optimisations and type coercion based on the types it is evaluating. It is also possible that this evaluator does not support a given type.
operatorId - the string identifier of the evaluator
isNegated - true if the evaluator instance to be returned is the negated version of the evaluator.
parameterText - some evaluators support parameters and these parameters are defined as a String that is parsed by the evaluator itself.
left - the target of the evaluator on the Left side, i.e., on Rete terms, the previous binding or the actual value on the right side of the operator.
right - the target of the evaluator on the Right side, i.e., on Rete terms, the current pattern field.
Returns:
an Evaluator instance capable of evaluating expressions between values of the given type, or null in case the type is not supported.

getEvaluatorIds

public String[] getEvaluatorIds()
Description copied from interface: EvaluatorDefinition
Returns the list of identifies this evaluator implementation supports

Returns:

isNegatable

public boolean isNegatable()
Description copied from interface: EvaluatorDefinition
My apologies to English speakers if the word "negatable" does not exist. :) This method returns true if this evaluator supports negation. Example: the "matches" operator supports "not matches" and so is "negatable" (!?)

Returns:

getTarget

public EvaluatorDefinition.Target getTarget()
Description copied from interface: EvaluatorDefinition
There are evaluators that operate on *fact* attributes, evaluators that operate on *fact handle* attributes, and evaluators that operate on both. This method returns the target of the current evaluator.

Returns:
true if this evaluator operates on fact handle attributes and false if it operates on fact attributes

supportsType

public boolean supportsType(ValueType type)
Description copied from interface: EvaluatorDefinition
Returns true in case this evaluator supports operations over values of that specific type.

Returns:


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