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:
java.io.Closeable,java.io.Serializable,java.lang.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 java.lang.StringDEFAULT_CONTENT_TYPEThe content-type applied in case the resource stream's default constructor is used
-
Constructor Summary
Constructors Constructor Description AbstractStringResourceStream()Constructor.AbstractStringResourceStream(java.lang.String contentType)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.StringasString()voidclose()Closes the resource.protected java.nio.charset.CharsetgetCharset()java.lang.StringgetContentType()Gets the mime type of this resourcejava.io.InputStreamgetInputStream()Gets the resource stream.protected abstract java.lang.StringgetString()TimelastModifiedTime()Gets the last time this modifiable thing changed.Byteslength()Gets the size of this resourcevoidsetCharset(java.nio.charset.Charset charset)Sets the character set used for reading this resource.voidsetLastModified(Time 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 java.lang.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(java.lang.String contentType)
Constructor.- Parameters:
contentType- The mime type of this resource, such as "image/jpeg" or "text/html"
-
-
Method Detail
-
asString
public java.lang.String asString()
- Specified by:
asStringin interfaceIStringResourceStream- Returns:
- This resource as a String.
-
getCharset
protected java.nio.charset.Charset getCharset()
- Returns:
- Charset for resource
-
setCharset
public void setCharset(java.nio.charset.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 java.io.IOExceptionDescription copied from interface:IResourceStreamCloses the resource. Normally, this includes closing any underlying input stream returned by getInputStream().- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceIResourceStream- Throws:
java.io.IOException- See Also:
IResourceStream.close()
-
getContentType
public java.lang.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 java.io.InputStream getInputStream() throws ResourceStreamNotFoundExceptionDescription 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 Time 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(Time lastModified)
- Parameters:
lastModified- The lastModified to set.
-
getString
protected abstract java.lang.String getString()
- Returns:
- The string resource
-
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
-
-