|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.util.TreeNode
public class TreeNode
Tree Node
Nested Class Summary | |
---|---|
static interface |
TreeNode.TreeNodeHandler
|
Field Summary | |
---|---|
static java.lang.String |
JSON_Key_children
|
static java.lang.String |
JSON_Key_description
|
static java.lang.String |
JSON_Key_name
|
static java.lang.String |
SLASH_SEPARATOR
|
static char |
SLASH_SEPARATOR_CHAR
|
Constructor Summary | |
---|---|
TreeNode()
Constructor |
|
TreeNode(java.lang.String name)
Constructor |
|
TreeNode(java.lang.String name,
java.util.List<TreeNode> children)
Constructor |
Method Summary | ||
---|---|---|
protected JSON._Object |
_setJsonNodeValues(JSON._Object jsonObj,
java.lang.String name,
java.lang.String desc,
JSON._Array children)
Overridable method for setting node JSON values |
|
TreeNode |
addChild(TreeNode node)
Adds the specified TreeNode as a child to this node |
|
void |
addChildren(java.util.List<TreeNode> children)
Adds all children in the specified java.util.List |
|
static TreeNode |
createTreePath(TreeNode parent,
java.lang.String[] name)
Create named TreeNodes under specified parent |
|
static TreeNode |
createTreePath(TreeNode parent,
java.lang.String[] name,
java.lang.Class<? extends TreeNode> treeNodeClass)
Create named TreeNodes under specified parent |
|
boolean |
equals(java.lang.Object other)
Returns true if the 'other' node is the same as 'this' node |
|
TreeNode |
findChildByName(java.lang.String name)
Return first node with matching name |
|
TreeNode |
findChildByProperty(java.lang.String key,
java.lang.Object value)
Return first node with matching property key |
|
static java.util.List<java.lang.String> |
flattenTree(java.util.List<java.lang.String> list,
java.lang.String prefix,
char sep,
TreeNode parent)
Flattens the specified tree |
|
TreeNode |
getChildAt(int ndx)
Finds/Returns the named child Does not check grandchildren. |
|
TreeNode |
getChildByName(java.lang.String name)
Finds/Returns the named child Does not check grandchildren. |
|
TreeNode |
getChildByPath(java.lang.String[] name)
Finds/Returns the named child Does not check grandchildren. |
|
TreeNode |
getChildByValue(java.lang.Object val)
Finds/Returns the child matching the specified value Does not check grandchildren. |
|
java.util.List<TreeNode> |
getChildren()
Returns the collection of children nodes |
|
java.lang.String |
getDescription()
Gets the description of this TreeNode |
|
JSON._Array |
getJsonChildrenArray()
Returns a JSON array of this nodes children (or null if there are no children) |
|
JSON._Object |
getJsonObject()
Returns a JSON object for this TreeNode |
|
int |
getLevel()
Calculates/Returns the level of this node (root node is level '0') |
|
int |
getLevel(TreeNode parent)
Calculates/Returns the level of this node (root node is level '0') |
|
java.lang.String |
getName()
Gets the name of this TreeNode |
|
TreeNode |
getNextSibling()
Return the 'next' sibling node of this node |
|
java.lang.Object |
getObject()
Gets the node leaf object |
|
protected TreeNode |
getParent()
Gets the parent of this TreeNode |
|
TreeNode[] |
getPath()
Returns the path of this TreeNode |
|
TreeNode[] |
getPath(TreeNode parent)
Returns the path of this TreeNode |
|
java.lang.String |
getPathDescription(java.lang.String sep)
Returns the path name of this TreeNode |
|
java.lang.String |
getPathDescription(TreeNode parent,
java.lang.String sep)
Returns the path name of this TreeNode |
|
java.lang.String[] |
getPathDescriptions()
Returns the path name of this TreeNode |
|
java.lang.String[] |
getPathDescriptions(TreeNode parent)
Returns the path name of this TreeNode |
|
java.lang.String |
getPathName(java.lang.String sep)
Returns the path name of this TreeNode |
|
java.lang.String |
getPathName(TreeNode parent,
java.lang.String sep)
Returns the path name of this TreeNode |
|
java.lang.String[] |
getPathNames()
Returns the path name of this TreeNode |
|
java.lang.String[] |
getPathNames(TreeNode parent)
Returns the path name of this TreeNode |
|
TreeNode |
getPreviousSibling()
Return the 'previous' sibling node of this node |
|
RTProperties |
getProperties()
Get node properties |
|
java.lang.Object |
getProperty(java.lang.String key)
Gets the specified node property value |
|
java.lang.Object |
getProperty(java.lang.String key,
java.lang.Object dft)
Gets the specified node property value |
|
static TreeNode |
getTreePath(TreeNode parent,
java.lang.String[] name)
Gets/Returns named TreeNodes under specified parent |
|
int |
getType()
Gets the type of this TreeNode |
|
boolean |
hasChildren()
Returns true if this node has children |
|
boolean |
hasNextSibling()
Return true if this node has a 'next' sibling |
|
boolean |
hasObject()
Returns true if this node has an object value |
|
boolean |
hasParent()
Returns true if this TreeNode has a parent |
|
boolean |
hasPreviousSibling()
Return true if this node has a 'previous' sibling |
|
boolean |
hasProperties()
Returns true if properties have been defined for this node |
|
boolean |
hasProperty(java.lang.String key)
Returns true if the specified property key is defined in this node |
|
boolean |
isAncestor(TreeNode node)
Returns true if the specified node is the same as this node, or is an ancestor |
|
boolean |
isLeaf()
Returns true if this node has an object value |
|
boolean |
isOffspring(TreeNode node)
Returns true if the specified node is an offspring of this node |
|
boolean |
isRootNode()
Returns true if this node does not have a parent |
|
static void |
main(java.lang.String[] argv)
|
|
void |
printChildren()
Prints the children nodes |
|
void |
printChildren(int lvl)
Prints the children nodes |
|
static
|
printTree(TN parent)
Prints the specified Tree |
|
boolean |
removeChild(TreeNode tn)
Remove the specified child |
|
boolean |
removeFromParent()
Remove this node from it's parent |
|
void |
setDescription(java.lang.String desc)
Sets the description of this TreeNode |
|
void |
setName(java.lang.String name)
Sets the name of this TreeNode |
|
void |
setObject(java.lang.Object val)
Sets a node leaf object |
|
protected void |
setParent(TreeNode node)
Sets the parent of this TreeNode |
|
void |
setProperty(java.lang.String key,
java.lang.Object val)
Sets the specified node property value |
|
void |
setType(int type)
Sets the type of this TreeNode (usage defined by caller) |
|
int |
size()
Returns number of children in this node |
|
java.lang.String |
toString()
Gets the String representation of this TreeNode |
|
java.lang.String |
toString(java.lang.String sep)
Gets the String representation of this TreeNode |
|
TreeNode |
traverseTree(TreeNode.TreeNodeHandler tnh)
Prefix traversal of TreeNodes |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SLASH_SEPARATOR
public static final char SLASH_SEPARATOR_CHAR
public static final java.lang.String JSON_Key_name
public static final java.lang.String JSON_Key_description
public static final java.lang.String JSON_Key_children
Constructor Detail |
---|
public TreeNode()
public TreeNode(java.lang.String name)
public TreeNode(java.lang.String name, java.util.List<TreeNode> children)
Method Detail |
---|
public static TreeNode createTreePath(TreeNode parent, java.lang.String[] name)
public static TreeNode createTreePath(TreeNode parent, java.lang.String[] name, java.lang.Class<? extends TreeNode> treeNodeClass)
public static TreeNode getTreePath(TreeNode parent, java.lang.String[] name)
public static java.util.List<java.lang.String> flattenTree(java.util.List<java.lang.String> list, java.lang.String prefix, char sep, TreeNode parent)
public static <TN extends TreeNode> void printTree(TN parent)
public void setName(java.lang.String name)
public java.lang.String getName()
public void setType(int type)
public int getType()
public void setDescription(java.lang.String desc)
public java.lang.String getDescription()
public java.util.List<TreeNode> getChildren()
public boolean hasChildren()
public int size()
public void addChildren(java.util.List<TreeNode> children)
public TreeNode addChild(TreeNode node)
public TreeNode getChildAt(int ndx)
public TreeNode getChildByName(java.lang.String name)
public TreeNode getChildByPath(java.lang.String[] name)
public TreeNode getChildByValue(java.lang.Object val)
public boolean removeChild(TreeNode tn)
public boolean removeFromParent()
public boolean hasNextSibling()
public TreeNode getNextSibling()
public boolean hasPreviousSibling()
public TreeNode getPreviousSibling()
protected void setParent(TreeNode node)
protected TreeNode getParent()
public boolean hasParent()
public boolean isRootNode()
public boolean isAncestor(TreeNode node)
public boolean isOffspring(TreeNode node)
public int getLevel()
public int getLevel(TreeNode parent)
public TreeNode[] getPath()
public TreeNode[] getPath(TreeNode parent)
public java.lang.String[] getPathNames()
public java.lang.String[] getPathNames(TreeNode parent)
public java.lang.String getPathName(java.lang.String sep)
public java.lang.String getPathName(TreeNode parent, java.lang.String sep)
public java.lang.String[] getPathDescriptions()
public java.lang.String[] getPathDescriptions(TreeNode parent)
public java.lang.String getPathDescription(java.lang.String sep)
public java.lang.String getPathDescription(TreeNode parent, java.lang.String sep)
public TreeNode traverseTree(TreeNode.TreeNodeHandler tnh)
public TreeNode findChildByName(java.lang.String name)
public TreeNode findChildByProperty(java.lang.String key, java.lang.Object value)
public JSON._Array getJsonChildrenArray()
public JSON._Object getJsonObject()
protected JSON._Object _setJsonNodeValues(JSON._Object jsonObj, java.lang.String name, java.lang.String desc, JSON._Array children)
jsonObj
- The JSON object for this not (never null)name
- The default node namedesc
- The default node descriptionchildren
- A JSON array of children JSON nodes (may be null)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String sep)
public void printChildren()
public void printChildren(int lvl)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public RTProperties getProperties()
public boolean hasProperties()
public boolean hasProperty(java.lang.String key)
key
- The property key
public java.lang.Object getProperty(java.lang.String key, java.lang.Object dft)
key
- The property keydft
- The default return value
public java.lang.Object getProperty(java.lang.String key)
key
- The property key
public void setProperty(java.lang.String key, java.lang.Object val)
key
- The property keyval
- The property valuepublic void setObject(java.lang.Object val)
public java.lang.Object getObject()
public boolean hasObject()
public boolean isLeaf()
public static void main(java.lang.String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |