|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectverinec.util.InterfaceUtility
public class InterfaceUtility
This utilily class provides methods to find Class resources that implement a given Interface.
You can specify an interface that the class must match. All folders and jars
in the classpath are searched for classes, of which each is tested whether
it implements the interface.
The interface can be just the name of the interface, or can also contain the
package name. (If it is just the name, classes implementing any interface with
that name are found, if the name occurs in more than one packages.)
Examples:
IMyInterface:
To avoid unexpected results, specify the full classpath.
| Constructor Summary | |
|---|---|
InterfaceUtility()
|
|
| Method Summary | |
|---|---|
private static void |
addClassIfImplements(ArrayList resourceList,
String classname,
String iface)
Test wether the class implements the interface and if it does, add it to the list if it is not yet in it. |
static ArrayList |
getClassResources(String iface)
Finds and returns URLs of all the system resources(classes) that implement a given interface. |
private static ArrayList |
getClassResourcesFromArchive(ArrayList resourceList,
JarFile jar,
String iface)
Finds all of the entries within the specified JAR file that implement the specified interface and returns the associated resource URLs. |
private static ArrayList |
getClassResourcesFromDirectory(ArrayList resourceList,
File dir,
String iface)
Finds all of the classes under the specified root directory within subdirectories that implement the specified interface and returns the associated resource URLs. |
private static ArrayList |
getClassResourcesFromDirectory(ArrayList resourceList,
File dir,
String iface,
String relpath)
Implements the recursive search through directories. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InterfaceUtility()
| Method Detail |
|---|
public static final ArrayList getClassResources(String iface)
throws IOException
iface - The implemented interface to look for.
IOException - If creation of jar file fails.
private static final ArrayList getClassResourcesFromArchive(ArrayList resourceList,
JarFile jar,
String iface)
resourceList - list of the already found classesjar - The JAR file to search; if null an empty list will be returned.iface - The interface classes must implement.
private static final ArrayList getClassResourcesFromDirectory(ArrayList resourceList,
File dir,
String iface)
resourceList - list of the already found classesdir - the directory to add (potentially); if dir is null or dir is
not a directory then an empty Collection is returnediface - the implemented interface to look for.
private static final ArrayList getClassResourcesFromDirectory(ArrayList resourceList,
File dir,
String iface,
String relpath)
resourceList - list of the already found classesdir - The root directory of the searchiface - the implemented interface to look for.relpath - Path so far opened from root path.
private static final void addClassIfImplements(ArrayList resourceList,
String classname,
String iface)
resourceList - The list to add the class if it implements the interface.classname - Name (with full class path) of a class to test.iface - Interface name of interface the class must implement.
|
Copyright © 2005 Verinec, DIUF | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||