org.progeeks.bcel
Class ClassDependencyGraph

java.lang.Object
  extended by com.phoenixst.plexus.DefaultGraph
      extended by org.progeeks.graph.EdgeIdentityGraph
          extended by org.progeeks.bcel.ClassDependencyGraph
All Implemented Interfaces:
com.phoenixst.plexus.Graph, com.phoenixst.plexus.ObservableGraph, java.io.Serializable

public class ClassDependencyGraph
extends EdgeIdentityGraph

A graph that uses BCEL examination of classes to determine dependencies.

Version:
$Revision: 1.18 $
Author:
Paul Speed
See Also:
Serialized Form

Nested Class Summary
static class ClassDependencyGraph.DependencyInfo
           
static class ClassDependencyGraph.Package
           
 
Nested classes/interfaces inherited from interface com.phoenixst.plexus.Graph
com.phoenixst.plexus.Graph.Edge
 
Field Summary
static java.lang.String EDGE_DEPENDENCY
           
static java.lang.String EDGE_LOCATION
           
static java.lang.String EDGE_PACKAGE
           
static java.lang.String LOCATION_CLASSPATH
           
static java.lang.String LOCATION_ROOT
           
static ClassDependencyGraph.Package PACKAGE_ROOT
           
 
Constructor Summary
ClassDependencyGraph()
           
 
Method Summary
 java.lang.Object addClass(java.io.File f, java.lang.Object location)
          Adds a class specified by .class file to the graph.
 java.lang.Object addClass(java.io.InputStream in, java.lang.String name, java.lang.Object location)
          Adds a class by reading it from the specified input stream.
 java.lang.Object addClass(org.apache.bcel.classfile.JavaClass jc, java.lang.Object location)
          Adds an already loaded JavaClass to the graph.
 java.lang.Object addClass(java.lang.String cname)
          Adds a class by fully qualified name, loaded from the current classpath.
 void addDirectory(java.io.File dir, boolean recurse)
          Adds all of the .class and .jar files in the specified directory to the graph.
 void addDirectory(java.io.File dir, boolean recurse, ProgressReporter pr)
          Adds all of the .class and .jar files in the specified directory to the graph.
 void addDirectory(java.io.File dir, java.io.File root, boolean recurse)
           
 java.lang.Object addJar(java.io.File jar)
          Adds all of the .class files in the specified jar to the graph.
 java.lang.Object addJar(java.io.File jar, java.lang.Object location)
           
 boolean addNode(java.lang.Object node)
           
 void addPackage(ClassDependencyGraph.Package pkg)
          Adds a package to the graph... splitting into multiple nodes as needed.
 void addPremappedClasses(java.util.Map classes)
          Sets a set of preloaded classes keyed by name.
 java.util.Map getPremappedClasses()
          Returns the map containing any name-mapped JavaClass objects that were provided prior to or discovered during analyis.
protected  void linkDependencies(org.apache.bcel.classfile.JavaClass jc)
           
static void main(java.lang.String[] args)
           
 
Methods inherited from class org.progeeks.graph.EdgeIdentityGraph
createEdge
 
Methods inherited from class com.phoenixst.plexus.DefaultGraph
addEdge, addEdge, addGraphListener, adjacentNodes, containsEdge, containsNode, degree, degree, edgeAdded, edgeAdding, edgeRemoved, edgeRemoving, edges, equals, getAdjacentNode, getEdge, getIncidentEdge, getNode, hashCode, incidentEdges, nodeAdded, nodeAdding, nodeRemoved, nodeRemoving, nodes, removeEdge, removeGraphListener, removeNode, toString, traverser
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EDGE_LOCATION

public static java.lang.String EDGE_LOCATION

EDGE_DEPENDENCY

public static java.lang.String EDGE_DEPENDENCY

EDGE_PACKAGE

public static java.lang.String EDGE_PACKAGE

LOCATION_ROOT

public static java.lang.String LOCATION_ROOT

PACKAGE_ROOT

public static ClassDependencyGraph.Package PACKAGE_ROOT

LOCATION_CLASSPATH

public static java.lang.String LOCATION_CLASSPATH
Constructor Detail

ClassDependencyGraph

public ClassDependencyGraph()
Method Detail

addPremappedClasses

public void addPremappedClasses(java.util.Map classes)
Sets a set of preloaded classes keyed by name. The key is the fully qualified class name and the value is the JavaClass object for the class.


getPremappedClasses

public java.util.Map getPremappedClasses()
Returns the map containing any name-mapped JavaClass objects that were provided prior to or discovered during analyis.


addDirectory

public void addDirectory(java.io.File dir,
                         boolean recurse)
                  throws java.io.IOException
Adds all of the .class and .jar files in the specified directory to the graph.

Throws:
java.io.IOException

addDirectory

public void addDirectory(java.io.File dir,
                         boolean recurse,
                         ProgressReporter pr)
                  throws java.io.IOException
Adds all of the .class and .jar files in the specified directory to the graph. Reports any progress to the specified progress reporter.

Throws:
java.io.IOException

addDirectory

public void addDirectory(java.io.File dir,
                         java.io.File root,
                         boolean recurse)
                  throws java.io.IOException
Throws:
java.io.IOException

addJar

public java.lang.Object addJar(java.io.File jar)
                        throws java.io.IOException
Adds all of the .class files in the specified jar to the graph. Returns the location node associated with the jar file.

Throws:
java.io.IOException

addJar

public java.lang.Object addJar(java.io.File jar,
                               java.lang.Object location)
                        throws java.io.IOException
Throws:
java.io.IOException

addClass

public java.lang.Object addClass(java.io.File f,
                                 java.lang.Object location)
                          throws java.io.IOException
Adds a class specified by .class file to the graph. Returns the created node.

Throws:
java.io.IOException

addClass

public java.lang.Object addClass(java.io.InputStream in,
                                 java.lang.String name,
                                 java.lang.Object location)
                          throws java.io.IOException
Adds a class by reading it from the specified input stream. Returns the created node.

Throws:
java.io.IOException

addClass

public java.lang.Object addClass(java.lang.String cname)
Adds a class by fully qualified name, loaded from the current classpath. Returns the node that was actually added to the graph.


addPackage

public void addPackage(ClassDependencyGraph.Package pkg)
Adds a package to the graph... splitting into multiple nodes as needed.


addClass

public java.lang.Object addClass(org.apache.bcel.classfile.JavaClass jc,
                                 java.lang.Object location)
Adds an already loaded JavaClass to the graph. Returns the node that was actually added to the graph.


addNode

public boolean addNode(java.lang.Object node)
Specified by:
addNode in interface com.phoenixst.plexus.Graph
Overrides:
addNode in class com.phoenixst.plexus.DefaultGraph

linkDependencies

protected void linkDependencies(org.apache.bcel.classfile.JavaClass jc)

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2002-2003 Paul Speed. All Rights Reserved.