Package org.apache.wicket.util.resource
Class AbstractResourceStreamWriter
- java.lang.Object
-
- org.apache.wicket.util.resource.AbstractResourceStreamWriter
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,IClusterable
,IResourceStream
,IResourceStreamWriter
,IModifiable
- Direct Known Subclasses:
ExportToolbar.DataExportResourceStreamWriter
public abstract class AbstractResourceStreamWriter extends Object implements IResourceStreamWriter
Base implementation of an IResourceStreamWriter so that you only have to override theIResourceStreamWriter.write(java.io.OutputStream)
. Don't forget to overwrite theIResourceStream.length()
method if you do know the total length that will be generated.- See Also:
IResourceStreamWriter
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceStreamWriter()
-
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()
this method should not be used as it is not required for resource writersLocale
getLocale()
String
getStyle()
String
getVariation()
Instant
lastModifiedTime()
Just returns now.Bytes
length()
Default implementation to returnsnull
, i.e.void
setLocale(Locale locale)
This method shouldn't be used from the outside.void
setStyle(String style)
This method shouldn't be used from the outside.void
setVariation(String variation)
This method shouldn't be used from the outside.-
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.IResourceStreamWriter
write
-
-
-
-
Constructor Detail
-
AbstractResourceStreamWriter
public AbstractResourceStreamWriter()
-
-
Method Detail
-
length
public Bytes length()
Default implementation to returnsnull
, i.e. chunked-encoding will be used. Do override this if you know the length up front.- Specified by:
length
in interfaceIResourceStream
- Returns:
- The size of this resource in the number of bytes, or
null
if unknown
-
getLocale
public Locale getLocale()
- Specified by:
getLocale
in interfaceIResourceStream
- Returns:
- The Locale where this stream did resolve to
-
setLocale
public void setLocale(Locale locale)
Description copied from interface:IResourceStream
This method shouldn't be used from the outside. It is used by the Loaders to set the resolved locale.- Specified by:
setLocale
in interfaceIResourceStream
- Parameters:
locale
- The Locale where this stream did resolve to.
-
lastModifiedTime
public Instant lastModifiedTime()
Just returns now.- Specified by:
lastModifiedTime
in interfaceIModifiable
- Returns:
- the last modification
Time
ornull
if that information is not available
-
getInputStream
public final InputStream getInputStream()
this method should not be used as it is not required for resource writers- Specified by:
getInputStream
in interfaceIResourceStream
- Returns:
- Returns the inputStream.
- See Also:
IResourceStream.close()
-
close
public void close() throws IOException
Closes the resource. Normally, this includes closing any underlying input stream returned by getInputStream().This implementation does nothing.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceIResourceStream
- Throws:
IOException
- if an error occurred.
-
getContentType
public String getContentType()
Description copied from interface:IResourceStream
Gets the mime type of this resource- Specified by:
getContentType
in interfaceIResourceStream
- Returns:
- The mime type of this resource, such as "image/jpeg" or "text/html". Return null to let ResourceStreamRequestHandler handle the Content-Type automatically
-
getStyle
public String getStyle()
- Specified by:
getStyle
in interfaceIResourceStream
- Returns:
- The Style where this stream did resolve to
-
setStyle
public void setStyle(String style)
Description copied from interface:IResourceStream
This method shouldn't be used from the outside. It is used by the Loaders to set the resolved Style.- Specified by:
setStyle
in interfaceIResourceStream
- Parameters:
style
- The style where this stream did resolve to.
-
getVariation
public String getVariation()
- Specified by:
getVariation
in interfaceIResourceStream
- Returns:
- The Variation where this stream did resolve to
-
setVariation
public void setVariation(String variation)
Description copied from interface:IResourceStream
This method shouldn't be used from the outside. It is used by the Loaders to set the resolved variation.- Specified by:
setVariation
in interfaceIResourceStream
- Parameters:
variation
- The Variation where this stream did resolve to.
-
-