Class ByteArrayResource
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- org.apache.wicket.request.resource.BaseDataResource<byte[]>
-
- org.apache.wicket.request.resource.ByteArrayResource
-
- All Implemented Interfaces:
java.io.Serializable,IResource,org.apache.wicket.util.io.IClusterable
public class ByteArrayResource extends BaseDataResource<byte[]>
AnIResourcefor byte arrays. The byte array can be static - passed to the constructor, or dynamic - by overridingBaseDataResource.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.ContentRangeType, 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
CONTENT_DISPOSITION_HEADER_NAME, CONTENT_RANGE_ENDBYTE, CONTENT_RANGE_STARTBYTE, INTERNAL_HEADERS
-
-
Constructor Summary
Constructors Constructor Description ByteArrayResource(java.lang.String contentType)Creates aByteArrayResourcewhich will provide its data dynamically withBaseDataResource.getData(org.apache.wicket.request.resource.IResource.Attributes)ByteArrayResource(java.lang.String contentType, byte[] array)Creates a Resource from the given byte array with its content typeByteArrayResource(java.lang.String contentType, byte[] array, java.lang.String filename)Creates a Resource from the given byte array with its content type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.LonggetLength(byte[] data)protected voidwriteData(org.apache.wicket.request.Response response, byte[] data)Writes the given data to the response-
Methods inherited from class org.apache.wicket.request.resource.BaseDataResource
configureResponse, getData, getFilename, newResourceResponse
-
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, getCachingStrategy, respond, setRequestMetaData, setRequestRangeMetaData, setResponseContentRangeHeaderFields, setResponseHeaders
-
-
-
-
Constructor Detail
-
ByteArrayResource
public ByteArrayResource(java.lang.String contentType)
Creates aByteArrayResourcewhich will provide its data dynamically withBaseDataResource.getData(org.apache.wicket.request.resource.IResource.Attributes)- Parameters:
contentType- The Content type of the array.
-
ByteArrayResource
public ByteArrayResource(java.lang.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(java.lang.String contentType, byte[] array, java.lang.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 contentfilename- The filename that will be set as the Content-Disposition header.
-
-
Method Detail
-
writeData
protected void writeData(org.apache.wicket.request.Response response, byte[] data)Description copied from class:BaseDataResourceWrites the given data to the response- Specified by:
writeDatain classBaseDataResource<byte[]>- Parameters:
response- The response to write todata- The data to write
-
getLength
protected java.lang.Long getLength(byte[] data)
- Specified by:
getLengthin classBaseDataResource<byte[]>- Parameters:
data- The data to be written- Returns:
- The length of the data to be written. Used to set "Content-Length" response header
-
-