Module org.apache.wicket.util
Package org.apache.wicket.util.resource
Class AbstractStringResourceStream
java.lang.Object
org.apache.wicket.util.resource.AbstractResourceStream
org.apache.wicket.util.resource.AbstractStringResourceStream
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,IClusterable
,IResourceStream
,IStringResourceStream
,IModifiable
- Direct Known Subclasses:
StringBufferResourceStream
,StringResourceStream
,TextTemplate
public abstract class AbstractStringResourceStream
extends AbstractResourceStream
implements IStringResourceStream
Base class for string resources.
- Author:
- Jonathan Locke
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The content-type applied in case the resource stream's default constructor is used -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionasString()
void
close()
Closes the resource.protected Charset
Gets the mime type of this resourceGets the resource stream.protected abstract String
Gets the last time this modifiable thing changed.final Bytes
length()
Gets the size of this resourcevoid
setCharset
(Charset charset) Sets the character set used for reading this resource.void
setLastModified
(Instant lastModified) Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.wicket.util.resource.IResourceStream
getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
-
Field Details
-
DEFAULT_CONTENT_TYPE
The content-type applied in case the resource stream's default constructor is used- See Also:
-
-
Constructor Details
-
AbstractStringResourceStream
public AbstractStringResourceStream()Constructor. -
AbstractStringResourceStream
Constructor.- Parameters:
contentType
- The mime type of this resource, such as "image/jpeg" or "text/html"
-
-
Method Details
-
asString
- Specified by:
asString
in interfaceIStringResourceStream
- Returns:
- This resource as a String.
-
getCharset
- Returns:
- Charset for resource
-
setCharset
Sets the character set used for reading this resource.- Specified by:
setCharset
in interfaceIStringResourceStream
- Parameters:
charset
- Charset for component
-
close
Description copied from interface:IResourceStream
Closes the resource. Normally, this includes closing any underlying input stream returned by getInputStream().- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceIResourceStream
- Throws:
IOException
- See Also:
-
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
- See Also:
-
getInputStream
Description copied from interface:IResourceStream
Gets the resource stream. You should not directly close this stream. Instead call the close() method on IResourceStream.- Specified by:
getInputStream
in interfaceIResourceStream
- Returns:
- Returns the inputStream.
- Throws:
ResourceStreamNotFoundException
- See Also:
-
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 - See Also:
-
setLastModified
- Parameters:
lastModified
- The lastModified to set.
-
getString
- Returns:
- The string resource
-
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
-