de.unihalle.informatik.Alida.helpers
Class SubclassFinder

java.lang.Object
  extended by de.unihalle.informatik.Alida.helpers.SubclassFinder

public class SubclassFinder
extends Object

Utility-class with static methods to

The methods may fail to find a certain sub-class, if

Author:
Jan Grau, Jens Keilwagen

Constructor Summary
SubclassFinder()
           
 
Method Summary
static LinkedList<Class> findInstantiableSubclasses(Class clazz, String startPackage)
          Returns all sub-classes of T that can be instantiated, i.e.
static LinkedList<Class> findSubclasses(Class clazz, String startPackage)
          Returns all sub-classes of T including interfaces and abstract classes that are located in a package below startPackage.
static LinkedList<Class> findSubclasses(String prefix, Class clazz, String startPackage)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubclassFinder

public SubclassFinder()
Method Detail

findInstantiableSubclasses

public static LinkedList<Class> findInstantiableSubclasses(Class clazz,
                                                           String startPackage)
                                                    throws ClassNotFoundException,
                                                           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 T
startPackage - the package under which to search
Returns:
the Class objects for the sub-classes
Throws:
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 read

findSubclasses

public static LinkedList<Class> findSubclasses(Class clazz,
                                               String startPackage)
                                        throws ClassNotFoundException,
                                               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 T
startPackage - the package under which to search
Returns:
the Class objects for the sub-classes
Throws:
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 read

findSubclasses

public static LinkedList<Class> findSubclasses(String prefix,
                                               Class clazz,
                                               String startPackage)
                                        throws ClassNotFoundException,
                                               IOException
Throws:
ClassNotFoundException
IOException


Copyright © 2010–2014 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.