public class ClassDepend extends Object
Modifier and Type | Method and Description |
---|---|
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.
|
Map |
getDependencyRelationshipMap(Collection rootClasses,
boolean recurse)
This method builds the entire DependencyRelationShipMap that can be
used to analyse class dependencies.
|
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() |
void |
setPrintClassesWithFileSeparator(boolean printClassesWithFileSeparator) |
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 nameClassNotFoundException
- 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 failureIOException
- to signal that processing should terminate and the
exception should be thrown to the callerpublic Pattern createPattern(Collection names)
names
- public boolean matches(String string, Pattern pattern)
string
- pattern
- public boolean printClassesWithFileSeparator()
public void setPrintClassesWithFileSeparator(boolean printClassesWithFileSeparator)
Copyright © 2016–2018. All rights reserved.