Fields Summary |
---|
public static final int | MAX_LOOPSMaximum number of loops for looking for indirect dependencies. |
private org.apache.tools.ant.types.Path | sourcePathThe source path for the source files |
private org.apache.tools.ant.types.Path | classPathThe classpath containg dirs and jars of class files |
private Vector | rootClassesThe list of root classes |
private boolean | determinedtrue if dependencies have been determined |
private Vector | fileDependenciesthe list of File objects that the root classes depend upon |
private Vector | classDependenciesthe list of java classes the root classes depend upon |
private boolean | closuretrue if indirect dependencies should be gathered |
Methods Summary |
---|
public void | addClassPath(org.apache.tools.ant.types.Path classPath)Add a classpath to the classpath being used by the analyzer. The
classpath contains the binary classfiles for the classes being
analyzed The elements may either be the directories or jar files.Not
all analyzers will use this information.
if (classPath == null) {
return;
}
this.classPath.append(classPath);
this.classPath.setProject(classPath.getProject());
|
public void | addRootClass(java.lang.String className)Add a root class. The root classes are used to drive the
determination of dependency information. The analyzer will start at
the root classes and add dependencies from there.
if (className == null) {
return;
}
if (!rootClasses.contains(className)) {
rootClasses.addElement(className);
}
|
public void | addSourcePath(org.apache.tools.ant.types.Path sourcePath)Add a source path to the source path used by this analyzer. The
elements in the given path contain the source files for the classes
being analyzed. Not all analyzers will use this information.
if (sourcePath == null) {
return;
}
this.sourcePath.append(sourcePath);
this.sourcePath.setProject(sourcePath.getProject());
|
public void | config(java.lang.String name, java.lang.Object info)Configure an aspect of the analyzer. The set of aspects that are
supported is specific to each analyzer instance.
// do nothing by default
|
protected abstract void | determineDependencies(java.util.Vector files, java.util.Vector classes)Determine the dependencies of the current set of root classes
|
public java.io.File | getClassContainer(java.lang.String classname)Get the file that contains the class definition
String classLocation = classname.replace('.", '/") + ".class";
// we look through the classpath elements. If the element is a dir
// we look for the file. IF it is a zip, we look for the zip entry
return getResourceContainer(classLocation, classPath.list());
|
public java.util.Enumeration | getClassDependencies()Get the list of classes upon which root classes depend. This is a
list of Java classnames in dot notation.
if (!determined) {
determineDependencies(fileDependencies, classDependencies);
}
return classDependencies.elements();
|
public java.util.Enumeration | getFileDependencies()Get the list of files in the file system upon which the root classes
depend. The files will be either the classfiles or jar files upon
which the root classes depend.
if (!supportsFileDependencies()) {
throw new RuntimeException("File dependencies are not supported "
+ "by this analyzer");
}
if (!determined) {
determineDependencies(fileDependencies, classDependencies);
}
return fileDependencies.elements();
|
private java.io.File | getResourceContainer(java.lang.String resourceLocation, java.lang.String[] paths)Get the file that contains the resource
for (int i = 0; i < paths.length; ++i) {
File element = new File(paths[i]);
if (!element.exists()) {
continue;
}
if (element.isDirectory()) {
File resource = new File(element, resourceLocation);
if (resource.exists()) {
return resource;
}
} else {
// must be a zip of some sort
ZipFile zipFile = null;
try {
zipFile = new ZipFile(element);
if (zipFile.getEntry(resourceLocation) != null) {
return element;
}
} finally {
if (zipFile != null) {
zipFile.close();
}
}
}
}
return null;
|
protected java.util.Enumeration | getRootClasses()Get an enumeration of the root classes
return rootClasses.elements();
|
public java.io.File | getSourceContainer(java.lang.String classname)Get the file that contains the class source.
String sourceLocation = classname.replace('.", '/") + ".java";
// we look through the source path elements. If the element is a dir
// we look for the file. If it is a zip, we look for the zip entry.
// This isn't normal for source paths but we get it for free
return getResourceContainer(sourceLocation, sourcePath.list());
|
protected boolean | isClosureRequired()Indicate if the analyzer is required to follow
indirect class relationships.
return closure;
|
public void | reset()Reset the dependency list. This will reset the determined
dependencies and the also list of root classes.
rootClasses.removeAllElements();
determined = false;
fileDependencies = new Vector();
classDependencies = new Vector();
|
public void | setClosure(boolean closure)Set the closure flag. If this flag is true the analyzer will traverse
all class relationships until it has collected the entire set of
direct and indirect dependencies
this.closure = closure;
|
protected abstract boolean | supportsFileDependencies()Indicate if the particular subclass supports file dependency
information.
|