org.drools.reteoo
Class AlphaNode

java.lang.Object
  extended by org.drools.common.BaseNode
      extended by org.drools.reteoo.ObjectSource
          extended by org.drools.reteoo.AlphaNode
All Implemented Interfaces:
Externalizable, Serializable, NetworkNode, NodeMemory, ObjectSink, ObjectSinkNode, Sink

public class AlphaNode
extends ObjectSource
implements ObjectSinkNode, NodeMemory

AlphaNodes are nodes in the Rete network used to apply FieldConstraint<.code>s on asserted fact objects where the FieldConstraints have no dependencies on any other of the facts in the current Rule.

See Also:
AlphaNodeFieldConstraint, Serialized Form

Nested Class Summary
static class AlphaNode.AlphaMemory
           
 
Field Summary
 
Fields inherited from class org.drools.reteoo.ObjectSource
sink, source
 
Fields inherited from class org.drools.common.BaseNode
associations, id, partitionId, partitionsEnabled
 
Constructor Summary
AlphaNode()
           
AlphaNode(int id, AlphaNodeFieldConstraint constraint, ObjectSource objectSource, BuildContext context)
          Construct an AlphaNode with a unique id using the provided FieldConstraint and the given ObjectSource.
 
Method Summary
 void assertObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void attach()
          Attaches the node into the network.
 void attach(InternalWorkingMemory[] workingMemories)
           
 Memory createMemory(RuleBaseConfiguration config)
          Creates a HashSet for the AlphaNode's memory.
 boolean equals(Object object)
           
 AlphaNodeFieldConstraint getConstraint()
          Retruns the FieldConstraint
 ObjectSinkNode getNextObjectSinkNode()
          Returns the next node
 ObjectSinkNode getPreviousObjectSinkNode()
          Returns the previous node
 int hashCode()
          The hashCode return is simply the unique id of the node.
 void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void readExternal(ObjectInput in)
           
 void setNextObjectSinkNode(ObjectSinkNode next)
          Sets the next node
 void setPreviousObjectSinkNode(ObjectSinkNode previous)
          Sets the previous node
 String toString()
           
 void updateSink(ObjectSink sink, PropagationContext context, InternalWorkingMemory workingMemory)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.reteoo.ObjectSource
addObjectSink, doRemove, getParentObjectSource, getSinkPropagator, isInUse, networkUpdated, removeObjectSink
 
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

AlphaNode

public AlphaNode()

AlphaNode

public AlphaNode(int id,
                 AlphaNodeFieldConstraint constraint,
                 ObjectSource objectSource,
                 BuildContext context)
Construct an AlphaNode with a unique id using the provided FieldConstraint and the given ObjectSource. Set the boolean flag to true if the node is supposed to have local memory, or false otherwise. Memory is optional for AlphaNodes and is only of benefic when adding additional Rules at runtime.

Parameters:
id - Node's ID
constraint - Node's constraints
objectSource - Node's object source
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class ObjectSource
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class ObjectSource
Throws:
IOException

getConstraint

public AlphaNodeFieldConstraint getConstraint()
Retruns the FieldConstraint

Returns:
FieldConstraint

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

attach

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

assertObject

public void assertObject(InternalFactHandle factHandle,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
Specified by:
assertObject in interface ObjectSink

modifyObject

public void modifyObject(InternalFactHandle factHandle,
                         ModifyPreviousTuples modifyPreviousTuples,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
Specified by:
modifyObject in interface ObjectSink

updateSink

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

createMemory

public Memory createMemory(RuleBaseConfiguration config)
Creates a HashSet for the AlphaNode's memory.

Specified by:
createMemory in interface NodeMemory

toString

public String toString()
Overrides:
toString in class BaseNode

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).

Overrides:
hashCode in class BaseNode

equals

public boolean equals(Object object)
Overrides:
equals in class Object

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


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