public class ClassFinder extends Object
| Constructor | Description |
|---|---|
ClassFinder() |
|
ClassFinder(File jarFile) |
|
ClassFinder(ClassLoader loader) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
find(String packageName,
Class<?> parentType) |
Scans the classpath for classes within the specified package and sub-packages that
extend the parentType.
|
Set<Class<?>> |
getClasses() |
Fetches the set of classes discovered so far.
|
Set<Class<?>> |
getConcreteClasses() |
Fetches the set of classes discovered so far, subsetted down to concrete (non-abstract/interface) classes only
|
protected void |
handleItem(String name) |
Checks an item to see if it is a class and is annotated with the specified
annotation.
|
static boolean |
isConcrete(Class<?> clazz) |
Determines whether or not the specified class is concrete (ie., non-abstract and non-interface)
|
protected void |
scanDir(File file,
String path) |
Scans a directory on the filesystem for classes.
|
protected void |
scanJar(File file,
String packagePath) |
Scans the entries in a ZIP/JAR file for classes under the parent package.
|
String |
toClassName(String filename) |
Convert a filename to a class name by removing '.class' and converting '/'s to '.'s.
|
public ClassFinder()
public ClassFinder(ClassLoader loader)
public ClassFinder(File jarFile) throws IOException
IOExceptionpublic String toClassName(String filename)
public void find(String packageName, Class<?> parentType)
getClasses().protected void scanJar(File file, String packagePath) throws IOException
file - the jar file to be scannedpackagePath - the top level package to start fromIOExceptionprotected void scanDir(File file, String path)
file - the directory or file to examinepath - the package path acculmulated so far (e.g. edu/mit/broad)protected void handleItem(String name)
name - the path equivelant to the package + class/item namepublic Set<Class<?>> getConcreteClasses()
public static boolean isConcrete(Class<?> clazz)
clazz - class to check