|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.structure.hierarchy.tree.TreeNavigator<T,TN>
T - TreeTN - TreeNodepublic class TreeNavigator<T extends Tree<?,TN>,TN extends TreeNode>
A TreeNavigator allows to navigate on a given Tree. It will store a path to the current TreeNode, so
that it can navigate in a upward direction, too.
The TreeNavigator will use an internal cache to cache the children of the selected TreeNode path. This can be
turned of using #se
Tree,
TreeNode| Nested Class Summary | |
|---|---|
protected static class |
TreeNavigator.LocalAndReducedTraversalControl
Reduced TreeNavigator.TreeNodeVisitor.TraversalControl which affects the local behavior |
protected class |
TreeNavigator.TreeNodePathAndCache
Internal representation of the path of TreeNodes. |
protected class |
TreeNavigator.TreeNodeTraversal<TNV extends TreeNavigator.TreeNodeVisitor<T,TN>>
Includes the logic to traverse TreeNodes |
static interface |
TreeNavigator.TreeNodeVisitor<T extends Tree<?,TN>,TN extends TreeNode>
|
| Field Summary | |
|---|---|
protected boolean |
cachingChildrenOfPathNodes
|
protected boolean |
navigationSuccessful
|
protected T |
tree
|
protected TreeNavigator.TreeNodePathAndCache |
treeNodePathAndCache
Stores the current path through the TreeNodes. |
protected TreeNavigator.TreeNodeTraversal<TreeNavigator.TreeNodeVisitor<T,TN>> |
treeNodeTraversal
|
| Constructor Summary | |
|---|---|
|
TreeNavigator(T tree)
Creates a TreeNavigator on top of the given Tree which starts with the Tree.getTreeRootNode() as
navigation origin. |
|
TreeNavigator(T tree,
boolean cachingChildrenOfPathNodes)
|
protected |
TreeNavigator(T tree,
TreeNavigator.TreeNodePathAndCache treeNodePath,
boolean cachingChildrenOfPathNodes)
|
| Method Summary | |
|---|---|
TreeNavigator<T,TN> |
fork()
Creates a fork instance of the current TreeNavigator. |
TN |
getCurrentTreeNode()
Returns the current TreeNode |
T |
getTree()
|
List<TN> |
getTreeNodePathList()
Returns a new List instance containing the current path of TreeNodes |
boolean |
hasChildren()
Returns true if the current TreeNode.getChildrenList() is not empty |
boolean |
hasNextSibling()
Returns true, if the current TreeNode has a next sibling |
boolean |
hasParent()
Returns true, if the current TreeNode has a parent |
boolean |
hasPreviousSibling()
Returns true, if the current TreeNode has a previous sibling |
boolean |
isCachingChildrenOfPathNodes()
|
boolean |
isNavigationSuccessful()
|
TreeNavigator<T,TN> |
navigateToChildAt(int index)
Tries to navigate to the child of the current TreeNode at the given index position |
TreeNavigator<T,TN> |
navigateToFirstChild()
Navigates to the first child of the current TreeNode |
TreeNavigator<T,TN> |
navigateToLastChild()
Navigates to the last child of the current TreeNode |
TreeNavigator<T,TN> |
navigateToNextSibling()
Tries to navigate to the next TreeNode sibling. |
TreeNavigator<T,TN> |
navigateToNextSibling(int relativeIndexPosition)
Tries to navigate to the next TreeNode sibling with the given relative index position. |
TreeNavigator<T,TN> |
navigateToParent()
Navigates to the parent TreeNode |
TreeNavigator<T,TN> |
navigateToPreviousSibling()
Tries to navigate to the direct previous sibling. |
TreeNavigator<T,TN> |
navigateToPreviousSibling(int relativeIndexPosition)
Navigates to the previous sibling using the given relative index position decrement. |
void |
setCachingChildrenOfPathNodes(boolean cachingChildrenOfPathNodes)
|
String |
toString()
|
TreeNavigator<T,TN> |
traverse(TreeNavigator.TreeNodeVisitor.TraversalConfiguration defaultTraversalConfiguration,
TreeNavigator.TreeNodeVisitor<T,TN>... treeNodeVisitors)
Similar to traverse(TreeNodeVisitor...) but allows to specify a default TreeNavigator.TreeNodeVisitor.TraversalConfiguration. |
TreeNavigator<T,TN> |
traverse(TreeNavigator.TreeNodeVisitor.TraversalConfiguration defaultTraversalConfiguration,
TreeNavigator.TreeNodeVisitor<T,TN> treeNodeVisitor)
Similar to #traverse(TraversalConfiguration, TreeNodeVisitor) |
TreeNavigator<T,TN> |
traverse(TreeNavigator.TreeNodeVisitor<T,TN>... treeNodeVisitors)
Traverses the current TreeNode and its children transitively invoking TreeNavigator.TreeNodeVisitors for each
TreeNode. |
TreeNavigator<T,TN> |
traverse(TreeNavigator.TreeNodeVisitor<T,TN> treeNodeVisitor)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final T extends Tree<?,TN> tree
protected TreeNavigator.TreeNodePathAndCache treeNodePathAndCache
TreeNodes. The last element is the current.
protected boolean navigationSuccessful
protected boolean cachingChildrenOfPathNodes
protected TreeNavigator.TreeNodeTraversal<TreeNavigator.TreeNodeVisitor<T extends Tree<?,TN>,TN extends TreeNode>> treeNodeTraversal
| Constructor Detail |
|---|
public TreeNavigator(T tree)
TreeNavigator on top of the given Tree which starts with the Tree.getTreeRootNode() as
navigation origin.
tree -
IllegalArgumentException - if the Tree reference is nullTreeNavigator,
Tree,
TreeNode
protected TreeNavigator(T tree,
TreeNavigator.TreeNodePathAndCache treeNodePath,
boolean cachingChildrenOfPathNodes)
tree - treeNodePath - cachingChildrenOfPathNodes - TreeNavigator
public TreeNavigator(T tree,
boolean cachingChildrenOfPathNodes)
tree - cachingChildrenOfPathNodes - TreeNavigator| Method Detail |
|---|
public TreeNavigator<T,TN> fork()
TreeNavigator. Any navigation actions to the fork will not affect the current
TreeNavigator instance and vice versa.
public TreeNavigator<T,TN> navigateToFirstChild()
TreeNode
public TreeNavigator<T,TN> navigateToLastChild()
TreeNode
public TreeNavigator<T,TN> navigateToChildAt(int index)
TreeNode at the given index position
index -
public TreeNavigator<T,TN> navigateToNextSibling(int relativeIndexPosition)
TreeNode sibling with the given relative index position. A relative index position of 0
means the current TreeNode, a relative index position of 1 means the direct next one,...
relativeIndexPosition -
isNavigationSuccessful(),
navigateToNextSibling(),
navigateToPreviousSibling(int),
navigateToPreviousSibling()public TreeNavigator<T,TN> navigateToNextSibling()
TreeNode sibling.
isNavigationSuccessful(),
navigateToPreviousSibling(),
navigateToNextSibling(int)public TreeNavigator<T,TN> navigateToPreviousSibling()
isNavigationSuccessful(),
navigateToNextSibling(int),
navigateToPreviousSibling(int)public TreeNavigator<T,TN> navigateToPreviousSibling(int relativeIndexPosition)
TreeNode, a relative index position of 1 means the direct previous TreeNode
relativeIndexPosition -
isNavigationSuccessful(),
navigateToPreviousSibling(),
navigateToNextSibling(),
navigateToNextSibling(int)public boolean hasNextSibling()
TreeNode has a next sibling
public boolean hasPreviousSibling()
TreeNode has a previous sibling
public TreeNavigator<T,TN> navigateToParent()
TreeNode
public boolean hasParent()
TreeNode has a parent
public boolean hasChildren()
TreeNode.getChildrenList() is not empty
public TreeNavigator<T,TN> traverse(TreeNavigator.TreeNodeVisitor<T,TN>... treeNodeVisitors)
TreeNode and its children transitively invoking TreeNavigator.TreeNodeVisitors for each
TreeNode.TreeNavigator.TreeNodeVisitor.TraversalControl.GO_ON is used for the case the TreeNavigator.TreeNodeVisitor returns null.TreeNavigator.TreeNodeVisitor instances are given and they return different TreeNavigator.TreeNodeVisitor.TraversalControl results they are
grouped and a fork() is used for the different groups.TreeNavigator.TreeNodeVisitor.TraversalControl.GO_ON_INCLUDE_ALREADY_TRAVERSED_NODES in combination with
#traverse(TraversalConfiguration, TreeNodeVisitor)
treeNodeVisitors - TreeNavigator.TreeNodeVisitor
#traverse(TraversalConfiguration, TreeNodeVisitor)public TreeNavigator<T,TN> traverse(TreeNavigator.TreeNodeVisitor<T,TN> treeNodeVisitor)
treeNodeVisitor -
traverse(TreeNodeVisitor...)
public TreeNavigator<T,TN> traverse(TreeNavigator.TreeNodeVisitor.TraversalConfiguration defaultTraversalConfiguration,
TreeNavigator.TreeNodeVisitor<T,TN> treeNodeVisitor)
#traverse(TraversalConfiguration, TreeNodeVisitor)
defaultTraversalConfiguration - treeNodeVisitor -
public TreeNavigator<T,TN> traverse(TreeNavigator.TreeNodeVisitor.TraversalConfiguration defaultTraversalConfiguration,
TreeNavigator.TreeNodeVisitor<T,TN>... treeNodeVisitors)
traverse(TreeNodeVisitor...) but allows to specify a default TreeNavigator.TreeNodeVisitor.TraversalConfiguration. TreeNavigator.TreeNodeVisitor.TraversalConfiguration is used initially for all TreeNavigator.TreeNodeVisitor instances. If any
TreeNavigator.TreeNodeVisitor instance returns a TreeNavigator.TreeNodeVisitor.TraversalControl flag, the TreeNavigator.TreeNodeVisitor.TraversalConfiguration of the
particular node is adapted while the other TreeNavigator.TreeNodeVisitor will keep their TreeNavigator.TreeNodeVisitor.TraversalConfiguration. TreeNavigator.TreeNodeVisitor.TraversalConfiguration defines which nodes are traversed.
defaultTraversalConfiguration - TreeNavigator.TreeNodeVisitor.TraversalConfigurationtreeNodeVisitors - TreeNavigator.TreeNodeVisitor
traverse(TreeNodeVisitor...)public boolean isNavigationSuccessful()
public TN getCurrentTreeNode()
TreeNode
public String toString()
toString in class Objectpublic boolean isCachingChildrenOfPathNodes()
public void setCachingChildrenOfPathNodes(boolean cachingChildrenOfPathNodes)
cachingChildrenOfPathNodes - the cachingChildrenOfPathNodes to setpublic T getTree()
public List<TN> getTreeNodePathList()
List instance containing the current path of TreeNodes
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||