Class ClassTools

java.lang.Object
de.intarsys.tools.reflect.ClassTools

public class ClassTools extends Object
Tool class to enhance the reflective capabilities about classes.
  • Method Details

    • collectClasses

      public static List collectClasses(String classPath) throws IOException
      Create a list of all classes that are available from classPath.

      Be aware that the classes are loaded and so any static code is executed.

      Parameters:
      classPath - The classpath to inspect
      Returns:
      A list of all classes that are available from classPath.
      Throws:
      IOException
    • collectClassNames

      public static List collectClassNames(String classPath) throws IOException
      Create a list of class names in dot notation that can be found in the classPath.
      Parameters:
      classPath - The classpath to inspect
      Returns:
      A list of class names in dot notation that can be found in the classPath.
      Throws:
      IOException
    • createClass

      public static <T> Class<T> createClass(String className, Class<T> expectedClass, ClassLoader classLoader) throws ObjectCreationException
      Throws:
      ObjectCreationException
    • createClassLoader

      public static ClassLoader createClassLoader(String classPath)
      Create a new ClassLoader on the specified classpath
      Parameters:
      classPath - The classpath we want to load from.
      Returns:
      A new ClassLoader on the specified classpath
    • extractClassNamesFromDir

      protected static void extractClassNamesFromDir(List result, File currentFile, String relativePath) throws IOException
      Create a list of all classes "current" and its subdirectories.
      Parameters:
      result - The collection that is filled with new classnames
      currentFile - The directory/file under inspection
      relativePath - The path extending from the initial root we are currently inspecting.
      Throws:
      IOException
    • extractClassNamesFromJar

      protected static void extractClassNamesFromJar(List result, File file) throws IOException
      Create a list of all ".class" entries in the jar file.
      Parameters:
      result - The collection that is filled with new classnames
      file - The jar file we are inspecting.
      Throws:
      IOException
    • getPackageName

      public static String getPackageName(Class clazz)
    • getUnqualifiedName

      public static String getUnqualifiedName(Class clazz)