Package org.drools.core.rule
Class Accumulate
- java.lang.Object
-
- org.drools.core.rule.ConditionalElement
-
- org.drools.core.rule.Accumulate
-
- All Implemented Interfaces:
Externalizable,Serializable,Cloneable,PatternSource,RuleConditionElement,RuleComponent
- Direct Known Subclasses:
MultiAccumulate,SingleAccumulate
public abstract class Accumulate extends ConditionalElement implements PatternSource
A class to represent the Accumulate CE- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Accumulate>clonedprotected Declaration[]innerDeclarationCacheprotected Declaration[]requiredDeclarationsprotected RuleConditionElementsource
-
Constructor Summary
Constructors Constructor Description Accumulate()Accumulate(RuleConditionElement source, Declaration[] requiredDeclarations)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Objectaccumulate(Object workingMemoryContext, Object context, Tuple match, InternalFactHandle handle, ReteEvaluator reteEvaluator)Executes the accumulate (action) code for the given fact handleabstract Objectaccumulate(Object workingMemoryContext, Tuple match, InternalFactHandle childHandle, AccumulateNode.GroupByContext groupByContext, TupleList<AccumulateNode.AccumulateContextEntry> tupleList, ReteEvaluator reteEvaluator)abstract Accumulateclone()Returns a clone from itselfabstract ObjectcreateFunctionContext()abstract ObjectcreateWorkingMemoryContext()abstract Accumulator[]getAccumulators()protected Declaration[]getInnerDeclarationCache()Map<String,Declaration>getInnerDeclarations()Returns a Map of declarations that are visible inside this conditional elementList<RuleConditionElement>getNestedElements()Returs a list of RuleConditionElement's that are nested inside the current elementMap<String,Declaration>getOuterDeclarations()Returns a Map of declarations that are visible outside this conditional element.Declaration[]getRequiredDeclarations()abstract ObjectgetResult(Object workingMemoryContext, Object context, Tuple leftTuple, ReteEvaluator reteEvaluator)Gets the result of the accumulationRuleConditionElementgetSource()booleanhasRequiredDeclarations()abstract Objectinit(Object workingMemoryContext, Object accContext, Object funcContext, Tuple leftTuple, ReteEvaluator reteEvaluator)Executes the initialization block of codebooleanisGroupBy()abstract booleanisMultiFunction()booleanisPatternScopeDelimiter()Returns true in case this RuleConditionElement delimits a pattern visibility scope.voidreadExternal(ObjectInput in)protected voidregisterClone(Accumulate clone)abstract voidreplaceAccumulatorDeclaration(Declaration declaration, Declaration resolved)voidreplaceDeclaration(Declaration declaration, Declaration resolved)booleanrequiresLeftActivation()DeclarationresolveDeclaration(String identifier)Resolves the given identifier in the current scope and returns the Declaration object for the declaration.abstract booleansupportsReverse()Returns true if this accumulate supports reverseabstract booleantryReverse(Object workingMemoryContext, Object context, Tuple leftTuple, InternalFactHandle handle, RightTuple rightParent, LeftTuple match, ReteEvaluator reteEvaluator)Executes the reverse (action) code for the given fact handlevoidwriteExternal(ObjectOutput out)
-
-
-
Field Detail
-
source
protected RuleConditionElement source
-
requiredDeclarations
protected Declaration[] requiredDeclarations
-
innerDeclarationCache
protected Declaration[] innerDeclarationCache
-
cloned
protected List<Accumulate> cloned
-
-
Constructor Detail
-
Accumulate
public Accumulate()
-
Accumulate
public Accumulate(RuleConditionElement source, Declaration[] requiredDeclarations)
-
-
Method Detail
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
getAccumulators
public abstract Accumulator[] getAccumulators()
-
createFunctionContext
public abstract Object createFunctionContext()
-
init
public abstract Object init(Object workingMemoryContext, Object accContext, Object funcContext, Tuple leftTuple, ReteEvaluator reteEvaluator)
Executes the initialization block of code
-
accumulate
public abstract Object accumulate(Object workingMemoryContext, Object context, Tuple match, InternalFactHandle handle, ReteEvaluator reteEvaluator)
Executes the accumulate (action) code for the given fact handle
-
tryReverse
public abstract boolean tryReverse(Object workingMemoryContext, Object context, Tuple leftTuple, InternalFactHandle handle, RightTuple rightParent, LeftTuple match, ReteEvaluator reteEvaluator)
Executes the reverse (action) code for the given fact handle
-
getResult
public abstract Object getResult(Object workingMemoryContext, Object context, Tuple leftTuple, ReteEvaluator reteEvaluator)
Gets the result of the accumulation
-
supportsReverse
public abstract boolean supportsReverse()
Returns true if this accumulate supports reverse
-
clone
public abstract Accumulate clone()
Description copied from interface:RuleConditionElementReturns a clone from itself- Specified by:
clonein interfaceRuleConditionElement- Specified by:
clonein classConditionalElement- Returns:
-
registerClone
protected void registerClone(Accumulate clone)
-
getSource
public RuleConditionElement getSource()
-
getInnerDeclarations
public Map<String,Declaration> getInnerDeclarations()
Description copied from interface:RuleConditionElementReturns a Map of declarations that are visible inside this conditional element- Specified by:
getInnerDeclarationsin interfaceRuleConditionElement- Returns:
-
getOuterDeclarations
public Map<String,Declaration> getOuterDeclarations()
Description copied from interface:RuleConditionElementReturns a Map of declarations that are visible outside this conditional element.- Specified by:
getOuterDeclarationsin interfaceRuleConditionElement- Returns:
-
resolveDeclaration
public Declaration resolveDeclaration(String identifier)
Description copied from interface:RuleConditionElementResolves the given identifier in the current scope and returns the Declaration object for the declaration. Returns null if identifier can not be resolved.- Specified by:
resolveDeclarationin interfaceRuleConditionElement- Returns:
-
createWorkingMemoryContext
public abstract Object createWorkingMemoryContext()
-
getNestedElements
public List<RuleConditionElement> getNestedElements()
Description copied from interface:RuleConditionElementReturs a list of RuleConditionElement's that are nested inside the current element- Specified by:
getNestedElementsin interfaceRuleConditionElement- Returns:
-
isPatternScopeDelimiter
public boolean isPatternScopeDelimiter()
Description copied from interface:RuleConditionElementReturns true in case this RuleConditionElement delimits a pattern visibility scope. For instance, AND CE is not a scope delimiter, while NOT CE is a scope delimiter- Specified by:
isPatternScopeDelimiterin interfaceRuleConditionElement- Returns:
-
isMultiFunction
public abstract boolean isMultiFunction()
-
replaceDeclaration
public void replaceDeclaration(Declaration declaration, Declaration resolved)
-
replaceAccumulatorDeclaration
public abstract void replaceAccumulatorDeclaration(Declaration declaration, Declaration resolved)
-
getInnerDeclarationCache
protected Declaration[] getInnerDeclarationCache()
-
getRequiredDeclarations
public Declaration[] getRequiredDeclarations()
-
hasRequiredDeclarations
public boolean hasRequiredDeclarations()
-
requiresLeftActivation
public boolean requiresLeftActivation()
- Specified by:
requiresLeftActivationin interfacePatternSource
-
isGroupBy
public boolean isGroupBy()
-
accumulate
public abstract Object accumulate(Object workingMemoryContext, Tuple match, InternalFactHandle childHandle, AccumulateNode.GroupByContext groupByContext, TupleList<AccumulateNode.AccumulateContextEntry> tupleList, ReteEvaluator reteEvaluator)
-
-