|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.huguesjohnson.tiamat.TreeNode
public class TreeNode
TreeNode - stores object in a heirarchical (tree) structure
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_PATH_DELIMITER
Default path delimiter. |
Constructor Summary | |
---|---|
TreeNode(java.lang.String name)
Creates a new instance of TreeNode, uses the default path delimiter. |
|
TreeNode(java.lang.String name,
java.lang.Object object)
Creates a new instance of TreeNode, uses the default path delimiter. |
|
TreeNode(java.lang.String name,
java.lang.Object object,
TreeNode parent)
Creates a new instance of TreeNode, uses the default path delimiter. |
|
TreeNode(java.lang.String name,
java.lang.String pathDelimiter)
Creates a new instance of TreeNode. |
|
TreeNode(java.lang.String name,
java.lang.String pathDelimiter,
java.lang.Object object)
Creates a new instance of TreeNode. |
|
TreeNode(java.lang.String name,
java.lang.String pathDelimiter,
java.lang.Object object,
TreeNode parent)
Creates a new instance of TreeNode. |
Method Summary | |
---|---|
protected void |
addChild(TreeNode childNode)
Should be called by another node when it sets this node as the parent. |
TreeNode |
getChild(int index)
Returns the child TreeNode at the specified index, null if index is out of bounds. |
int |
getChildLeafCount(boolean recursive)
Returns the number of leaves for this node. |
TreeNode[] |
getChildLeaves(boolean recursive)
Returns the all leaves for this node. |
TreeNode |
getChildNode(java.lang.String path,
boolean recursive)
Returns the child TreeNode with the specified path, null if it is not found. |
int |
getChildNodeCount(boolean recursive)
Returns the number of children for this node. |
TreeNode[] |
getChildren()
Returns the children of this TreeNode. |
java.lang.String |
getName()
Returns the name of this TreeNode. |
java.lang.Object |
getObject()
Returns the object this TreeNode is storing. |
TreeNode |
getParent()
Returns the parent of this TreeNode. |
java.lang.String |
getPath()
Returns the full path to this node. |
java.lang.String |
getPathDelimiter()
Returns the character used to separate names in path, can only be changed in constructor. |
void |
insertChildNode(java.lang.String path,
TreeNode node)
Inserts a node at the specified path. |
boolean |
isLeaf()
Returns true if no children. |
boolean |
isRoot()
Returns true if parent is null. |
void |
onDeserialize(Formatter formatter,
java.lang.String absoluteDir)
The onDeserialize event should be fired after an object is de-serialized. |
boolean |
removeChildNode(java.lang.String path,
boolean recursive)
Removes the child TreeNode with the specified path. |
void |
setChild(int index,
TreeNode child)
Sets the child TreeNode at the specified index. |
void |
setChildren(TreeNode[] children)
Sets the children of this TreeNode. |
void |
setName(java.lang.String name)
Sets the name of this TreeNode. |
void |
setObject(java.lang.Object object)
Sets the object this TreeNode is storing. |
void |
setParent(TreeNode parent)
Sets the parent of this TreeNode. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_PATH_DELIMITER
Constructor Detail |
---|
public TreeNode(java.lang.String name)
name
- The name of this TreeNode.public TreeNode(java.lang.String name, java.lang.String pathDelimiter)
name
- The name of this TreeNode.pathDelimiter
- The path delimiter to use.public TreeNode(java.lang.String name, java.lang.Object object)
name
- The name of this TreeNode.object
- The object this TreeNode is storing.public TreeNode(java.lang.String name, java.lang.String pathDelimiter, java.lang.Object object)
name
- The name of this TreeNode.pathDelimiter
- The path delimiter to use.object
- The object this TreeNode is storing.public TreeNode(java.lang.String name, java.lang.Object object, TreeNode parent)
name
- The name of this TreeNode.object
- The object this TreeNode is storing.parent
- The parent of this TreeNode.public TreeNode(java.lang.String name, java.lang.String pathDelimiter, java.lang.Object object, TreeNode parent)
name
- The name of this TreeNode.pathDelimiter
- The path delimiter to use.object
- The object this TreeNode is storing.parent
- The parent of this TreeNode.Method Detail |
---|
public java.lang.String getPathDelimiter()
public TreeNode getParent()
public void setParent(TreeNode parent)
parent
- The new parent of this TreeNode.public void setChildren(TreeNode[] children)
children
- The new children of this TreeNode.public TreeNode[] getChildren()
public void setChild(int index, TreeNode child)
index
- The index to set the child TreeNode at.child
- The TreeNode to set.public TreeNode getChild(int index)
index
- The index of the child TreeNode to return.
public java.lang.Object getObject()
public void setObject(java.lang.Object object)
object
- The new object this TreeNode is storing.public java.lang.String getName()
public void setName(java.lang.String name)
name
- The new name of this TreeNode.protected void addChild(TreeNode childNode)
childNode
- The child node to add.public java.lang.String getPath()
public boolean isRoot()
public boolean isLeaf()
public boolean removeChildNode(java.lang.String path, boolean recursive)
path
- The path of the child to remove.recursive
- Set to true to recursively search through children, false to only check the direct children of this TreeNode.
public TreeNode getChildNode(java.lang.String path, boolean recursive)
path
- The path of the child to remove.recursive
- Set to true to recursively search through children, false to only check the direct children of this TreeNode.
public int getChildNodeCount(boolean recursive)
recursive
- Set to true to recursively search through children, false to only check the direct children of this TreeNode.
public int getChildLeafCount(boolean recursive)
recursive
- Set to true to recursively search through children, false to only check the direct children of this TreeNode.
public TreeNode[] getChildLeaves(boolean recursive)
recursive
- Set to true to recursively search through children, false to only check the direct children of this TreeNode.
public void insertChildNode(java.lang.String path, TreeNode node)
path
- The path to insert the node at.node
- The TreeNode to insert.public java.lang.String toString()
toString
in class java.lang.Object
public void onDeserialize(Formatter formatter, java.lang.String absoluteDir)
onDeserialize
in interface Storable
formatter
- the formatter to use to load any storable membersabsoluteDir
- the working directory since all paths stored in the object should be relative
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |