Package org.apache.lucene.analysis.util
Class ClasspathResourceLoader
java.lang.Object
org.apache.lucene.analysis.util.ClasspathResourceLoader
- All Implemented Interfaces:
ResourceLoader
Simple
ResourceLoader
that uses ClassLoader.getResourceAsStream(String)
and Class.forName(String,boolean,ClassLoader)
to open resources and
classes, respectively.-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance using the context classloader to load Resources and classes.ClasspathResourceLoader
(Class<?> clazz) Creates an instance using the context classloader to load Resources and classes Resources are resolved relative to the given class, if path is not absolute.ClasspathResourceLoader
(ClassLoader loader) Creates an instance using the given classloader to load Resources and classes. -
Method Summary
Modifier and TypeMethodDescription<T> Class
<? extends T> Finds class of the name and expected type<T> T
newInstance
(String cname, Class<T> expectedType) Creates an instance of the name and expected typeopenResource
(String resource) Opens a named resource
-
Constructor Details
-
ClasspathResourceLoader
public ClasspathResourceLoader()Creates an instance using the context classloader to load Resources and classes. Resource paths must be absolute. -
ClasspathResourceLoader
Creates an instance using the given classloader to load Resources and classes. Resource paths must be absolute. -
ClasspathResourceLoader
Creates an instance using the context classloader to load Resources and classes Resources are resolved relative to the given class, if path is not absolute.
-
-
Method Details
-
openResource
Description copied from interface:ResourceLoader
Opens a named resource- Specified by:
openResource
in interfaceResourceLoader
- Throws:
IOException
-
findClass
Description copied from interface:ResourceLoader
Finds class of the name and expected type- Specified by:
findClass
in interfaceResourceLoader
-
newInstance
Description copied from interface:ResourceLoader
Creates an instance of the name and expected type- Specified by:
newInstance
in interfaceResourceLoader
-