org.drools.common
Class BaseNode

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

public abstract class BaseNode
extends java.lang.Object
implements NetworkNode

The base class for all Rete nodes.

Author:
Mark Proctor, Bob McWhirter
See Also:
Serialized Form

Field Summary
protected  int id
           
 
Constructor Summary
BaseNode(int id)
          All nodes have a unique id, set in the constructor.
 
Method Summary
abstract  void attach()
          Attaches the node into the network.
abstract  void attach(InternalWorkingMemory[] workingMemories)
           
 int getId()
          Returns the unique id that represents the node in the Rete network
 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 remove(RuleRemovalContext context, BaseNode node, InternalWorkingMemory[] workingMemories)
          Removes the node from teh network.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected final int id
Constructor Detail

BaseNode

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

Parameters:
id - The unique id
Method Detail

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)

remove

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


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 java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object