Inheritance diagram for edu.virtualschool.jwaa.TreeNode:


Each node identifies its parent via its (single!) parent instance variable, and its children via a ArrayList of child references.
The parent-child hierarchy, if populated as described above, is available for applicatio-specific Page subclasses to use to generate navigational menus, next-prev buttons, and so forth. It is also used by RoleAbstraction as the basis for role hierarchies.
Page
Definition at line 24 of file TreeNode.java.
Public Member Functions | |
| TreeNode () | |
| final void | addChildNode (TreeNode child) |
| final void | addChildNodeArray (TreeNode[] c) |
| final void | removeChildNode (TreeNode child) |
| final void | removeAllChildNodes () |
| final TreeNode | getParentNode () |
| final void | detachFromParent () |
| final int | getDepth () |
| final ArrayList | getRootPath () |
| final TreeNode | getRootNode () |
| final Iterator | childrenIterator () |
| final boolean | isChildNodeOf (TreeNode thatNode) |
| final boolean | isRootNode () |
| final TreeNode | nextSiblingNode () |
| final TreeNode | prevSiblingNode () |
| final void | accept (Visitor visitor) |
Static Package Attributes | |
| final Logger | logger = Logger.getLogger(TreeNode.class.getName()) |
|
|
Construct a node with no children Definition at line 34 of file TreeNode.java.
00034 { }
|
|
|
Accept a Visitor
Definition at line 192 of file TreeNode.java. References edu.virtualschool.jwaa.Visitor.isDone(), and edu.virtualschool.jwaa.Visitor.visit().
|
|
|
Add a child node
Definition at line 39 of file TreeNode.java. References edu.virtualschool.jwaa.TreeNode.setParentNode().
00040 {
00041 if (child != null)
00042 child.setParentNode(this);
00043 }
|
|
|
Return an iterator over the children of this node
Definition at line 132 of file TreeNode.java. Referenced by edu.virtualschool.jwaa.GenericPage.children(), edu.virtualschool.jwaa.GenericLookAndFeel.computeNavigationBar(), and edu.virtualschool.jwaa.MetaPage.nextPage().
00133 {
00134 return childNodeList.iterator();
00135 }
|
|
|
Detach the receiver from its parent. Definition at line 70 of file TreeNode.java.
00071 {
00072 setParentNode(null);
00073 }
|
|
|
Return the depth of this node in the tree.
Definition at line 98 of file TreeNode.java. References edu.virtualschool.jwaa.TreeNode.parentNode.
00099 {
00100 int depth = 0;
00101 for(TreeNode node = this; node != null; node = node.parentNode)
00102 depth++;
00103 return depth;
00104 }
|
|
|
Return the parent of this node or null if none.
Definition at line 66 of file TreeNode.java. Referenced by edu.virtualschool.jwaa.GenericPage.getParent(), edu.virtualschool.jwaa.MetaPage.nextPage(), and edu.virtualschool.jwaa.MetaPage.prevPage().
00066 { return parentNode; }
|
|
|
Return the root node of the tree this node is is.
Definition at line 120 of file TreeNode.java. References edu.virtualschool.jwaa.TreeNode.parentNode.
00121 {
00122 TreeNode node = null;
00123 for (node = this; node != null; node = node.parentNode)
00124 if (node.parentNode == null)
00125 break;
00126 return node;
00127 }
|
|
|
Return an ArrayList of this node and each of its parents as the path from the receiver to the root. Definition at line 109 of file TreeNode.java. References edu.virtualschool.jwaa.TreeNode.parentNode. Referenced by edu.virtualschool.jwaa.GenericLookAndFeel.computeNavigationBar().
00110 {
00111 ArrayList path = new ArrayList();
00112 for (TreeNode node = this; node != null; node = node.parentNode)
00113 path.add(node);
00114 return path;
00115 }
|
|
|
Returns true if that node is one of the children of this node.
Definition at line 149 of file TreeNode.java. References edu.virtualschool.jwaa.TreeNode.parentNode.
00150 {
00151 for (TreeNode thisNode = this; thisNode != null; thisNode = thisNode.parentNode)
00152 if (thisNode == thatNode) return true;
00153 return false;
00154 }
|
|
|
Returns true if this is a root node, e.g. a node whose parent == null.
Definition at line 159 of file TreeNode.java.
00159 { return parentNode == null; }
|
|
|
Return the righthand sibling of this node or null if none. This is used to support the next/prev hotlinks in navigation menus.
Definition at line 166 of file TreeNode.java. References edu.virtualschool.jwaa.TreeNode.childNodeList. Referenced by edu.virtualschool.jwaa.MetaPage.nextPage().
00167 {
00168 if (parentNode == null) return null;
00169 ArrayList siblings = parentNode.childNodeList;
00170 int index = siblings.indexOf(this);
00171 if (index+1 < siblings.size()) return (TreeNode)siblings.get(index+1);
00172 else return null;
00173 }
|
|
|
Return the lefthand sibling of this node or null if none. This is used to support the next/prev hotlinks in navigation menus.
Definition at line 180 of file TreeNode.java. References edu.virtualschool.jwaa.TreeNode.childNodeList. Referenced by edu.virtualschool.jwaa.MetaPage.prevPage().
00181 {
00182 if (parentNode == null) return null;
00183 ArrayList siblings = parentNode.childNodeList;
00184 int index = siblings.indexOf(this);
00185 if (index-1 >= 0) return (TreeNode)siblings.get(index-1);
00186 else return parentNode;
00187 }
|