See: Description
Interface | Description |
---|---|
NavuTraversalMean | |
TraversalFilter |
Class | Description |
---|---|
NavuTraversalBfsMean |
This implements the
NavuTraversalMean for BFS
(Breath-first traversal). |
NavuTraversalDfsMean |
This implements the
NavuTraversalMean for DFS
(Depth-first traversal). |
NavuTreeTraversal |
Starting point for both Active and Passive mode traversal
|
Utility package for traversing the NAVU tree using NAVU API. The configuration tree means all existing keypaths that exists will be processed.
There is the ability to retrieve all the NavuNode
s that
exists both in CDB and trough external data.
There are two ways that one could use the Traversal API:
Passive traversal: Which means that one implements the method
TraversalFilter.currentNode(
com.tailf.navu.NavuNode)
and
register it in
NavuTreeTraversal.addFilter(
com.tailf.navu.traversal.TraversalFilter)
.
When all the filter has been registered the
traversal process needs to be started, which is done through
NavuTreeTraversal.traverse()
the
"filters" gets invoked for each node the traversal process encounters.
Active traversal:
This is the mode in which user could actively
retrieves a node through a iterator and the user has full control
when the next NavuNode
could be retrieved.
The following example shows a passive traversal (Breadth-first traversal)
NavuContext ctx = new NavuContext(maapi,th); NavuTreeTraversal traversalProcess = NavuTreeTraversal .createInstance(ctx,new NavuTraversalBfsMean()); traversalProcess.addFilter(new TraversalFilte(){ public void currentNode(NavuNode node) throws NavuException{ //process the current node } } traversalProcess.traverse();The following example shows a passive traversal (Depth-first traversal)
NavuContext ctx = new NavuContext(maapi,th); NavuTreeTraversal traversalProcess = NavuTreeTraversal .createInstance(ctx,new NavuTraversalDfsMean()); traversalProcess.addFilter(new TraversalFilter(){ public void currentNode(NavuNode node) throws NavuException{ //process the current node } } traversalProcess.traverse();The following example shows a active traversal
NavuContext ctx = new NavuContext(maapi,th); Iterator<NavuNode> it = NavuTreeTraversal.iterator(ctx); while(it.hasNext()){ NavuNode currentNode = it.next(); //Process the node }