Class PackageResourceStream
- java.lang.Object
-
- org.apache.wicket.util.resource.AbstractResourceStream
-
- org.apache.wicket.core.util.resource.PackageResourceStream
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,IClusterable
,IResourceStream
,IModifiable
public class PackageResourceStream extends AbstractResourceStream
AnIResourceStream
that reads data from a resource in the classpath. It simply delegates all operations to theIResourceStream
returned by the application'sIResourceStreamLocator
.- Author:
- Jean-Baptiste Quenot, Tobias Soloschenko
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PackageResourceStream(Class<?> scope, String path)
Obtains anIResourceStream
from the application'sIResourceStreamLocator.locate(Class, String)
PackageResourceStream(Class<?> scope, String path, Locale locale, String style, String variation)
Obtains anIResourceStream
from the application'sIResourceStreamLocator.locate(Class, String)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the resource.String
getContentType()
Gets the mime type of this resourceInputStream
getInputStream()
Gets the resource stream.Instant
lastModifiedTime()
Gets the last time this modifiable thing changed.Bytes
length()
Gets the size of this resource-
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
-
-
-
-
Constructor Detail
-
PackageResourceStream
public PackageResourceStream(Class<?> scope, String path)
Obtains anIResourceStream
from the application'sIResourceStreamLocator.locate(Class, String)
- Parameters:
scope
- This argument will be used to get the class loader for loading the package resource, and to determine what package it is in.path
- The path to the resource
-
PackageResourceStream
public PackageResourceStream(Class<?> scope, String path, Locale locale, String style, String variation)
Obtains anIResourceStream
from the application'sIResourceStreamLocator.locate(Class, String)
- Parameters:
scope
- This argument will be used to get the class loader for loading the package resource, and to determine what package it is in.path
- The path to the resourcelocale
- the locale of the resource to getstyle
- the style of the resource to getvariation
- the variation of the resource to get
-
-
Method Detail
-
close
public void close() throws IOException
Description copied from interface:IResourceStream
Closes the resource. Normally, this includes closing any underlying input stream returned by getInputStream().- Throws:
IOException
-
getContentType
public String getContentType()
Description copied from interface:IResourceStream
Gets the mime type of this resource- Specified by:
getContentType
in interfaceIResourceStream
- Overrides:
getContentType
in classAbstractResourceStream
- Returns:
- The mime type of this resource, such as "image/jpeg" or "text/html". Return null to let ResourceStreamRequestHandler handle the Content-Type automatically
-
getInputStream
public InputStream getInputStream() throws ResourceStreamNotFoundException
Description copied from interface:IResourceStream
Gets the resource stream. You should not directly close this stream. Instead call the close() method on IResourceStream.- Returns:
- Returns the inputStream.
- Throws:
ResourceStreamNotFoundException
- See Also:
IResourceStream.close()
-
length
public Bytes length()
Description copied from interface:IResourceStream
Gets the size of this resource- Specified by:
length
in interfaceIResourceStream
- Overrides:
length
in classAbstractResourceStream
- Returns:
- The size of this resource in the number of bytes, or
null
if unknown
-
lastModifiedTime
public Instant lastModifiedTime()
Description copied from interface:IModifiable
Gets the last time this modifiable thing changed.- Specified by:
lastModifiedTime
in interfaceIModifiable
- Overrides:
lastModifiedTime
in classAbstractResourceStream
- Returns:
- the last modification
Time
ornull
if that information is not available
-
-