|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavafe.filespace.Tree
A Tree is a n-ary tree with data at each node; the direct children of a node are unordered but distinguished via String labels on the edges to them.
All labels must be non-null.
Field Summary | |
java.lang.Object |
data
The data, if any, associated with this node: |
private java.lang.String |
label
The label on the edge leading to us from our parent, or null if we have no parent. |
private Tree |
parent
Our parent or null if we have no parent (aka, we are a root) |
Constructor Summary | |
protected |
Tree(java.lang.Object data)
Create a root node: |
protected |
Tree(Tree parent,
java.lang.String label,
java.lang.Object data)
Create a non-root node: |
Method Summary | |
abstract java.util.Enumeration |
children()
An enumeration of this node's direct children. |
Tree |
getChild(java.lang.String label)
Fetch our direct child along the edge labelled label. |
int |
getChildrenCount()
Return a count of how many direct children we have: |
java.lang.String |
getLabel()
Return the label on the edge to us from our parent or null if we have no parent. |
Tree |
getParent()
Return our parent node or null if we have no parent |
Tree |
getQualifiedChild(java.lang.String name,
char separator)
Return the child with a given partially qualified name or null if no such node exists; if this node is X.Y and name is Z! |
java.lang.String |
getQualifiedName(java.lang.String separator)
Return a fully qualified name for this node using a specified separator String. |
Tree |
getRootNode()
Return the root node for the tree we belong to. |
java.lang.String |
getSimpleName()
The same as getLabel, except that it returns "" instead of null for the top node. |
boolean |
isLeaf()
Return true iff we have no direct children |
void |
print(java.lang.String prefix)
Print out on System.out a human-readable representation of this tree. |
void |
printDetails(java.lang.String prefix)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private Tree parent
private java.lang.String label
public java.lang.Object data
Constructor Detail |
protected Tree(java.lang.Object data)
protected Tree(Tree parent, java.lang.String label, java.lang.Object data)
Method Detail |
public final Tree getParent()
public final java.lang.String getLabel()
public abstract java.util.Enumeration children()
Note: The Objects returned by the resulting enumeration's nextElement method are guaranteed to be of type Tree, non-null, and have non-null labels.
public Tree getChild(java.lang.String label)
public boolean isLeaf()
public int getChildrenCount()
public final java.lang.String getSimpleName()
public final java.lang.String getQualifiedName(java.lang.String separator)
If the sequences of labels on the edges from the root of the tree this node belongs to til this node is X, Y, ... Z, then this routine returns the string X!Y! ... !Z, where ! is the separator. Normal usage is to use "." as the separator.
Root nodes are thus named "" and their direct children have names of the form X, where X is their label.
For the resulting name to be useful, labels should never contain the separator or be the empty string.
public final Tree getRootNode()
public final Tree getQualifiedChild(java.lang.String name, char separator)
See getQualifiedName for more information on qualified names. Name must be non-null.
public void print(java.lang.String prefix)
Included is our fully qualified name, our data, and information about each of our children.
public void printDetails(java.lang.String prefix)
|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |