org.sonatype.aether.util.graph
Class PreorderNodeListGenerator

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

public class PreorderNodeListGenerator
extends Object
implements DependencyVisitor

Generates a sequence of dependency nodes from a dependeny graph by traversing the graph in preorder. This visitor visits each node exactly once regardless how many paths within the dependency graph lead to the node such that the resulting node sequence is free of duplicates.

Author:
Benjamin Bentmann

Constructor Summary
PreorderNodeListGenerator()
          Creates a new list generator.
 
Method Summary
 List<Artifact> getArtifacts(boolean includeUnresolved)
          Gets the artifacts associated with the list of dependency nodes generated during the graph traversal.
 String getClassPath()
          Gets a class path by concatenating the artifact files of the visited dependency nodes.
 List<Dependency> getDependencies(boolean includeUnresolved)
          Gets the dependencies seen during the graph traversal.
 List<File> getFiles()
          Gets the files of resolved artifacts seen during the graph traversal.
 List<DependencyNode> getNodes()
          Gets the list of dependency nodes that was generated during the graph traversal.
 boolean visitEnter(DependencyNode node)
           
 boolean visitLeave(DependencyNode node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreorderNodeListGenerator

public PreorderNodeListGenerator()
Creates a new list generator.

Method Detail

getNodes

public List<DependencyNode> getNodes()
Gets the list of dependency nodes that was generated during the graph traversal.

Returns:
The list of dependency nodes in preorder, never null.

getDependencies

public List<Dependency> getDependencies(boolean includeUnresolved)
Gets the dependencies seen during the graph traversal.

Parameters:
includeUnresolved - Whether unresolved dependencies shall be included in the result or not.
Returns:
The list of dependencies in preorder, never null.

getArtifacts

public List<Artifact> getArtifacts(boolean includeUnresolved)
Gets the artifacts associated with the list of dependency nodes generated during the graph traversal.

Parameters:
includeUnresolved - Whether unresolved artifacts shall be included in the result or not.
Returns:
The list of artifacts in preorder, never null.

getFiles

public List<File> getFiles()
Gets the files of resolved artifacts seen during the graph traversal.

Returns:
The list of artifact files in preorder, never null.

getClassPath

public String getClassPath()
Gets a class path by concatenating the artifact files of the visited dependency nodes. Nodes with unresolved artifacts are automatically skipped.

Returns:
The class path, using the platform-specific path separator, never null.

visitEnter

public boolean visitEnter(DependencyNode node)
Specified by:
visitEnter in interface DependencyVisitor

visitLeave

public boolean visitLeave(DependencyNode node)
Specified by:
visitLeave in interface DependencyVisitor


Copyright © 2010-2011 Sonatype, Inc.. All Rights Reserved.