de.unihalle.informatik.Alida.helpers
Class SubclassFinder
java.lang.Object
de.unihalle.informatik.Alida.helpers.SubclassFinder
public class SubclassFinder
- extends java.lang.Object
Utility-class with static methods to
- find all sub-classes of a certain class (or interface) within the scope
of the current class-loader
- find all sub-classes of a certain class (or interface) within the scope
of the current class-loader that can be instantiated, i.e. that are neither
interfaces nor abstract
- filter a set of classes by inheritance from a super-class
- obtain the class of an
InstanceParameterSet
that can be used to
instantiate a sub-class of InstantiableFromParameterSet
.
- obtain a
CollectionParameter
using all possible
InstanceParameterSet
s (for classes that are a subclass of a specified
superclass) as elements
The methods may fail to find a certain sub-class, if
- it was loaded by another
ClassLoader
than the caller
- it was loaded from a physically other place than the super-class, e.g.
another jar-file.
- Author:
- Jan Grau, Jens Keilwagen
Method Summary |
static java.util.LinkedList<java.lang.Class> |
findInstantiableSubclasses(java.lang.Class clazz,
java.lang.String startPackage)
Returns all sub-classes of T that can be instantiated, i.e. |
static java.util.LinkedList<java.lang.Class> |
findSubclasses(java.lang.Class clazz,
java.lang.String startPackage)
Returns all sub-classes of T including interfaces and
abstract classes that are located in a package below
startPackage . |
static java.util.LinkedList<java.lang.Class> |
findSubclasses(java.lang.String prefix,
java.lang.Class clazz,
java.lang.String startPackage)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SubclassFinder
public SubclassFinder()
findInstantiableSubclasses
public static java.util.LinkedList<java.lang.Class> findInstantiableSubclasses(java.lang.Class clazz,
java.lang.String startPackage)
throws java.lang.ClassNotFoundException,
java.io.IOException
- Returns all sub-classes of
T
that can be instantiated, i.e.
are neither an interface nor abstract, and that are located in a package
below startPackage
.
- Type Parameters:
T
- The class to obtain the sub-classes for- Parameters:
clazz
- the Class
object for TstartPackage
- the package under which to search
- Returns:
- the
Class
objects for the sub-classes
- Throws:
java.lang.ClassNotFoundException
- if one of the classes is present in the file system or jar
but cannot be loaded by the class loader
java.io.IOException
- is thrown if the classes are searched for in a jar file, but
that file could not be accessed or read
findSubclasses
public static java.util.LinkedList<java.lang.Class> findSubclasses(java.lang.Class clazz,
java.lang.String startPackage)
throws java.lang.ClassNotFoundException,
java.io.IOException
- Returns all sub-classes of
T
including interfaces and
abstract classes that are located in a package below
startPackage
.
- Type Parameters:
T
- The class to obtain the sub-classes for- Parameters:
clazz
- the Class
object for TstartPackage
- the package under which to search
- Returns:
- the
Class
objects for the sub-classes
- Throws:
java.lang.ClassNotFoundException
- if one of the classes is present in the file system or jar
but cannot be loaded by the class loader
java.io.IOException
- is thrown if the classes are searched for in a jar file, but
that file could not be accessed or read
findSubclasses
public static java.util.LinkedList<java.lang.Class> findSubclasses(java.lang.String prefix,
java.lang.Class clazz,
java.lang.String startPackage)
throws java.lang.ClassNotFoundException,
java.io.IOException
- Throws:
java.lang.ClassNotFoundException
java.io.IOException
Copyright © 2010-2014 Martin Luther University Halle-Wittenberg. All Rights Reserved.