|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.utils.SubclassFinder
public class SubclassFinder
Utility-class with static methods to
InstanceParameterSet
that can be used to
instantiate a sub-class of InstantiableFromParameterSet
.SelectionParameter
using all possible
ParameterSet
s (for classes that are a subclass of a specified
superclass) as elementsClassLoader
than the caller
Field Summary | |
---|---|
static String |
includePath
This field can be set to include a path into the search performed in findSubclasses(Class, String)
thereby enabling to find self-implemented classes not included in the Jstacs class hierarchy. |
Constructor Summary | |
---|---|
SubclassFinder()
|
Method Summary | ||
---|---|---|
static
|
filterBySuperclass(Class<S> superclass,
LinkedList<Class<? extends T>> listToFilter)
Returns a LinkedList of the Class objects for all classes
in listToFilter that are sub-classes of
superClass . |
|
static
|
findInstantiableSubclasses(Class<T> clazz,
String startPackage)
Returns all sub-classes of T that can be instantiated, i.e. |
|
static
|
findSubclasses(Class<T> clazz,
String startPackage)
Returns all sub-classes of T including interfaces and
abstract classes that are located in a package below
startPackage . |
|
static
|
getInstanceParameterSets(Class<T> clazz,
String startPackage)
This method returns a list of InstanceParameterSet s that can be used to create a subclass of clazz . |
|
static LinkedList<Class<? extends InstanceParameterSet>> |
getParameterSetFor(Class<? extends InstantiableFromParameterSet> clazz)
Returns a LinkedList of the classes of the
InstanceParameterSet s that can be used to instantiate the
sub-class of InstantiableFromParameterSet that is given by
clazz |
|
static
|
getSelectionParameter(Class<? extends ParameterSet> clazz,
String startPackage,
String name,
String comment,
boolean required)
This method creates an SelectionParameter that contains
InstanceParameterSet for each possible
class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String includePath
findSubclasses(Class, String)
thereby enabling to find self-implemented classes not included in the Jstacs class hierarchy.
The default value of this field is null
.
findSubclasses(Class, String)
it is highly recommended to reset the value. If this is not done, preceeding searches might take longer.
Constructor Detail |
---|
public SubclassFinder()
Method Detail |
---|
public static <T> LinkedList<Class<? extends T>> findInstantiableSubclasses(Class<T> clazz, String startPackage) throws ClassNotFoundException, IOException
T
that can be instantiated, i.e.
are neither an interface nor abstract, and that are located in a package
below startPackage
.
T
- The class to obtain the sub-classes forclazz
- the Class
object for TstartPackage
- the package under which to search
Class
objects for the sub-classes
ClassNotFoundException
- if one of the classes is present in the file system or jar
but cannot be loaded by the class loader
IOException
- is thrown if the classes are searched for in a jar file, but
that file could not be accessed or readpublic static <S,T> LinkedList<Class<? extends S>> filterBySuperclass(Class<S> superclass, LinkedList<Class<? extends T>> listToFilter)
LinkedList
of the Class
objects for all classes
in listToFilter
that are sub-classes of
superClass
.
S
- the class that is used as filterT
- a common super-class of all classes in
listToFilter
superclass
- the additional class to use as a filter criterionlistToFilter
- the list of classes
public static LinkedList<Class<? extends InstanceParameterSet>> getParameterSetFor(Class<? extends InstantiableFromParameterSet> clazz)
LinkedList
of the classes of the
InstanceParameterSet
s that can be used to instantiate the
sub-class of InstantiableFromParameterSet
that is given by
clazz
clazz
- the Class
object of the sub-class of
InstantiableFromParameterSet
LinkedList
of Class
es of the corresponding
InstanceParameterSet
spublic static <T> LinkedList<Class<? extends T>> findSubclasses(Class<T> clazz, String startPackage) throws ClassNotFoundException, IOException
T
including interfaces and
abstract classes that are located in a package below
startPackage
.
T
- The class to obtain the sub-classes forclazz
- the Class
object for TstartPackage
- the package under which to search
Class
objects for the sub-classes
ClassNotFoundException
- if one of the classes is present in the file system or jar
but cannot be loaded by the class loader
IOException
- is thrown if the classes are searched for in a jar file, but
that file could not be accessed or readpublic static <T> SelectionParameter getSelectionParameter(Class<? extends ParameterSet> clazz, String startPackage, String name, String comment, boolean required) throws Exception
SelectionParameter
that contains
InstanceParameterSet
for each possible
class. The classes are specified by
findInstantiableSubclasses(Class, String)
and
filterBySuperclass(Class, LinkedList)
.
T
- The class to use the sub-classes in the
SelectionParameter
clazz
- the Class
object for T
startPackage
- the package under which to start the searchname
- the name of the SelectionParameter
comment
- the comment for the SelectionParameter
required
- whether the SelectionParameter
is required
SelectionParameter
that contains
InstanceParameterSet
for each
possible class.
Exception
- if the SelectionParameter
could not be created properlyfindInstantiableSubclasses(Class, String)
,
filterBySuperclass(Class, LinkedList)
,
getInstanceParameterSets(Class, String)
public static <T> LinkedList<InstanceParameterSet<? extends T>> getInstanceParameterSets(Class<T> clazz, String startPackage) throws ClassNotFoundException, IOException, InstantiationException, IllegalAccessException
InstanceParameterSet
s that can be used to create a subclass of clazz
.
The classes are specified by
findInstantiableSubclasses(Class, String)
and
filterBySuperclass(Class, LinkedList)
.
T
- The class to use the sub-classes in the
SelectionParameter
clazz
- the Class
object for T
startPackage
- the package under which to start the search
LinkedList
that contains
InstanceParameterSet
for each
possible class.
InstantiationException
- if any InstanceParameterSet
has no nullary
constructor; or if the instantiation fails for some other
reason
IllegalAccessException
- if any InstanceParameterSet
or its nullary
constructor is not accessible
ClassNotFoundException
- if one of the classes is present in the file system or jar
but cannot be loaded by the class loader
IOException
- if the classes are searched for in a jar file, but that file
could not be accessed or readfindInstantiableSubclasses(Class, String)
,
filterBySuperclass(Class, LinkedList)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |