Package org.apache.lucene.analysis.util
Class ClasspathResourceLoader
- java.lang.Object
-
- org.apache.lucene.analysis.util.ClasspathResourceLoader
-
- All Implemented Interfaces:
ResourceLoader
public final class ClasspathResourceLoader extends java.lang.Object implements ResourceLoader
SimpleResourceLoader
that usesClassLoader.getResourceAsStream(String)
andClass.forName(String,boolean,ClassLoader)
to open resources and classes, respectively.
-
-
Constructor Summary
Constructors Constructor Description ClasspathResourceLoader()
Creates an instance using the context classloader to load Resources and classes.ClasspathResourceLoader(java.lang.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(java.lang.ClassLoader loader)
Creates an instance using the given classloader to load Resources and classes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> java.lang.Class<? extends T>
findClass(java.lang.String cname, java.lang.Class<T> expectedType)
Finds class of the name and expected type<T> T
newInstance(java.lang.String cname, java.lang.Class<T> expectedType)
Creates an instance of the name and expected typejava.io.InputStream
openResource(java.lang.String resource)
Opens a named resource
-
-
-
Constructor Detail
-
ClasspathResourceLoader
public ClasspathResourceLoader()
Creates an instance using the context classloader to load Resources and classes. Resource paths must be absolute.
-
ClasspathResourceLoader
public ClasspathResourceLoader(java.lang.ClassLoader loader)
Creates an instance using the given classloader to load Resources and classes. Resource paths must be absolute.
-
ClasspathResourceLoader
public ClasspathResourceLoader(java.lang.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.
-
-
Method Detail
-
openResource
public java.io.InputStream openResource(java.lang.String resource) throws java.io.IOException
Description copied from interface:ResourceLoader
Opens a named resource- Specified by:
openResource
in interfaceResourceLoader
- Throws:
java.io.IOException
-
findClass
public <T> java.lang.Class<? extends T> findClass(java.lang.String cname, java.lang.Class<T> expectedType)
Description copied from interface:ResourceLoader
Finds class of the name and expected type- Specified by:
findClass
in interfaceResourceLoader
-
newInstance
public <T> T newInstance(java.lang.String cname, java.lang.Class<T> expectedType)
Description copied from interface:ResourceLoader
Creates an instance of the name and expected type- Specified by:
newInstance
in interfaceResourceLoader
-
-