public final class ClassResolver extends Object implements TraversalRoot
ClassRoot objects for which
each represents a classes directory or a JAR file. And it has to HashMaps
for all the packages and classes contained in any of these roots. The key
used for theses HashMaps is the full qualified class or package name.
The ClassPackage has a collection of all classes subpackages it contains.
Thus it provides direct access to all classes and subpackages of some package
within some root.
Each ClassPackage or ClassEntry belongs to one root. The
same class or package name may appear within different roots. In that case the
ClassPackage or ClassEntry has LinkedList of all entries with the
same name. This lists can be accessed by ClassPackage.getAlternatives()
or ClassEntry.getAlternatives() respectively. Each entry points
to the same list of alternatives. If there are no alternatives the correspondig
list is null.
Typically one of the static of methods should be used to create a ClassResolver.
| Constructor and Description |
|---|
ClassResolver() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(File file) |
void |
add(String path) |
void |
addBootClassPath() |
void |
addClassPath() |
void |
addRoot(ClassRoot root) |
void |
freeze() |
int |
getClassCount() |
ClassEntry |
getClassEntry(File root,
String classname) |
ClassEntry |
getClassEntry(String classname) |
Map<String,List<ClassEntry>> |
getDuplicates() |
ClassPackage |
getPackage(File root,
String packageName) |
ClassPackage |
getPackage(String packageName) |
int |
getPackageCount() |
ClassRoot |
getRoot(File file) |
Set<File> |
getRootDirs() |
Set<File> |
getRootFiles() |
Set<File> |
getRootFiles(Predicate<File> predicate) |
Set<File> |
getRootJars() |
static ClassResolver |
of(String path)
Creates a ClassResolver for some arbitrary path.
|
static ClassResolver |
ofBootClassPath() |
static ClassResolver |
ofClassPath() |
static ClassResolver |
ofClassPathAndBootClassPath() |
static ClassResolver |
ofClassPathWithoutJars() |
String |
toString() |
void |
traverse(NamePattern pattern,
ClassVisitor visitor) |
public static ClassResolver of(String path) throws IOException
path - the path to scan using the system specific classpath formatIOException - if a directory or jar file could not be readpublic static ClassResolver ofClassPath() throws IOException
IOExceptionpublic static ClassResolver ofClassPathWithoutJars() throws IOException
IOExceptionpublic static ClassResolver ofBootClassPath() throws IOException
IOExceptionpublic static ClassResolver ofClassPathAndBootClassPath() throws IOException
IOExceptionpublic void addClassPath()
throws IOException
IOExceptionpublic void addBootClassPath()
throws IOException
IOExceptionpublic void add(String path) throws IOException
IOExceptionpublic void add(File file) throws IOException
IOExceptionpublic void addRoot(ClassRoot root) throws IOException
IOExceptionpublic void freeze()
public ClassPackage getPackage(String packageName)
public ClassPackage getPackage(File root, String packageName)
public ClassEntry getClassEntry(String classname)
public ClassEntry getClassEntry(File root, String classname)
public void traverse(NamePattern pattern, ClassVisitor visitor)
traverse in interface TraversalRootpublic Map<String,List<ClassEntry>> getDuplicates()
public int getPackageCount()
public int getClassCount()
Copyright © 2017–2021 Hans Jörg Heßmann. All rights reserved.