org.drools.common
Class BaseNode

java.lang.Object
  extended by org.drools.common.BaseNode
All Implemented Interfaces:
Externalizable, Serializable, NetworkNode
Direct Known Subclasses:
LeftTupleSource, ObjectSource, QueryTerminalNode, RuleTerminalNode

public abstract class BaseNode
extends Object
implements NetworkNode

The base class for all Rete nodes.

See Also:
Serialized Form

Field Summary
protected  Map<org.drools.definition.rule.Rule,RuleComponent> associations
           
protected  int id
           
protected  RuleBasePartitionId partitionId
           
protected  boolean partitionsEnabled
           
 
Constructor Summary
BaseNode()
           
BaseNode(int id, RuleBasePartitionId partitionId, boolean partitionsEnabled)
          All nodes have a unique id, set in the constructor.
 
Method Summary
 void addAssociation(org.drools.definition.rule.Rule rule, RuleComponent component)
          Creates an association between this node and the rule + rule component that caused the creation of this node.
abstract  void attach()
          Attaches the node into the network.
abstract  void attach(InternalWorkingMemory[] workingMemories)
           
protected abstract  void doRemove(RuleRemovalContext context, ReteooBuilder builder, BaseNode node, InternalWorkingMemory[] workingMemories)
          Removes the node from teh network.
 Map<org.drools.definition.rule.Rule,RuleComponent> getAssociations()
          Returns the map of associations for this node
 int getId()
          Returns the unique id that represents the node in the Rete network
 RuleBasePartitionId getPartitionId()
          Returns the partition ID for which this node belongs to
 int hashCode()
          The hashCode return is simply the unique id of the node.
abstract  boolean isInUse()
          Returns true in case the current node is in use (is referenced by any other node)
abstract  void networkUpdated()
          A method that is called for all nodes whose network below them changed, after the change is complete, providing them with an oportunity for state update
 void readExternal(ObjectInput in)
           
 void remove(RuleRemovalContext context, ReteooBuilder builder, BaseNode node, InternalWorkingMemory[] workingMemories)
           
 void removeAssociation(org.drools.definition.rule.Rule rule)
          Removes the association to the given rule from the associations map.
 void setPartitionId(RuleBasePartitionId partitionId)
          Sets the partition this node belongs to
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected int id

partitionId

protected RuleBasePartitionId partitionId

partitionsEnabled

protected boolean partitionsEnabled

associations

protected Map<org.drools.definition.rule.Rule,RuleComponent> associations
Constructor Detail

BaseNode

public BaseNode()

BaseNode

public BaseNode(int id,
                RuleBasePartitionId partitionId,
                boolean partitionsEnabled)
All nodes have a unique id, set in the constructor.

Parameters:
id - The unique id
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

getId

public int getId()
Description copied from interface: NetworkNode
Returns the unique id that represents the node in the Rete network

Specified by:
getId in interface NetworkNode
Returns:
unique int value

attach

public abstract void attach()
Attaches the node into the network. Usually to the parent ObjectSource or TupleSource


attach

public abstract void attach(InternalWorkingMemory[] workingMemories)

networkUpdated

public abstract void networkUpdated()
A method that is called for all nodes whose network below them changed, after the change is complete, providing them with an oportunity for state update


remove

public void remove(RuleRemovalContext context,
                   ReteooBuilder builder,
                   BaseNode node,
                   InternalWorkingMemory[] workingMemories)

doRemove

protected abstract void doRemove(RuleRemovalContext context,
                                 ReteooBuilder builder,
                                 BaseNode node,
                                 InternalWorkingMemory[] workingMemories)
Removes the node from teh network. Usually from the parent ObjectSource or TupleSource

Parameters:
builder -

isInUse

public abstract boolean isInUse()
Returns true in case the current node is in use (is referenced by any other node)

Returns:

hashCode

public int hashCode()
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 Object

toString

public String toString()
Overrides:
toString in class Object

getPartitionId

public RuleBasePartitionId getPartitionId()
Returns the partition ID for which this node belongs to

Specified by:
getPartitionId in interface NetworkNode
Returns:

setPartitionId

public void setPartitionId(RuleBasePartitionId partitionId)
Sets the partition this node belongs to

Parameters:
partitionId -

addAssociation

public void addAssociation(org.drools.definition.rule.Rule rule,
                           RuleComponent component)
Creates an association between this node and the rule + rule component that caused the creation of this node. Since nodes might be shared, there might be more than one source for each node.

Parameters:
rule - The rule source
component -

getAssociations

public Map<org.drools.definition.rule.Rule,RuleComponent> getAssociations()
Returns the map of associations for this node

Returns:

removeAssociation

public void removeAssociation(org.drools.definition.rule.Rule rule)
Removes the association to the given rule from the associations map.

Parameters:
rule -


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