public class ResourceDataSource extends DataSource
ClassLoader.getResourceAsStream(java.lang.String)
method.DEFAULT_INTRO_LIMIT, MARK_WORKAROUND_PROPERTY
Constructor and Description |
---|
ResourceDataSource(String resource)
Constructs a new ResourceDataSource from a resource name with a
default size of intro buffer.
|
ResourceDataSource(String resource,
int introLimit)
Constructs a new ResourceDataSource from a resource name and
given size of intro buffer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
exists()
Indicates whether this resource can be located by the class loader
or not.
|
ClassLoader |
getClassLoader()
Returns the ClassLoader which is used for resource resolution.
|
InputStream |
getRawInputStream()
Provides a new InputStream for this data source.
|
URL |
getURL()
Returns a URL which corresponds to this data source, if one exists.
|
void |
setClassLoader(ClassLoader classLoader)
Sets the ClassLoader which is used for resource resolution.
|
close, forceCompression, getCompression, getHybridInputStream, getInputStream, getInputStream, getIntro, getIntroLimit, getLength, getMarkWorkaround, getName, getPosition, getRawLength, getSystemId, makeDataSource, makeDataSource, makeDataSource, setCompression, setIntroLimit, setMarkWorkaround, setName, setPosition, toString
public ResourceDataSource(String resource, int introLimit)
ClassLoader.getResource(java.lang.String)
but unlike Class.getResource(java.lang.String)
the resource name
is assumed absolute, and should '/'.resource
- the path of the resource represented by this DataSourceintroLimit
- the intro buffer sizepublic ResourceDataSource(String resource)
ClassLoader.getResource(java.lang.String)
but unlike Class.getResource(java.lang.String)
the resource name
is assumed absolute, and should '/'.resource
- the path of the resource represented by this DataSourcepublic InputStream getRawInputStream() throws IOException
DataSource
getRawInputStream
in class DataSource
IOException
public URL getURL()
DataSource
URL.openConnection()
method call on the URL
returned by this method should provide a stream with the
same content as the DataSource.getRawInputStream()
method of this
data source. If no such URL exists or is known, then null
should be returned.
If this source has a non-null position value, it will be appended to the main part of the URL after a '#' character (as the URL's ref part).
getURL
in class DataSource
null
public boolean exists()
public ClassLoader getClassLoader()
public void setClassLoader(ClassLoader classLoader)
classLoader
- the class loaderCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.