|
HOME | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ireasoning.util.CTreeNode
This class is a tree data structure. It can be converted to a JTree node to be displayed in a UI program.
Constructor Summary | |
CTreeNode(Comparable name)
Construtor for creating root node. |
|
CTreeNode(Comparable name,
CTreeNode root)
Constructs a non-root node if passed root is not null. |
Method Summary | |
CTreeNode |
addChild(Comparable name)
Not applicable, only supported in ordered tree node classes |
CTreeNode |
addChild(CTreeNode node)
Not applicable, only supported in ordered tree node classes |
CTreeNode |
appendChild(Comparable name)
Appends a new node with the passed name |
CTreeNode |
appendChild(CTreeNode newChild)
Adds the node newChild to the end of the list of children of this node. |
CTreeNode |
appendChild(CTreeNode newChild,
int mode)
Adds the node newChild to the end of the list of children of this node. |
int |
compareTo(Comparable name)
Compares this Object with the specified Object for order. |
int |
compareTo(CTreeNode node)
Compares this Object with the specified Object for order. |
int |
compareTo(Object o)
Compares this Object with the specified Object for order. |
CTreeNode |
copy()
Deep copy of itself, including its subtree. |
boolean |
equals(Object obj)
Checks if passed object is equal to this object |
CTreeNode |
getChildNode(int index)
Returns child node at specified index. |
int |
getChildNodeCount()
Returns the number of immidiate child nodes |
int |
getChildNodeIndex(CTreeNode node)
Returns the passed child node's position. |
ArrayList |
getChildNodes()
Returns all the immidiate child nodes |
CTreeNode |
getFirstChild()
Returns the first immediate child of this node. |
CTreeNode |
getLastChild()
Returns the last child of this node |
static CTreeNode |
getLeftMost(CTreeNode start)
Gets the left most child node (could be multiple levels below starting node) starting from the passed start. |
Comparable |
getName()
Gets the name object |
CTreeNode |
getNextSibling()
The node immediately following this node. |
CTreeNode |
getParent()
Returns the parent node. |
CTreeNode |
getPrevSibling()
Return the node immediately preceding this node. |
Comparable |
getRawName()
|
static CTreeNode |
getRightMost(CTreeNode start)
Gets the right most child node (could be multiple levels below starting node) starting from the passed start. |
CTreeNode |
getRoot()
Gets the root node |
int |
hashCode()
|
CTreeNode |
insertBefore(CTreeNode newChild,
CTreeNode refChild)
Inserts the node newChild before the existing child node refChild . |
boolean |
isChildNode(CTreeNode child)
Checks the passed child is one of this node 's immediate child nodes |
boolean |
isInSameTree(CTreeNode node)
Checks if the passed node is in the same tree as this object |
boolean |
isLeaf()
Returns true if this node has no child node |
boolean |
isRoot()
Returns true if this object itself is a root node |
boolean |
removeChild(Comparable oldChildName)
Removes the first encounter of its immediate child node with oldChildName (only remove 1 node). |
boolean |
removeChild(CTreeNode oldChild)
Removes the immediate child node indicated by oldChild from the list of children |
boolean |
removeChild(int index)
Removes the immediate child node at specified index |
static boolean |
removeNode(CTreeNode node)
Removes the passed node from its tree. |
CTreeNode |
replaceChild(CTreeNode oldChild,
CTreeNode newChild)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node. |
CTreeNode |
search(Comparable name)
Searches for the node with passed name within this node's subtree, starting from itself. |
void |
setName(Comparable name)
Sets a new name |
void |
setParent(CTreeNode parent)
Sets parent node |
void |
setRoot(CTreeNode r)
Sets a new root node |
DefaultMutableTreeNode |
toJTreeNode()
Convert this node (including all subtrees) to JTree node, so it can be displayed in a JTree. |
String |
toString()
|
static void |
traverse(CTreeNode start,
TraverseListener listener)
Traverse the tree starting from the passed start node. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CTreeNode(Comparable name)
name
- an instance of a class that implements Comparable interface, usually represents the identity of the node.public CTreeNode(Comparable name, CTreeNode root)
name
- an instance of a class that implements Comparable interface, usually represents the identity of the node.root
- root node. If it's null, then this object become a new root node.Method Detail |
public CTreeNode copy()
public boolean isRoot()
public CTreeNode getRoot()
public void setRoot(CTreeNode r)
public Comparable getName()
public void setName(Comparable name)
public boolean isLeaf()
public String toString()
public CTreeNode getChildNode(int index)
public int getChildNodeIndex(CTreeNode node)
public ArrayList getChildNodes()
public int getChildNodeCount()
public CTreeNode getParent()
public void setParent(CTreeNode parent)
public CTreeNode getNextSibling()
public CTreeNode getPrevSibling()
public CTreeNode getFirstChild()
public CTreeNode getLastChild()
public CTreeNode appendChild(Comparable name)
appendChild(CTreeNode newChild)
public CTreeNode appendChild(CTreeNode newChild)
newChild
- - The node to add.
public CTreeNode appendChild(CTreeNode newChild, int mode)
newChild
- - The node to add.mode
- 0: append anyway; 1: no append if exists 2: merge and replace the existing child node.
public CTreeNode insertBefore(CTreeNode newChild, CTreeNode refChild)
newChild
- - node to insert.refChild
- - reference node, i.e., the node before which the new node must be inserted.
public boolean isChildNode(CTreeNode child)
public boolean removeChild(Comparable oldChildName)
public boolean removeChild(int index)
public boolean removeChild(CTreeNode oldChild)
removeNode(CTreeNode node)
public static boolean removeNode(CTreeNode node)
removeChild(CTreeNode oldChild)
public CTreeNode replaceChild(CTreeNode oldChild, CTreeNode newChild)
newChild
- - The new node to put in the child listoldChild
- - The node being replaced in the listpublic int compareTo(Comparable name)
public int compareTo(CTreeNode node)
public int compareTo(Object o)
compareTo
in interface Comparable
public boolean equals(Object obj)
public int hashCode()
public CTreeNode addChild(Comparable name)
public CTreeNode addChild(CTreeNode node)
public static CTreeNode getRightMost(CTreeNode start)
public static CTreeNode getLeftMost(CTreeNode start)
public static void traverse(CTreeNode start, TraverseListener listener)
public boolean isInSameTree(CTreeNode node)
public DefaultMutableTreeNode toJTreeNode()
public CTreeNode search(Comparable name)
public final Comparable getRawName()
|
HOME | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |