Package org.drools.core.base.evaluators
Class PointInTimeEvaluator
- java.lang.Object
-
- org.drools.core.base.BaseEvaluator
-
- org.drools.core.base.evaluators.PointInTimeEvaluator
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Evaluator
,org.kie.api.runtime.rule.Evaluator
- Direct Known Subclasses:
AfterEvaluatorDefinition.AfterEvaluator
,BeforeEvaluatorDefinition.BeforeEvaluator
public abstract class PointInTimeEvaluator extends BaseEvaluator
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected long
finalRange
protected long
initRange
protected String
paramText
protected boolean
unwrapLeft
protected boolean
unwrapRight
-
Constructor Summary
Constructors Constructor Description PointInTimeEvaluator()
PointInTimeEvaluator(ValueType type, Operator operator, long[] parameters, String paramText, boolean unwrapLeft, boolean unwrapRight)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
protected abstract boolean
evaluate(long rightTS, long leftTS)
boolean
evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, InternalFactHandle object1, FieldValue object2)
Evaluates the expression using the provided parameters.boolean
evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor1, InternalFactHandle handle1, InternalReadAccessor extractor2, InternalFactHandle handle2)
Evaluates the expression using the provided parameters.boolean
evaluateCachedLeft(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, InternalFactHandle right)
Evaluates the expression using the provided parameters.boolean
evaluateCachedRight(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, InternalFactHandle left)
Evaluates the expression using the provided parameters.protected abstract long
getLeftTimestamp(InternalFactHandle handle)
protected abstract long
getRightTimestamp(InternalFactHandle handle)
static long
getTimestampFromDate(Object obj)
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.void
readExternal(ObjectInput in)
String
toString()
void
writeExternal(ObjectOutput out)
-
Methods inherited from class org.drools.core.base.BaseEvaluator
getCoercedValueType, getInterval, getOperator, getValueType
-
-
-
-
Field Detail
-
initRange
protected long initRange
-
finalRange
protected long finalRange
-
paramText
protected String paramText
-
unwrapLeft
protected boolean unwrapLeft
-
unwrapRight
protected boolean unwrapRight
-
-
Method Detail
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classBaseEvaluator
- Throws:
IOException
ClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classBaseEvaluator
- Throws:
IOException
-
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 interfaceEvaluator
- Specified by:
isTemporal
in interfaceorg.kie.api.runtime.rule.Evaluator
- Overrides:
isTemporal
in classBaseEvaluator
- Returns:
- true if the evaluator is a temporal evaluator.
-
evaluate
protected abstract boolean evaluate(long rightTS, long leftTS)
-
getLeftTimestamp
protected abstract long getLeftTimestamp(InternalFactHandle handle)
-
getRightTimestamp
protected abstract long getRightTimestamp(InternalFactHandle handle)
-
getTimestampFromDate
public static long getTimestampFromDate(Object obj)
-
evaluate
public boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor, InternalFactHandle 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 memoryextractor
- The extractor used to get the field value from the objectobject1
- The source object to evaluate, i.e., the factobject2
- The actual value to compare to, i.e., the constant value.- Returns:
- Returns true if evaluation is successful. false otherwise.
-
evaluateCachedLeft
public boolean evaluateCachedLeft(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, InternalFactHandle 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 memorycontext
- 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.
-
evaluateCachedRight
public boolean evaluateCachedRight(InternalWorkingMemory workingMemory, VariableRestriction.VariableContextEntry context, InternalFactHandle 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 memorycontext
- 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.
-
evaluate
public boolean evaluate(InternalWorkingMemory workingMemory, InternalReadAccessor extractor1, InternalFactHandle handle1, InternalReadAccessor extractor2, InternalFactHandle handle2)
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 memoryextractor1
- The extractor to read the left value. In the above example, the "$someName" variable value.handle1
- 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.handle2
- 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.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBaseEvaluator
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classBaseEvaluator
-
toString
public String toString()
- Overrides:
toString
in classBaseEvaluator
-
-