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
public abstract class AbstractStringResourceStream extends AbstractResourceStream implements IStringResourceStream
Base class for string resources.- Author:
- Jonathan Locke
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_CONTENT_TYPEThe content-type applied in case the resource stream's default constructor is used
-
Constructor Summary
Constructors Constructor Description AbstractStringResourceStream()Constructor.AbstractStringResourceStream(String contentType)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringasString()voidclose()Closes the resource.protected CharsetgetCharset()StringgetContentType()Gets the mime type of this resourceInputStreamgetInputStream()Gets the resource stream.protected abstract StringgetString()InstantlastModifiedTime()Gets the last time this modifiable thing changed.Byteslength()Gets the size of this resourcevoidsetCharset(Charset charset)Sets the character set used for reading this resource.voidsetLastModified(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 Detail
-
DEFAULT_CONTENT_TYPE
public static final String DEFAULT_CONTENT_TYPE
The content-type applied in case the resource stream's default constructor is used- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractStringResourceStream
public AbstractStringResourceStream()
Constructor.
-
AbstractStringResourceStream
public AbstractStringResourceStream(String contentType)
Constructor.- Parameters:
contentType- The mime type of this resource, such as "image/jpeg" or "text/html"
-
-
Method Detail
-
asString
public String asString()
- Specified by:
asStringin interfaceIStringResourceStream- Returns:
- This resource as a String.
-
getCharset
protected Charset getCharset()
- Returns:
- Charset for resource
-
setCharset
public void setCharset(Charset charset)
Sets the character set used for reading this resource.- Specified by:
setCharsetin interfaceIStringResourceStream- Parameters:
charset- Charset for component
-
close
public void close() throws IOException
Description copied from interface:IResourceStreamCloses the resource. Normally, this includes closing any underlying input stream returned by getInputStream().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceIResourceStream- Throws:
IOException- See Also:
IResourceStream.close()
-
getContentType
public String getContentType()
Description copied from interface:IResourceStreamGets the mime type of this resource- Specified by:
getContentTypein interfaceIResourceStream- Overrides:
getContentTypein 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:
IResourceStream.getContentType()
-
getInputStream
public InputStream getInputStream() throws ResourceStreamNotFoundException
Description copied from interface:IResourceStreamGets the resource stream. You should not directly close this stream. Instead call the close() method on IResourceStream.- Specified by:
getInputStreamin interfaceIResourceStream- Returns:
- Returns the inputStream.
- Throws:
ResourceStreamNotFoundException- See Also:
IResourceStream.getInputStream()
-
lastModifiedTime
public Instant lastModifiedTime()
Description copied from interface:IModifiableGets the last time this modifiable thing changed.- Specified by:
lastModifiedTimein interfaceIModifiable- Overrides:
lastModifiedTimein classAbstractResourceStream- Returns:
- the last modification
Timeornullif that information is not available - See Also:
IModifiable.lastModifiedTime()
-
setLastModified
public void setLastModified(Instant lastModified)
- Parameters:
lastModified- The lastModified to set.
-
length
public final Bytes length()
Description copied from interface:IResourceStreamGets the size of this resource- Specified by:
lengthin interfaceIResourceStream- Overrides:
lengthin classAbstractResourceStream- Returns:
- The size of this resource in the number of bytes, or
nullif unknown
-
-