org.drools.rule
Class Accumulate

java.lang.Object
  extended by org.drools.rule.ConditionalElement
      extended by org.drools.rule.Accumulate
All Implemented Interfaces:
Externalizable, Serializable, Cloneable, PatternSource, RuleConditionElement, RuleComponent

public class Accumulate
extends ConditionalElement
implements PatternSource

A class to represent the Accumulate CE

See Also:
Serialized Form

Nested Class Summary
 class Accumulate.Wirer
           
 
Constructor Summary
Accumulate()
           
Accumulate(RuleConditionElement source)
           
Accumulate(RuleConditionElement source, Declaration[] requiredDeclarations, Declaration[] innerDeclarations)
           
Accumulate(RuleConditionElement source, Declaration[] requiredDeclarations, Declaration[] innerDeclarations, Accumulator[] accumulators, boolean multiFunction)
           
 
Method Summary
 void accumulate(Object[] workingMemoryContext, Object[] context, Tuple leftTuple, InternalFactHandle handle, WorkingMemory workingMemory)
          Executes the accumulate (action) code for the given fact handle
 Object clone()
          Returns a clone from itself
 Serializable[] createContext()
           
 Object[] createWorkingMemoryContext()
           
 Accumulator[] getAccumulators()
           
 Map<String,Declaration> getInnerDeclarations()
          Returns a Map of declarations that are visible inside this conditional element
 List<RuleConditionElement> getNestedElements()
          Returs a list of RuleConditionElement's that are nested inside the current element
 Map<String,Declaration> getOuterDeclarations()
          Returns a Map of declarations that are visible outside this conditional element.
 Object[] getResult(Object[] workingMemoryContext, Object[] context, Tuple leftTuple, WorkingMemory workingMemory)
          Gets the result of the accumulation
 RuleConditionElement getSource()
           
 void init(Object[] workingMemoryContext, Object[] context, Tuple leftTuple, WorkingMemory workingMemory)
          Executes the initialization block of code
 boolean isMultiFunction()
           
 boolean isPatternScopeDelimiter()
          Returns true in case this RuleConditionElement delimits a pattern visibility scope.
 void readExternal(ObjectInput in)
           
 Declaration resolveDeclaration(String identifier)
          Resolves the given identifier in the current scope and returns the Declaration object for the declaration.
 void reverse(Object[] workingMemoryContext, Object[] context, Tuple leftTuple, InternalFactHandle handle, WorkingMemory workingMemory)
          Executes the reverse (action) code for the given fact handle
 void setAccumulators(Accumulator[] accumulators)
           
 void setMultiFunction(boolean multiFunction)
           
 boolean supportsReverse()
          Returns true if this accumulate supports reverse
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Accumulate

public Accumulate()

Accumulate

public Accumulate(RuleConditionElement source)

Accumulate

public Accumulate(RuleConditionElement source,
                  Declaration[] requiredDeclarations,
                  Declaration[] innerDeclarations)

Accumulate

public Accumulate(RuleConditionElement source,
                  Declaration[] requiredDeclarations,
                  Declaration[] innerDeclarations,
                  Accumulator[] accumulators,
                  boolean multiFunction)
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

getAccumulators

public Accumulator[] getAccumulators()

setAccumulators

public void setAccumulators(Accumulator[] accumulators)

createContext

public Serializable[] createContext()

init

public void init(Object[] workingMemoryContext,
                 Object[] context,
                 Tuple leftTuple,
                 WorkingMemory workingMemory)
Executes the initialization block of code

Parameters:
leftTuple - tuple causing the rule fire
declarations - previous declarations
workingMemory -
Throws:
Exception

accumulate

public void accumulate(Object[] workingMemoryContext,
                       Object[] context,
                       Tuple leftTuple,
                       InternalFactHandle handle,
                       WorkingMemory workingMemory)
Executes the accumulate (action) code for the given fact handle

Parameters:
leftTuple -
handle -
declarations -
innerDeclarations -
workingMemory -
Throws:
Exception

reverse

public void reverse(Object[] workingMemoryContext,
                    Object[] context,
                    Tuple leftTuple,
                    InternalFactHandle handle,
                    WorkingMemory workingMemory)
Executes the reverse (action) code for the given fact handle

Parameters:
leftTuple -
handle -
declarations -
innerDeclarations -
workingMemory -
Throws:
Exception

getResult

public Object[] getResult(Object[] workingMemoryContext,
                          Object[] context,
                          Tuple leftTuple,
                          WorkingMemory workingMemory)
Gets the result of the accumulation

Parameters:
leftTuple -
declarations -
workingMemory -
Returns:
Throws:
Exception

supportsReverse

public boolean supportsReverse()
Returns true if this accumulate supports reverse

Returns:

clone

public Object clone()
Description copied from interface: RuleConditionElement
Returns a clone from itself

Specified by:
clone in interface RuleConditionElement
Specified by:
clone in class ConditionalElement
Returns:

getSource

public RuleConditionElement getSource()

getInnerDeclarations

public Map<String,Declaration> getInnerDeclarations()
Description copied from interface: RuleConditionElement
Returns a Map of declarations that are visible inside this conditional element

Specified by:
getInnerDeclarations in interface RuleConditionElement
Returns:

getOuterDeclarations

public Map<String,Declaration> getOuterDeclarations()
Description copied from interface: RuleConditionElement
Returns a Map of declarations that are visible outside this conditional element.

Specified by:
getOuterDeclarations in interface RuleConditionElement
Returns:

resolveDeclaration

public Declaration resolveDeclaration(String identifier)
Description copied from interface: RuleConditionElement
Resolves 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:
resolveDeclaration in interface RuleConditionElement
Returns:

createWorkingMemoryContext

public Object[] createWorkingMemoryContext()

getNestedElements

public List<RuleConditionElement> getNestedElements()
Description copied from interface: RuleConditionElement
Returs a list of RuleConditionElement's that are nested inside the current element

Specified by:
getNestedElements in interface RuleConditionElement
Returns:

isPatternScopeDelimiter

public boolean isPatternScopeDelimiter()
Description copied from interface: RuleConditionElement
Returns 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:
isPatternScopeDelimiter in interface RuleConditionElement
Returns:

isMultiFunction

public boolean isMultiFunction()
Returns:
the multiFunction

setMultiFunction

public void setMultiFunction(boolean multiFunction)
Parameters:
multiFunction - the multiFunction to set


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