Class ClassEnumerator


  • public class ClassEnumerator
    extends java.lang.Object
    Taken and adapted from here
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassEnumerator()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.SortedSet<java.lang.String> getClassesForPackage​(java.lang.Package pkg)
      Return all the classes in this package recursively.
      static java.util.SortedSet<java.lang.String> getClassesForPackage​(java.lang.Package pkg, java.lang.ClassLoader classLoader)
      Return all the classes in this package recursively.
      private static void processDirectory​(java.io.File directory, java.lang.String pkgname, java.util.SortedSet<java.lang.String> classes)  
      private static void processJarfile​(java.net.URL resource, java.lang.String pkgname, java.util.SortedSet<java.lang.String> classes)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClassEnumerator

        public ClassEnumerator()
    • Method Detail

      • processDirectory

        private static void processDirectory​(java.io.File directory,
                                             java.lang.String pkgname,
                                             java.util.SortedSet<java.lang.String> classes)
      • processJarfile

        private static void processJarfile​(java.net.URL resource,
                                           java.lang.String pkgname,
                                           java.util.SortedSet<java.lang.String> classes)
      • getClassesForPackage

        public static java.util.SortedSet<java.lang.String> getClassesForPackage​(java.lang.Package pkg)
        Return all the classes in this package recursively. The class loader of the ClassEnumerator class is used
        Parameters:
        pkg - the searched package
        Returns:
        list of full class names
      • getClassesForPackage

        public static java.util.SortedSet<java.lang.String> getClassesForPackage​(java.lang.Package pkg,
                                                                                 java.lang.ClassLoader classLoader)
        Return all the classes in this package recursively.
        Parameters:
        pkg - the searched package
        classLoader - class loader where to look for classes
        Returns:
        list of full class names