org.apache.wicket.request.resource
Class ByteArrayResource

java.lang.Object
  extended by org.apache.wicket.request.resource.AbstractResource
      extended by org.apache.wicket.request.resource.BaseDataResource<byte[]>
          extended by org.apache.wicket.request.resource.ByteArrayResource
All Implemented Interfaces:
Serializable, IResource, IClusterable

public class ByteArrayResource
extends BaseDataResource<byte[]>

An IResource for byte arrays. The byte array can be static - passed to the constructor, or dynamic - by overriding getData(org.apache.wicket.request.resource.IResource.Attributes)

Author:
Matej Knopp
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.AbstractResource
AbstractResource.ResourceResponse, AbstractResource.WriteCallback
 
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource
IResource.Attributes
 
Field Summary
 
Fields inherited from class org.apache.wicket.request.resource.AbstractResource
INTERNAL_HEADERS
 
Constructor Summary
ByteArrayResource(String contentType)
          Creates a ByteArrayResource which will provide its data dynamically with getData(org.apache.wicket.request.resource.IResource.Attributes)
ByteArrayResource(String contentType, byte[] array)
          Creates a Resource from the given byte array with its content type
ByteArrayResource(String contentType, byte[] array, String filename)
          Creates a Resource from the given byte array with its content type
 
Method Summary
protected  byte[] getData(IResource.Attributes attributes)
          Gets the data for this resource.
protected  Long getLength(byte[] data)
           
protected  void writeData(Response response, byte[] data)
          Writes the given data to the response
 
Methods inherited from class org.apache.wicket.request.resource.BaseDataResource
configureResponse, newResourceResponse
 
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, flushResponseAfterHeaders, getCachingStrategy, respond, setResponseHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayResource

public ByteArrayResource(String contentType)
Creates a ByteArrayResource which will provide its data dynamically with getData(org.apache.wicket.request.resource.IResource.Attributes)

Parameters:
contentType - The Content type of the array.

ByteArrayResource

public ByteArrayResource(String contentType,
                         byte[] array)
Creates a Resource from the given byte array with its content type

Parameters:
contentType - The Content type of the array.
array - The binary content

ByteArrayResource

public ByteArrayResource(String contentType,
                         byte[] array,
                         String filename)
Creates a Resource from the given byte array with its content type

Parameters:
contentType - The Content type of the array.
array - The binary content
filename - The filename that will be set as the Content-Disposition header.
Method Detail

getData

protected byte[] getData(IResource.Attributes attributes)
Description copied from class: BaseDataResource
Gets the data for this resource.

Overrides:
getData in class BaseDataResource<byte[]>
Parameters:
attributes - the context bringing the request, response and the parameters
Returns:
The data for this resource

writeData

protected void writeData(Response response,
                         byte[] data)
Description copied from class: BaseDataResource
Writes the given data to the response

Specified by:
writeData in class BaseDataResource<byte[]>
Parameters:
response - The response to write to
data - The data to write

getLength

protected Long getLength(byte[] data)
Specified by:
getLength in class BaseDataResource<byte[]>
Parameters:
data - The data to be written
Returns:
The length of the data to be written. Used to set "Content-Length" response header


Copyright © 2006–2016 Apache Software Foundation. All rights reserved.