org.sonatype.aether.util.graph
Class PathRecordingDependencyVisitor

java.lang.Object
  extended by org.sonatype.aether.util.graph.PathRecordingDependencyVisitor
All Implemented Interfaces:
DependencyVisitor

public class PathRecordingDependencyVisitor
extends Object
implements DependencyVisitor

A dependency visitor that records all paths leading to nodes matching a certain filter criteria.

Author:
Benjamin Bentmann

Constructor Summary
PathRecordingDependencyVisitor(DependencyFilter filter)
          Creates a new visitor that uses the specified filter to identify terminal nodes of interesting paths.
PathRecordingDependencyVisitor(DependencyFilter filter, boolean excludeChildrenOfMatches)
          Creates a new visitor that uses the specified filter to identify terminal nodes of interesting paths.
 
Method Summary
 DependencyFilter getFilter()
          Gets the filter being used to select terminal nodes.
 List<List<DependencyNode>> getPaths()
          Gets the paths leading to nodes matching the filter that have been recorded during the graph visit.
 boolean visitEnter(DependencyNode node)
          Notifies the visitor of a node visit before its children have been processed.
 boolean visitLeave(DependencyNode node)
          Notifies the visitor of a node visit after its children have been processed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathRecordingDependencyVisitor

public PathRecordingDependencyVisitor(DependencyFilter filter)
Creates a new visitor that uses the specified filter to identify terminal nodes of interesting paths. The visitor will not search for paths going beyond an already matched node.

Parameters:
filter - The filter used to select terminal nodes of paths to record, may be null to match any node.

PathRecordingDependencyVisitor

public PathRecordingDependencyVisitor(DependencyFilter filter,
                                      boolean excludeChildrenOfMatches)
Creates a new visitor that uses the specified filter to identify terminal nodes of interesting paths.

Parameters:
filter - The filter used to select terminal nodes of paths to record, may be null to match any node.
excludeChildrenOfMatches - Flag controlling whether children of matched nodes should be excluded from the traversal, thereby ignoring any potential paths to other matching nodes beneath a matching ancestor node. If true, all recorded paths will have only one matching node (namely the terminal node), if false a recorded path can consist of multiple matching nodes.
Method Detail

getFilter

public DependencyFilter getFilter()
Gets the filter being used to select terminal nodes.

Returns:
The filter being used or null if none.

getPaths

public List<List<DependencyNode>> getPaths()
Gets the paths leading to nodes matching the filter that have been recorded during the graph visit. A path is given as a sequence of nodes, starting with the root node of the graph and ending with the node that matched the filter.

Returns:
The recorded paths, never null.

visitEnter

public boolean visitEnter(DependencyNode node)
Description copied from interface: DependencyVisitor
Notifies the visitor of a node visit before its children have been processed.

Specified by:
visitEnter in interface DependencyVisitor
Parameters:
node - The dependency node being visited, must not be null.
Returns:
true to visit child nodes of the specified node as well, false to skip children.

visitLeave

public boolean visitLeave(DependencyNode node)
Description copied from interface: DependencyVisitor
Notifies the visitor of a node visit after its children have been processed. Note that this method is always invoked regardless whether any children have actually been visited.

Specified by:
visitLeave in interface DependencyVisitor
Parameters:
node - The dependency node being visited, must not be null.
Returns:
true to visit siblings nodes of the specified node as well, false to skip siblings.


Copyright © 2010-2012. All Rights Reserved.