public class ClassFinder extends Object
| Constructor and Description |
|---|
ClassFinder() |
ClassFinder(ClassLoader loader) |
ClassFinder(File jarFile) |
| Modifier and Type | Method and 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.
|
protected void |
handleItem(String name)
Checks an item to see if it is a class and is annotated with the specified
annotation.
|
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 name