Package org.docx4j.model.styles
Class Tree<T>
java.lang.Object
org.docx4j.model.styles.Tree<T>
Represents a Tree of Objects of generic type T. The Tree is represented as
a single rootElement which points to a List<Node> of children. There is
no restriction on the number of children that a particular node may have.
This Tree provides a method to serialize the Tree into a List by doing a
pre-order traversal. It has several methods to allow easy updation of Nodes
in the Tree.
Original code from http://sujitpal.blogspot.com/2006/05/java-data-structure-generic-tree.html
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionQuick access to any node in the tree.Return the root Node of the tree.voidsetRootElement(Node<T> rootElement) Set the root Element for the tree.toList()Returns the Treeas a List of Node objects. toString()Returns a String representation of the Tree.private voidWalks the Tree in pre-order style.
-
Field Details
-
log
private static org.slf4j.Logger log -
rootElement
-
nodes
-
-
Constructor Details
-
Tree
public Tree()
-
-
Method Details
-
get
Quick access to any node in the tree.- Parameters:
styleId-- Returns:
-
getRootElement
Return the root Node of the tree.- Returns:
- the root element.
-
setRootElement
Set the root Element for the tree.- Parameters:
rootElement- the root element to set.
-
toList
Returns the Treeas a List of Node objects. The elements of the List are generated from a pre-order traversal of the tree. - Returns:
- a List<Node
>.
-
toString
Returns a String representation of the Tree. The elements are generated from a pre-order traversal of the Tree. -
walk
Walks the Tree in pre-order style. This is a recursive method, and is called from the toList() method with the root element as the first argument. It appends to the second argument, which is passed by reference as it recurses down the tree.- Parameters:
element- the starting element.list- the output of the walk.
-
climb
-
climb
-