Skip navigation links

Package com.tailf.navu.traversal

Utility package for traversing the NAVU tree (or a subset thereof) using the NAVU API.

See: Description

Package com.tailf.navu.traversal Description

Utility package for traversing the NAVU tree (or a subset thereof) using the NAVU API.

Using this package it is possible to retrieve all the NavuNodes that exist in CDB as well as those available through external data providers.

There are two ways that one could use the Traversal API:

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 TraversalFilter() {
      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 an active traversal
 
  NavuContext ctx = new NavuContext(maapi, th);
  Iterator<NavuNode> it = NavuTreeTraversal.iterator(ctx);
  while(it.hasNext()) {
      NavuNode currentNode = it.next();
      // Process the node
  }
 
 

Skip navigation links