org.drools.reteoo
Class ExistsNode

java.lang.Object
  extended by org.drools.common.BaseNode
      extended by org.drools.reteoo.LeftTupleSource
          extended by org.drools.reteoo.BetaNode
              extended by org.drools.reteoo.ExistsNode
All Implemented Interfaces:
Externalizable, Serializable, NetworkNode, NodeMemory, LeftTupleSink, LeftTupleSinkNode, ObjectSink, ObjectSinkNode, RightTupleSink, Sink

public class ExistsNode
extends BetaNode

ExistsNode extends BetaNode to perform tests for the existence of a Fact plus one or more conditions. Where existence is found the left ReteTuple is copied and propagated. Further to this it maintains the "truth" by canceling any Activations that are no longer considered true by the retraction of ReteTuple's or FactHandleImpl. Tuples are considered to be asserted from the left input and facts from the right input. The BetaNode provides the BetaMemory to store asserted ReteTuples and FactHandleImpls. Each fact handle is stored in the right memory.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.drools.reteoo.BetaNode
behavior, concurrentRightTupleMemory, constraints, leftInput, lrUnlinkingEnabled, objectMemory, rightInput, tupleMemoryEnabled
 
Fields inherited from class org.drools.reteoo.LeftTupleSource
sink
 
Fields inherited from class org.drools.common.BaseNode
associations, id, partitionId, partitionsEnabled
 
Constructor Summary
ExistsNode()
           
ExistsNode(int id, LeftTupleSource leftInput, ObjectSource rightInput, BetaConstraints joinNodeBinder, Behavior[] behaviors, BuildContext context)
          Construct.
 
Method Summary
 void assertLeftTuple(LeftTuple leftTuple, PropagationContext context, InternalWorkingMemory workingMemory)
          Assert a new ReteTuple from the left input.
 void assertObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory)
          Assert a new FactHandleImpl from the right input.
 short getType()
           
 void modifyLeftTuple(LeftTuple leftTuple, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void modifyRightTuple(RightTuple rightTuple, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void retractLeftTuple(LeftTuple leftTuple, PropagationContext context, InternalWorkingMemory workingMemory)
          Retract the ReteTuple, any resulting propagated joins are also retracted.
 void retractRightTuple(RightTuple rightTuple, PropagationContext context, InternalWorkingMemory workingMemory)
          Retract the FactHandleImpl.
 String toString()
           
 void updateSink(LeftTupleSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
          Updates the given sink propagating all previously propagated tuples to it
 
Methods inherited from class org.drools.reteoo.BetaNode
attach, attach, createMemory, createRightTuple, doRemove, dumpMemory, equals, getBehaviors, getConstraints, getFirstRightTuple, getNextLeftTupleSinkNode, getNextObjectSinkNode, getObjectTypeNode, getPreviousLeftTupleSinkNode, getPreviousObjectSinkNode, getRawConstraints, getRightIterator, getRules, hashCode, isConcurrentRightTupleMemory, isLeftTupleMemoryEnabled, isObjectMemoryEnabled, leftUnlinked, modifyLeftTuple, modifyObject, networkUpdated, readExternal, rightUnlinked, setConcurrentRightTupleMemory, setLeftTupleMemoryEnabled, setNextLeftTupleSinkNode, setNextObjectSinkNode, setObjectMemoryEnabled, setPreviousLeftTupleSinkNode, setPreviousObjectSinkNode, setUnificationJoin, writeExternal
 
Methods inherited from class org.drools.reteoo.LeftTupleSource
addTupleSink, getSinkPropagator, isInUse, removeTupleSink
 
Methods inherited from class org.drools.common.BaseNode
addAssociation, getAssociations, getId, getPartitionId, remove, removeAssociation, setPartitionId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.drools.common.NetworkNode
getId, getPartitionId
 
Methods inherited from interface org.drools.common.NodeMemory
getId
 

Constructor Detail

ExistsNode

public ExistsNode()

ExistsNode

public ExistsNode(int id,
                  LeftTupleSource leftInput,
                  ObjectSource rightInput,
                  BetaConstraints joinNodeBinder,
                  Behavior[] behaviors,
                  BuildContext context)
Construct.

Parameters:
id - The unique id for this node.
leftInput - The left input TupleSource.
rightInput - The right input ObjectSource.
joinNodeBinder - The constraints to be applied to the right objects
Method Detail

assertLeftTuple

public void assertLeftTuple(LeftTuple leftTuple,
                            PropagationContext context,
                            InternalWorkingMemory workingMemory)
Assert a new ReteTuple from the left input. It iterates over the right FactHandleImpl's and if any match is found, a copy of the ReteTuple is made and propagated.

Parameters:
tuple - The Tuple being asserted.
context - The PropagationContext
workingMemory - The working memory session.

assertObject

public void assertObject(InternalFactHandle factHandle,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
Assert a new FactHandleImpl from the right input. If it matches any left ReteTuple's that had no matches before, propagate tuple as an assertion.

Parameters:
factHandle - The FactHandleImpl being asserted.
context - The PropagationContext
workingMemory - The working memory session.

retractRightTuple

public void retractRightTuple(RightTuple rightTuple,
                              PropagationContext context,
                              InternalWorkingMemory workingMemory)
Retract the FactHandleImpl. If the handle has any ReteTuple matches and those tuples now have no other match, retract tuple

Parameters:
handle - the being retracted
context - The PropagationContext
workingMemory - The working memory session.

retractLeftTuple

public void retractLeftTuple(LeftTuple leftTuple,
                             PropagationContext context,
                             InternalWorkingMemory workingMemory)
Retract the ReteTuple, any resulting propagated joins are also retracted.

Parameters:
leftTuple - The tuple being retracted
context - The PropagationContext
workingMemory - The working memory session.

modifyLeftTuple

public void modifyLeftTuple(LeftTuple leftTuple,
                            PropagationContext context,
                            InternalWorkingMemory workingMemory)

modifyRightTuple

public void modifyRightTuple(RightTuple rightTuple,
                             PropagationContext context,
                             InternalWorkingMemory workingMemory)

updateSink

public void updateSink(LeftTupleSink sink,
                       PropagationContext context,
                       InternalWorkingMemory workingMemory)
Updates the given sink propagating all previously propagated tuples to it

Specified by:
updateSink in class LeftTupleSource

toString

public String toString()
Overrides:
toString in class BetaNode

getType

public short getType()


Copyright © 2001-2013 JBoss Inc.. All Rights Reserved.