Class ClassScanner

java.lang.Object
io.hawt.util.introspect.support.ClassScanner

public class ClassScanner extends Object
A helper class to scan classes on the classpath
  • Constructor Details

    • ClassScanner

      public ClassScanner(ClassLoader... classLoaders)
  • Method Details

    • newInstance

      public static ClassScanner newInstance()
    • clearCache

      public void clearCache()
    • setClassLoaderProvider

      public void setClassLoaderProvider(String id, ClassLoaderProvider classLoaderProvider)
      Registers a named class loader provider or removes it if the classLoaderProvider is null
    • findClassNames

      public SortedSet<String> findClassNames(String search, Integer limit)
      Searches for the available class names given the text search
      Returns:
      all the class names found on the current classpath using the given text search filter
    • findClassNamesMethodsAnnotatedWith

      public SortedSet<String> findClassNamesMethodsAnnotatedWith(String annotationClassName)
    • findClassNamesInDirectoryWithMethodAnnotatedWith

      public SortedSet<String> findClassNamesInDirectoryWithMethodAnnotatedWith(File dir, String annotationClassName)
    • addClassNamesInDirectoryWithMethodsAnnotatedWith

      protected void addClassNamesInDirectoryWithMethodsAnnotatedWith(SortedSet<String> answer, File dir, Class<? extends Annotation> annotationClass, String packageName)
    • optionallyFindAnnotationClass

      protected Class<? extends Annotation> optionallyFindAnnotationClass(String annotationClassName)
    • findClassNamesMethodsAnnotatedWith

      public SortedSet<String> findClassNamesMethodsAnnotatedWith(String annotationClassName, Integer limit, Map<Package,ClassLoader[]> packages)
    • findClassNamesInPackages

      public SortedSet<String> findClassNamesInPackages(String search, Integer limit, Map<Package,ClassLoader[]> packages)
    • findClassNames

      protected SortedSet<String> findClassNames(Map<Package,ClassLoader[]> packages, Predicate<String> filter, Integer limit)
    • getAllClassesMap

      public SortedMap<String,Class<?>> getAllClassesMap()
      Returns all the classes found in a sorted map
    • getClassesMap

      public SortedMap<String,Class<?>> getClassesMap(Package... packages)
      Returns all the classes found in a sorted map for the given list of packages
    • getClassesForPackage

      public Set<Class<?>> getClassesForPackage(ClassResource classResource, String filter, Integer limit)
    • findClass

      public Class<?> findClass(String className) throws ClassNotFoundException
      Finds a class from its name
      Throws:
      ClassNotFoundException
    • optionallyFindClass

      public Class<?> optionallyFindClass(String className)
      Returns the given class or null if it cannot be loaded
    • optionallyFindClasses

      public List<Class<?>> optionallyFindClasses(Iterable<String> classNames)
      Tries to find as many of the class names on the class loaders as possible and return them
    • getIgnorePackages

      public Set<String> getIgnorePackages()
    • setIgnorePackages

      public void setIgnorePackages(Set<String> ignorePackages)
    • addPackageResources

      protected void addPackageResources(Package aPackage, Map<String,ClassResource> urlSet, ClassLoader[] classLoaders)
    • createCacheValue

      protected CacheValue createCacheValue(String key, ClassResource classResource)
    • processDirectoryClassNames

      protected void processDirectoryClassNames(File directory, String packageName, Set<String> classes)
    • processJarClassNames

      protected void processJarClassNames(ClassResource classResource, Set<String> classes)
    • addClassesForPackage

      protected void addClassesForPackage(ClassResource classResource, String filter, Integer limit, Set<Class<?>> classes)
    • processDirectory

      protected void processDirectory(File directory, String packageName, Set<Class<?>> classes, String filter, Integer limit)
    • processJar

      protected void processJar(ClassResource classResource, Set<Class<?>> classes, String filter, Integer limit)
    • getJavaResourceKey

      protected String getJavaResourceKey(URL resource)
    • tryFindClass

      protected Class<?> tryFindClass(String className, String filter)
    • getResources

      protected List<URL> getResources(String relPath, ClassLoader... classLoaders)
    • classNameMatches

      protected boolean classNameMatches(String className, String search)
      Returns true if the given class name matches the filter search
    • getPackageRelativePath

      protected String getPackageRelativePath(String packageName)
    • withinLimit

      protected boolean withinLimit(Integer limit, Collection<?> collection)
      Returns true if we are within the limit value for the number of results in the collection
    • getClassLoaders

      public List<ClassLoader> getClassLoaders()