public static class AbstractResource.ResourceResponse extends Object
Constructor and Description |
---|
ResourceResponse()
Construct.
|
Modifier and Type | Method and Description |
---|---|
boolean |
dataNeedsToBeWritten(IResource.Attributes attributes)
Check to determine if the resource data needs to be written.
|
AbstractResource.ResourceResponse |
disableCaching()
Disables caching.
|
AbstractResource.ContentRangeType |
getAcceptRange()
If the resource accepts ranges
|
Duration |
getCacheDuration()
Returns how long this resource may be cached for.
|
WebResponse.CacheScope |
getCacheScope()
returns what kind of caches are allowed to cache the resource response
resources are only cached at all if caching is enabled by setting a cache duration.
|
ContentDisposition |
getContentDisposition() |
long |
getContentLength() |
String |
getContentRange()
Gets the content range of the resource.
|
String |
getContentType() |
Integer |
getErrorCode() |
String |
getErrorMessage() |
String |
getFileName() |
HttpHeaderCollection |
getHeaders()
get custom headers
|
Time |
getLastModified() |
Integer |
getStatusCode() |
protected String |
getTextEncoding() |
AbstractResource.WriteCallback |
getWriteCallback() |
void |
setAcceptRange(AbstractResource.ContentRangeType contentRangeType)
Sets the accept range header (e.g.
|
AbstractResource.ResourceResponse |
setCacheDuration(Duration duration)
Controls how long this response may be cached.
|
AbstractResource.ResourceResponse |
setCacheDurationToMaximum()
Sets caching to maximum available duration.
|
AbstractResource.ResourceResponse |
setCacheScope(WebResponse.CacheScope scope)
controls what kind of caches are allowed to cache the response
resources are only cached at all if caching is enabled by setting a cache duration.
|
AbstractResource.ResourceResponse |
setContentDisposition(ContentDisposition contentDisposition)
Determines whether the resource will be inline or an attachment.
|
AbstractResource.ResourceResponse |
setContentLength(long contentLength)
Sets the content length (in bytes) of the data.
|
void |
setContentRange(String contentRange)
Sets the content range of the resource.
|
AbstractResource.ResourceResponse |
setContentType(String contentType)
Sets the content type for the resource.
|
AbstractResource.ResourceResponse |
setError(Integer errorCode)
Sets the error code for resource.
|
AbstractResource.ResourceResponse |
setError(Integer errorCode,
String errorMessage)
Sets the error code and message for resource.
|
AbstractResource.ResourceResponse |
setFileName(String fileName)
Sets the file name of the resource.
|
AbstractResource.ResourceResponse |
setLastModified(Time lastModified)
Sets the last modified data of the resource.
|
AbstractResource.ResourceResponse |
setStatusCode(Integer statusCode)
Sets the status code for resource.
|
AbstractResource.ResourceResponse |
setTextEncoding(String textEncoding)
Sets the text encoding for the resource.
|
AbstractResource.ResourceResponse |
setWriteCallback(AbstractResource.WriteCallback writeCallback)
Sets the
AbstractResource.WriteCallback . |
public AbstractResource.ResourceResponse setError(Integer errorCode)
errorCode
- error codethis
, for chaining.public AbstractResource.ResourceResponse setError(Integer errorCode, String errorMessage)
errorCode
- error codeerrorMessage
- error messagethis
, for chaining.public Integer getErrorCode()
null
public AbstractResource.ResourceResponse setStatusCode(Integer statusCode)
statusCode
- status codethis
, for chaining.public Integer getStatusCode()
null
public String getErrorMessage()
null
public AbstractResource.ResourceResponse setFileName(String fileName)
fileName
- file namethis
, for chaining.public String getFileName()
public AbstractResource.ResourceResponse setContentDisposition(ContentDisposition contentDisposition)
contentDisposition
- content disposition (attachment or inline)this
, for chaining.ContentDisposition
public ContentDisposition getContentDisposition()
public AbstractResource.ResourceResponse setContentType(String contentType)
contentType
- content type (also known as mime type)this
, for chaining.public String getContentType()
public String getContentRange()
public void setContentRange(String contentRange)
contentRange
- the content rangepublic AbstractResource.ContentRangeType getAcceptRange()
public void setAcceptRange(AbstractResource.ContentRangeType contentRangeType)
contentRangeType
- the content range header informationpublic AbstractResource.ResourceResponse setTextEncoding(String textEncoding)
textEncoding
- character encoding of text bodythis
, for chaining.protected String getTextEncoding()
public AbstractResource.ResourceResponse setContentLength(long contentLength)
contentLength
- length of response bodythis
, for chaining.public long getContentLength()
public AbstractResource.ResourceResponse setLastModified(Time lastModified)
If-Modified-Since
to determine if the actual data really needs to be sent
to client.lastModified
- last modification timestampthis
, for chaining.public Time getLastModified()
public boolean dataNeedsToBeWritten(IResource.Attributes attributes)
If-Modified-Since
request header and compares it to lastModified property.
In order for this method to work setLastModified(Time)
has to be called first.attributes
- request attributestrue
if the resource data does need to be written,
false
otherwise.public AbstractResource.ResourceResponse disableCaching()
this
, for chaining.public AbstractResource.ResourceResponse setCacheDurationToMaximum()
this
, for chaining.public AbstractResource.ResourceResponse setCacheDuration(Duration duration)
duration
- caching duration in secondsthis
, for chaining.public Duration getCacheDuration()
ResourceSettings.setDefaultCacheDuration(org.apache.wicket.util.time.Duration)
,
ResourceSettings.getDefaultCacheDuration()
public WebResponse.CacheScope getCacheScope()
getCacheDuration()
,
setCacheDuration(org.apache.wicket.util.time.Duration)
,
WebResponse.CacheScope
public AbstractResource.ResourceResponse setCacheScope(WebResponse.CacheScope scope)
scope
- scope for cachingthis
, for chaining.getCacheDuration()
,
setCacheDuration(org.apache.wicket.util.time.Duration)
,
WebResponse.CacheScope
public AbstractResource.ResourceResponse setWriteCallback(AbstractResource.WriteCallback writeCallback)
AbstractResource.WriteCallback
. The callback is responsible for generating the response
data.
It is necessary to set the AbstractResource.WriteCallback
if
dataNeedsToBeWritten(org.apache.wicket.request.resource.IResource.Attributes)
returns true
and setError(Integer)
has not been called.
writeCallback
- write callbackthis
, for chaining.public AbstractResource.WriteCallback getWriteCallback()
public HttpHeaderCollection getHeaders()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.