org.drools.reteoo
Class AccumulateNode

java.lang.Object
  extended by org.drools.common.BaseNode
      extended by org.drools.reteoo.TupleSource
          extended by org.drools.reteoo.AccumulateNode
All Implemented Interfaces:
java.io.Serializable, NetworkNode, NodeMemory, ObjectSink, ObjectSinkNode, TupleSink, TupleSinkNode

public class AccumulateNode
extends TupleSource

AccumulateNode A beta node capable of doing accumulate logic. Created: 04/06/2006

Version:
$Id: AccumulateNode.java 19220 2008-03-24 19:14:33Z tirelli $
Author:
Edson Tirelli
See Also:
Serialized Form

Nested Class Summary
static class AccumulateNode.AccumulateMemory
           
 
Field Summary
protected  BetaConstraints constraints
           
protected  TupleSource leftInput
          The left input TupleSource.
protected  boolean objectMemory
           
protected  ObjectSource rightInput
          The right input TupleSource.
protected  boolean tupleMemoryEnabled
           
 
Fields inherited from class org.drools.reteoo.TupleSource
sink
 
Fields inherited from class org.drools.common.BaseNode
id
 
Constructor Summary
AccumulateNode(int id, TupleSource leftInput, ObjectSource rightInput, AlphaNodeFieldConstraint[] resultConstraints, BetaConstraints sourceBinder, BetaConstraints resultBinder, Accumulate accumulate, boolean unwrapRightObject, BuildContext context)
           
 
Method Summary
 void assertObject(InternalFactHandle handle, PropagationContext context, InternalWorkingMemory workingMemory)
          Assert a new FactHandleImpl.
 void assertTuple(ReteTuple leftTuple, PropagationContext context, InternalWorkingMemory workingMemory)
          Assert a new ReteTuple.
 void attach()
          Attaches the node into the network.
 void attach(InternalWorkingMemory[] workingMemories)
           
 java.lang.Object createMemory(RuleBaseConfiguration config)
          Creates a BetaMemory for the BetaNode's memory.
 void dumpMemory(InternalWorkingMemory workingMemory)
           
 boolean equals(java.lang.Object object)
           
 BetaNodeFieldConstraint[] getConstraints()
           
 ObjectSinkNode getNextObjectSinkNode()
          Returns the next node
 TupleSinkNode getNextTupleSinkNode()
          Returns the next node
 ObjectTypeNode getObjectTypeNode()
           
 ObjectSinkNode getPreviousObjectSinkNode()
          Returns the previous node
 TupleSinkNode getPreviousTupleSinkNode()
          Returns the previous node
 java.util.List getRules()
           
 int hashCode()
          The hashCode return is simply the unique id of the node.
 boolean isObjectMemoryEnabled()
           
 boolean isTupleMemoryEnabled()
           
 void modifyTuple(boolean isAssert, ReteTuple leftTuple, InternalFactHandle handle, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void remove(RuleRemovalContext context, BaseNode node, InternalWorkingMemory[] workingMemories)
          Removes the node from teh network.
 void retractObject(InternalFactHandle handle, PropagationContext context, InternalWorkingMemory workingMemory)
          Retract an existing FactHandleImpl.
 void retractTuple(ReteTuple leftTuple, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void setNextObjectSinkNode(ObjectSinkNode next)
          Sets the next node
 void setNextTupleSinkNode(TupleSinkNode next)
          Sets the next node
 void setObjectMemoryEnabled(boolean objectMemory)
           
 void setPreviousObjectSinkNode(ObjectSinkNode previous)
          Sets the previous node
 void setPreviousTupleSinkNode(TupleSinkNode previous)
          Sets the previous node
 void setTupleMemoryEnabled(boolean tupleMemoryEnabled)
           
 java.lang.String toString()
           
 void updateSink(TupleSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
           
 
Methods inherited from class org.drools.reteoo.TupleSource
addTupleSink, getSinkPropagator, isInUse, removeTupleSink
 
Methods inherited from class org.drools.common.BaseNode
getId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.drools.common.NodeMemory
getId
 

Field Detail

leftInput

protected final TupleSource leftInput
The left input TupleSource.


rightInput

protected final ObjectSource rightInput
The right input TupleSource.


constraints

protected final BetaConstraints constraints

objectMemory

protected boolean objectMemory

tupleMemoryEnabled

protected boolean tupleMemoryEnabled
Constructor Detail

AccumulateNode

public AccumulateNode(int id,
                      TupleSource leftInput,
                      ObjectSource rightInput,
                      AlphaNodeFieldConstraint[] resultConstraints,
                      BetaConstraints sourceBinder,
                      BetaConstraints resultBinder,
                      Accumulate accumulate,
                      boolean unwrapRightObject,
                      BuildContext context)
Method Detail

assertTuple

public void assertTuple(ReteTuple leftTuple,
                        PropagationContext context,
                        InternalWorkingMemory workingMemory)
Description copied from interface: TupleSink
Assert a new ReteTuple.

Parameters:
leftTuple - The ReteTuple to propagate.
context - The PropagationContext of the WorkingMemory action
workingMemory - the WorkingMemory session.

retractTuple

public void retractTuple(ReteTuple leftTuple,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)

assertObject

public void assertObject(InternalFactHandle handle,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
Description copied from interface: ObjectSink
Assert a new FactHandleImpl.

Parameters:
handle - The asserted FactHandle/code>.
context - The PropagationContext of the WorkingMemory action.
workingMemory - the WorkingMemory session.

retractObject

public void retractObject(InternalFactHandle handle,
                          PropagationContext context,
                          InternalWorkingMemory workingMemory)
Description copied from interface: ObjectSink
Retract an existing FactHandleImpl.

Parameters:
handle - The FactHandle/code> to retract.
context - The PropagationContext of the WorkingMemory action.
workingMemory - the WorkingMemory session.

modifyTuple

public void modifyTuple(boolean isAssert,
                        ReteTuple leftTuple,
                        InternalFactHandle handle,
                        PropagationContext context,
                        InternalWorkingMemory workingMemory)

updateSink

public void updateSink(TupleSink sink,
                       PropagationContext context,
                       InternalWorkingMemory workingMemory)
Specified by:
updateSink in class TupleSource

hashCode

public int hashCode()
Description copied from class: BaseNode
The hashCode return is simply the unique id of the node. It is expected that base classes will also implement equals(Object object).


equals

public boolean equals(java.lang.Object object)

toString

public java.lang.String toString()

createMemory

public java.lang.Object createMemory(RuleBaseConfiguration config)
Creates a BetaMemory for the BetaNode's memory.

Specified by:
createMemory in interface NodeMemory

getConstraints

public BetaNodeFieldConstraint[] getConstraints()

attach

public void attach()
Description copied from class: BaseNode
Attaches the node into the network. Usually to the parent ObjectSource or TupleSource

Specified by:
attach in class BaseNode

getRules

public java.util.List getRules()

getObjectTypeNode

public ObjectTypeNode getObjectTypeNode()

attach

public void attach(InternalWorkingMemory[] workingMemories)
Specified by:
attach in class BaseNode

remove

public void remove(RuleRemovalContext context,
                   BaseNode node,
                   InternalWorkingMemory[] workingMemories)
Description copied from class: BaseNode
Removes the node from teh network. Usually from the parent ObjectSource or TupleSource

Specified by:
remove in class BaseNode

isObjectMemoryEnabled

public boolean isObjectMemoryEnabled()
Specified by:
isObjectMemoryEnabled in interface ObjectSink

setObjectMemoryEnabled

public void setObjectMemoryEnabled(boolean objectMemory)
Specified by:
setObjectMemoryEnabled in interface ObjectSink

isTupleMemoryEnabled

public boolean isTupleMemoryEnabled()
Specified by:
isTupleMemoryEnabled in interface TupleSink

setTupleMemoryEnabled

public void setTupleMemoryEnabled(boolean tupleMemoryEnabled)
Specified by:
setTupleMemoryEnabled in interface TupleSink

dumpMemory

public void dumpMemory(InternalWorkingMemory workingMemory)

getNextTupleSinkNode

public TupleSinkNode getNextTupleSinkNode()
Returns the next node

Specified by:
getNextTupleSinkNode in interface TupleSinkNode
Returns:
The next TupleSinkNode

setNextTupleSinkNode

public void setNextTupleSinkNode(TupleSinkNode next)
Sets the next node

Specified by:
setNextTupleSinkNode in interface TupleSinkNode
Parameters:
next - The next TupleSinkNode

getPreviousTupleSinkNode

public TupleSinkNode getPreviousTupleSinkNode()
Returns the previous node

Specified by:
getPreviousTupleSinkNode in interface TupleSinkNode
Returns:
The previous TupleSinkNode

setPreviousTupleSinkNode

public void setPreviousTupleSinkNode(TupleSinkNode previous)
Sets the previous node

Specified by:
setPreviousTupleSinkNode in interface TupleSinkNode
Parameters:
previous - The previous TupleSinkNode

getNextObjectSinkNode

public ObjectSinkNode getNextObjectSinkNode()
Returns the next node

Specified by:
getNextObjectSinkNode in interface ObjectSinkNode
Returns:
The next ObjectSinkNode

setNextObjectSinkNode

public void setNextObjectSinkNode(ObjectSinkNode next)
Sets the next node

Specified by:
setNextObjectSinkNode in interface ObjectSinkNode
Parameters:
next - The next ObjectSinkNode

getPreviousObjectSinkNode

public ObjectSinkNode getPreviousObjectSinkNode()
Returns the previous node

Specified by:
getPreviousObjectSinkNode in interface ObjectSinkNode
Returns:
The previous ObjectSinkNode

setPreviousObjectSinkNode

public void setPreviousObjectSinkNode(ObjectSinkNode previous)
Sets the previous node

Specified by:
setPreviousObjectSinkNode in interface ObjectSinkNode
Parameters:
previous - The previous ObjectSinkNode