Class ClassLoaderHandler<T>

java.lang.Object
ca.phon.util.resources.URLHandler<T>
ca.phon.util.resources.ClassLoaderHandler<T>
All Implemented Interfaces:
ResourceHandler<T>, Iterable<T>
Direct Known Subclasses:
BasicSyllabifierClassLoaderProvider, DefaultDictionaryProvider, OpGraphSyllabifierClassLoaderProvider, StockAnalysisHandler, StockMacroHandler, StockReportHandler, SystemQueryScriptHandler, TransliterationDictionaryProvider

public abstract class ClassLoaderHandler<T> extends URLHandler<T>
Loads resources from a specified class loader (or the default class loader if not specified.) Resources are located using ClassLoader.getResources(String) for each specified resource.
  • Field Details

    • resourcePaths

      public List<String> resourcePaths
      Resources to load
  • Constructor Details

    • ClassLoaderHandler

      public ClassLoaderHandler()
      Constructor
    • ClassLoaderHandler

      public ClassLoaderHandler(ClassLoader cl)
      Constructor
      Parameters:
      cl - the classloader to use
  • Method Details

    • addResource

      public void addResource(String res)
      Add a resource to locate
      Parameters:
      res - the resource to locate. Use the naming rules outline by ClassLoader.getResource(String).
    • loadResourceFile

      public void loadResourceFile(String resFile)
      Load resource list from the give resource file.
      Parameters:
      file -
    • removeResource

      public void removeResource(String res)
      Remove resource
      Parameters:
      res -
    • getResourcePaths

      public List<String> getResourcePaths()
    • iterator

      public Iterator<T> iterator()
      Description copied from interface: ResourceHandler
      Return an iterator for instances of type T.
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface ResourceHandler<T>
      Overrides:
      iterator in class URLHandler<T>
      Returns:
      an iterator providing instances of the parameterized type
    • getClassLoader

      public ClassLoader getClassLoader()
      Get the class loader used by this handler.
      Returns:
      ClassLoader
    • setClassLoader

      public void setClassLoader(ClassLoader cl)
      Set the class loader used by this handler.
      Parameters:
      cl - the new class loader to use, if null the default system classloader is used