|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jini.tool.classdepend.ClassDepend
public class ClassDepend
Provides a utility for computing which classes are depended on by a set of classes. This class is not thread safe.
Field Summary | |
---|---|
private ClassLoader |
loader
The class loader used to load classes being checked for dependencies. |
private PackageClasses |
packageClasses
Used to compute the classes available in the classpath for a package. |
private ClassLoader |
platformLoader
The class loader for classes that should be excluded because they are considered part of the platform. |
private boolean |
printClassesWithFileSeparator
|
private static String |
systemClasspath
The system classpath. |
Constructor Summary | |
---|---|
ClassDepend(String classpath,
String platform)
Creates an instance of this class. |
Method Summary | |
---|---|
private boolean |
classPresent(String name,
ClassLoader loader)
Checks if the class is present in the given loader. |
private Set |
computeClasses(Collection names)
Returns the classes in the classpath that match the specified names by expanding package wildcards. |
Pattern |
createPattern(Collection names)
Creates a pattern that matches class names for any of the names in the argument. |
Set |
filterClassDependencyRelationShipMap(Map dependencyRelationShipMap,
ClassDependParameters cdp)
This method applies optional filters to provide methods to support the original API of ClassDep. |
private URL[] |
getClasspathURLs(String classpath)
Returns the URLs associated with a classpath. |
Map |
getDependencyRelationshipMap(Collection rootClasses,
boolean recurse)
This method builds the entire DependencyRelationShipMap that can be used to analyse class dependencies. |
private String |
getResourceName(String classname)
Returns the name of the resource associated with a class name. |
static void |
main(String[] args)
|
boolean |
matches(String string,
Pattern pattern)
Checks if the string matches the pattern, returning false if the pattern is null. |
static ClassDepend |
newInstance(String classpath,
String platform,
boolean warn)
Public Factory method for creating a new instance of ClassDepend. |
protected void |
noteClassLoadingFailed(String name,
IOException e)
Called when attempts to load the bytecodes for the specified class fail. |
protected void |
noteClassNotFound(String name)
Called when the specified class is not found. |
boolean |
printClassesWithFileSeparator()
|
private String |
quote(String s)
Returns a literal pattern String for the specified String. |
void |
setPrintClassesWithFileSeparator(boolean printClassesWithFileSeparator)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String systemClasspath
private final ClassLoader loader
private final ClassLoader platformLoader
private final PackageClasses packageClasses
private volatile boolean printClassesWithFileSeparator
Constructor Detail |
---|
ClassDepend(String classpath, String platform) throws MalformedURLException, IOException
classpath
argument
specifies the classpath that will be used to look up the class bytecode
for classes whose dependencies are being computed. If the value
specified is null
, then the system class loader will be
used. Otherwise, a URLClassLoader
will be constructed using the
URLs specified by classpath
and with a parent class loader
that is the parent of the system class loader. The
platform
argument specifies the classpath that will be used
to find classes that should be considered part of the platform and
should be excluded from consideration when computing dependencies. If
the value specified is null
, then the parent of the system
class loader will be used. Otherwise, a URLClassLoader
will be constructed using the URLs specified by platform
and with a parent class loader that is the parent of the system class
loader.
classpath
- the classpath for finding classes, or
null
platform
- the classpath for finding platform classes, or
null
MalformedURLException
- if the URLs specified in the arguments
are malformed
IOException
- if an I/O error occurs while accessing files in the
classpathMethod Detail |
---|
public static ClassDepend newInstance(String classpath, String platform, boolean warn) throws MalformedURLException, IOException
classpath
argument
specifies the classpath that will be used to look up the class bytecode
for classes whose dependencies are being computed. If the value
specified is null
, then the system class loader will be
used. Otherwise, a URLClassLoader
will be constructed using the
URLs specified by classpath
and with a parent class loader
that is the parent of the system class loader. The
platform
argument specifies the classpath that will be used
to find classes that should be considered part of the platform and
should be excluded from consideration when computing dependencies. If
the value specified is null
, then the parent of the system
class loader will be used. Otherwise, a URLClassLoader
will be constructed using the URLs specified by platform
and with a parent class loader that is the parent of the system class
loader.
classpath
- the classpath for finding classes, or
null
platform
- the classpath for finding platform classes, or
null
warn
- print warnings instead of throwing an exception when a Class
can't be found or when ClassLoading fails.
MalformedURLException
IOException
public static void main(String[] args)
public Map getDependencyRelationshipMap(Collection rootClasses, boolean recurse) throws IOException, ClassNotFoundException
rootClasses
. Classes are found in a URL class loader by the
classpath
specified in the constructor.
rootClasses
- recurse
- If true, this option causes ClassDepend to inspect class
files for dependencies.
If false, ClassDepend doesn't inspect class files, it simply
gathers the names of class files from within Package directories and
JAR files.
IOException
ClassNotFoundException
ClassDependencyRelationship
public Set filterClassDependencyRelationShipMap(Map dependencyRelationShipMap, ClassDependParameters cdp)
dependencyRelationShipMap
- The initial map before filtering.cdp
- The parameters for filtration.
ClassDependParameters
,
ClassDependencyRelationship
protected void noteClassNotFound(String name) throws ClassNotFoundException
This implementation throws a ClassNotFoundException
.
name
- the class name
ClassNotFoundException
- to signal that processing should
terminate and the exception should be thrown to the callerprotected void noteClassLoadingFailed(String name, IOException e) throws IOException
name
- the class namee
- the exception caused by the failure
IOException
- to signal that processing should terminate and the
exception should be thrown to the callerprivate Set computeClasses(Collection names) throws IOException
IOException
private URL[] getClasspathURLs(String classpath) throws MalformedURLException
MalformedURLException
private boolean classPresent(String name, ClassLoader loader)
private String getResourceName(String classname)
public Pattern createPattern(Collection names)
names
-
public boolean matches(String string, Pattern pattern)
string
- pattern
-
private String quote(String s)
s
- - The String to be literalised
public boolean printClassesWithFileSeparator()
public void setPrintClassesWithFileSeparator(boolean printClassesWithFileSeparator)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |