Class ClassFinder

java.lang.Object
net.simplace.core.service.ClassFinder

public class ClassFinder extends Object
This utility class was based originally on Daniel Le Berre's RTSI class. This class can be called in different modes, but the principal use is to determine what subclasses/implementations of a given class/interface exist in the current runtime environment.
Author:
Daniel Le Berre, Elliott Wade
  • Method Details

    • getInstance

      public static ClassFinder getInstance()
      Returns:
      The singleton instance
    • refreshLocations

      public final void refreshLocations()
      Rescan the classpath, cacheing all possible file locations.
    • findSubclasses

      public final Vector<Class<?>> findSubclasses(String aStartsWithFilter, String fqcn)
      Parameters:
      aStartsWithFilter -
      fqcn - Name of superclass/interface on which to search
      Returns:
      Vector
    • exists

      public static boolean exists(String aClassName)
    • findResources

      public Vector<URL> findResources(String aPackage, String aRegexp)
      Parameters:
      aPackage -
      aRegexp -
      Returns:
      a Vector of Resources
    • getErrors

      public final List<Throwable> getErrors()
      Returns:
      List of Errors
    • getLocationOf

      public final URL getLocationOf(Class<?> cls)
      The result of the last search is cached in this object, along with the URL that corresponds to each class returned. This method may be called to query the cache for the location at which the given class was found. null will be returned if the given class was not found during the last search, or if the result cache has been cleared.
      Parameters:
      cls -
      Returns:
      location of the class
    • getClasspathLocations

      public final Map<URL,String> getClasspathLocations()
      Determine every URL location defined by the current classpath, and it's associated package name.
      Returns:
      Map of URL location defined by the current classpath, and it's associated package name
    • getResources

      public Collection<String> getResources(String pattern)
      for all elements of java.class.path get a Collection of resources Pattern pattern = Pattern.compile(".*"); gets all resources
      Parameters:
      aPackage -
      pattern - the pattern to match
      Returns:
      the resources in the order they are found
    • main

      public static void main(String[] args)
      Parameters:
      args -