Package ca.phon.util.resources
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
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 Summary
-
Constructor Summary
ConstructorDescriptionConstructorConstructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addResource
(String res) Add a resource to locateGet the class loader used by this handler.iterator()
Return an iterator for instances of type T.void
loadResourceFile
(String resFile) Load resource list from the give resource file.void
removeResource
(String res) Remove resourcevoid
Set the class loader used by this handler.Methods inherited from class ca.phon.util.resources.URLHandler
add, getURLS, loadFromURL, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
resourcePaths
Resources to load
-
-
Constructor Details
-
ClassLoaderHandler
public ClassLoaderHandler()Constructor -
ClassLoaderHandler
Constructor- Parameters:
cl
- the classloader to use
-
-
Method Details
-
addResource
Add a resource to locate- Parameters:
res
- the resource to locate. Use the naming rules outline byClassLoader.getResource(String)
.
-
loadResourceFile
Load resource list from the give resource file.- Parameters:
file
-
-
removeResource
Remove resource- Parameters:
res
-
-
getResourcePaths
-
iterator
Description copied from interface:ResourceHandler
Return an iterator for instances of type T.- Specified by:
iterator
in interfaceIterable<T>
- Specified by:
iterator
in interfaceResourceHandler<T>
- Overrides:
iterator
in classURLHandler<T>
- Returns:
- an iterator providing instances of the parameterized type
-
getClassLoader
Get the class loader used by this handler.- Returns:
- ClassLoader
-
setClassLoader
Set the class loader used by this handler.- Parameters:
cl
- the new class loader to use, ifnull
the default system classloader is used
-