public class SimpleTree<T extends Tree> extends Object implements Tree<T>, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected String |
name
Unique name of this element
|
protected String |
parentName
parent.name (or null if root element)
|
protected Map<String,T> |
treeElements
map of tree elements (ordered)
|
| Constructor and Description |
|---|
SimpleTree(String name,
T parent)
Construct a new Tree
|
| Modifier and Type | Method and Description |
|---|---|
T |
get(String name)
Retrieve a subtree by name.
|
List<T> |
getAllChildren()
Get the children, and their children, etc.
|
List<T> |
getAllChildren(boolean includeSelf)
sort in order of dependency
|
T |
getChild(String name)
Get a subtree by name.
|
Vector<T> |
getChildren()
Get the children of this element.
|
String |
getName()
Retrieve the unique name of this tree element.
|
T |
getParent()
Retrieve the parent node of current element.
|
String |
getPath(String separator)
Translate the path of this subtree as a separated string.
|
T |
getRoot()
Get the root element of this tree.
|
String |
getStringValue() |
Map<String,T> |
getTreeElements()
Retrieve all tree elements as map.
|
Object |
getValue()
Retrieve the value of this node/leaf
|
boolean |
hasChildren()
Retrieve wether this Tree has children
|
boolean |
hasParent()
Retrieve wether this Tree has a parent
|
void |
remove() |
void |
setName(String name) |
void |
setName(String name,
String url) |
void |
setParent(T parent)
Set the parent of current element (and move the children accordingly).
|
void |
setValue(Object value)
Set the value of this node/leaf
|
String |
toString()
Print the tree.
|
String |
toString(boolean includeSubTree) |
String |
toString(boolean includeSubTree,
int level)
Pretty print the (sub)tree, but only a certain levels
|
protected String name
protected String parentName
public String getName()
Treepublic void setName(String name)
public final T getParent()
Treepublic void setParent(T parent)
Treepublic T getRoot()
Treepublic final List<T> getAllChildren()
TreegetAllChildren in interface Tree<T extends Tree>public final List<T> getAllChildren(boolean includeSelf)
getAllChildren in interface Tree<T extends Tree>public Vector<T> getChildren()
TreegetChildren in interface Tree<T extends Tree>public T getChild(String name)
Treepublic String toString(boolean includeSubTree)
public String toString(boolean includeSubTree, int level)
Treepublic Object getValue()
Treepublic void setValue(Object value)
Treepublic Map<String,T> getTreeElements()
TreegetTreeElements in interface Tree<T extends Tree>public boolean hasChildren()
TreehasChildren in interface Tree<T extends Tree>public boolean hasParent()
Treepublic String getStringValue()
public String getPath(String separator)
Treepublic void remove()
Copyright © 2015. All Rights Reserved.