de.fhdarmstadt.fbi.dtree.model
Class DTreeNode

java.lang.Object
  extended byde.fhdarmstadt.fbi.dtree.model.DTreeNode

public class DTreeNode
extends java.lang.Object

Represents a node in a pattern matching decision tree.

The node contains a regular pattern and may contain child nodes for the positive and negative edge. If no child node is given, then the evaluation is finished and classifies the test data according to the node name.

A DTreeNode is only valid within the alphabet context given in the dtree. It is not possible to add a certain tree node to two or more parent nodes.

This implementation does not test, whether the node's pattern matches the tree's alphabet.


Constructor Summary
DTreeNode()
          Creates a new DTreeNode with a positive match-all pattern.
DTreeNode(RegularPattern pattern)
          Creates a new DTreeNode with the given regular pattern.
 
Method Summary
 DTreeNode getNegativeMatchNode()
          Returns the negative-match child node or null, if there is no next node.
 DTreeNode getParent()
          Returns the parent node of this tree node or null, if the node has no parent.
 RegularPattern getPattern()
          Returns the pattern assigned with this node.
 DTreeNode getPositiveMatchNode()
          Returns the positive-match child node or null, if there is no next node.
 DTree getTree()
          Returns the decision tree, to which this node is assigned.
 boolean isLeaf()
          Checks, whether the given node is a leaf.
 void setNegativeMatchNode(DTreeNode negativeMatchNode)
          Defines the negative-match child node or null, if there is no next node.
protected  void setParent(DTreeNode parent)
          Defines the parent node for this tree node.
 void setPattern(RegularPattern pattern)
          Defines the pattern for this node.
 void setPositiveMatchNode(DTreeNode positiveMatchNode)
          Defines the positive-match child node or null, if there is no next node.
protected  void setTree(DTree tree)
          Redefines the tree reference for the node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DTreeNode

public DTreeNode()
Creates a new DTreeNode with a positive match-all pattern. The node is initally not assigned to a tree or parent node.


DTreeNode

public DTreeNode(RegularPattern pattern)
Creates a new DTreeNode with the given regular pattern. The node is initally not assigned to a tree or parent node.

Parameters:
pattern - the pattern, never null.
Method Detail

getNegativeMatchNode

public DTreeNode getNegativeMatchNode()
Returns the negative-match child node or null, if there is no next node.

Returns:
the next node for negative evaluation results.

setNegativeMatchNode

public void setNegativeMatchNode(DTreeNode negativeMatchNode)
Defines the negative-match child node or null, if there is no next node.

Parameters:
negativeMatchNode - the next node for negative evaluation results.
Throws:
java.lang.IllegalArgumentException - if the given node is a child node of this node or if the node is already assigned to a different tree.

getPositiveMatchNode

public DTreeNode getPositiveMatchNode()
Returns the positive-match child node or null, if there is no next node.

Returns:
the next node for positive evaluation results.

setPositiveMatchNode

public void setPositiveMatchNode(DTreeNode positiveMatchNode)
Defines the positive-match child node or null, if there is no next node.

Parameters:
positiveMatchNode - the next node for positive evaluation results.

isLeaf

public boolean isLeaf()
Checks, whether the given node is a leaf. Leaf nodes have no childs.

Returns:
true, if the node is a leaf, false otherwise.

getPattern

public RegularPattern getPattern()
Returns the pattern assigned with this node.

Returns:
the pattern, never null.

setPattern

public void setPattern(RegularPattern pattern)
Defines the pattern for this node.

Parameters:
pattern - the pattern
Throws:
java.lang.NullPointerException - if the given pattern is null.

getParent

public DTreeNode getParent()
Returns the parent node of this tree node or null, if the node has no parent.

Returns:
the parent node.

setParent

protected void setParent(DTreeNode parent)
Defines the parent node for this tree node. This method is used internally to ensure the concurrency of the decision tree and should not be called from outside.

Parameters:
parent - the new parent node (may be null).

getTree

public DTree getTree()
Returns the decision tree, to which this node is assigned.

Returns:
the node's decision tree or null, if this node is not part of a tree.

setTree

protected void setTree(DTree tree)
Redefines the tree reference for the node.

Parameters:
tree - the tree for the given node.