Package com.appiancorp.suiteapi.common
Class Tree
java.lang.Object
com.appiancorp.suiteapi.common.TreeNode
com.appiancorp.suiteapi.common.Tree
- All Implemented Interfaces:
Serializable
Collection of objects such that each object has data and potentially
references to other
The data of each node is the set of properties inherited from
Tree
s, subject to the following
restrictions:
- Each tree has exactly one root.
- The root of the tree has no parent; all other nodes have exactly one parent.
- Each node may have an unbounded number of child nodes, possibly zero.
- The child nodes are themselves the roots of sub-trees.
The data of each node is the set of properties inherited from
TreeNode
.- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionTree[]
Get the children of this node.void
populateTree
(Object[] data_) Convenience method to populate the node data of nodes in this tree.Object[]
Convenience method to obtain a flat represention of the data in the tree.Integer[]
Convenience method to obtain a flat represention of the depths of the nodes in the tree.Long[]
Convenience method to obtain a flat represention of the tree.String[]
Convenience method to obtain a flat represention of the names of the tree nodes.void
setChildren
(Tree[] children_) Set the children of this node.
-
Field Details
-
SORT_BY_NODE_ID
A constant for sorting trees by the ID of the nodes -
SORT_BY_NAME
A constant for sorting trees by the name of the nodes -
SORT_BY_DATA
A constant for sorting tress by data field of the nodes
-
-
Constructor Details
-
Tree
public Tree()
-
-
Method Details
-
getChildren
Get the children of this node.- Returns:
- An array of Tree objects that are the root of children trees.
- See Also:
-
setChildren
Set the children of this node.- Parameters:
children_
- an array of child trees- See Also:
-
retrieveTreeIds
Convenience method to obtain a flat represention of the tree. Uses the same traversal aspopulateTree(java.lang.Object[])
. This order is known as preorder, which means that the root node is visited before any of its children.- Returns:
- the ids of the nodes in the tree in a one-dimensional array.
-
retrieveTreeData
Convenience method to obtain a flat represention of the data in the tree. Uses the same traversal aspopulateTree(java.lang.Object[])
. This order is known as preorder, which means that the root node is visited before any of its children.- Returns:
- The data in the nodes in the tree in a one-dimensional array.
-
retrieveTreeNames
Convenience method to obtain a flat represention of the names of the tree nodes. Uses the same traversal aspopulateTree(java.lang.Object[])
. This order is known as preorder, which means that the root node is visited before any of its children.- Returns:
- The names of the nodes in the tree in a one-dimensional array.
-
retrieveTreeDepths
Convenience method to obtain a flat represention of the depths of the nodes in the tree. The depth of the top-level node is 0, the depth of its direct descendants is 1, and so on. Uses the same traversal aspopulateTree(java.lang.Object[])
. This order is known as preorder, which means that the root node is visited before any of its children.- Returns:
- The depths of the nodes in the tree in a one-dimensional array.
-
populateTree
Convenience method to populate the node data of nodes in this tree. Uses the same traversal asretrieveTreeIds()
. This order is known as preorder, which means that the root node is visited before any of its children.- Parameters:
data_
- A one-dimensional array of data to use to populate tree.
-