public class ResourceResponseWrapper extends MimeResponseWrapper implements ResourceResponse
ResourceResponseWrapper
provides a convenient
implementation of the ResourceResponse
interface
that can be subclassed by developers.
This class implements the Wrapper or Decorator pattern.
Methods default to calling through to the wrapped response object.ResourceResponse
MimeResponse.Copy
HTTP_STATUS_CODE
CACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT
Constructor and Description |
---|
ResourceResponseWrapper(ResourceResponse response)
Creates an
ResourceResponse adaptor
wrapping the given response object. |
Modifier and Type | Method and Description |
---|---|
ResourceResponse |
getResponse()
Return the wrapped response object.
|
int |
getStatus()
Gets the current HTTP status code for the response.
|
void |
setCharacterEncoding(String charset)
Sets the character encoding (MIME charset) of the response being
sent to the client, for example, to UTF-8.
|
void |
setContentLength(int len)
Sets
the length of the content body in the response.
|
void |
setContentLengthLong(long len)
Sets the length of the content body in the response.
|
void |
setLocale(Locale loc)
Sets
the locale of the response, setting the headers
(including the Content-Type's charset) as appropriate.
|
void |
setResponse(ResourceResponse response)
Sets the response object being wrapped.
|
void |
setStatus(int sc)
Sets the HTTP status code for this request.
|
createActionURL, createActionURL, createRenderURL, createRenderURL, createResourceURL, flushBuffer, getBufferSize, getCacheControl, getCharacterEncoding, getContentType, getLocale, getPortletOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setContentType, setResponse
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty, setResponse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createActionURL, createActionURL, createRenderURL, createRenderURL, createResourceURL
flushBuffer, getBufferSize, getCacheControl, getCharacterEncoding, getContentType, getLocale, getPortletOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setContentType
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty
public ResourceResponseWrapper(ResourceResponse response)
ResourceResponse
adaptor
wrapping the given response object.response
- the event response to wrapIllegalArgumentException
- if the response is null
public ResourceResponse getResponse()
getResponse
in class MimeResponseWrapper
public void setResponse(ResourceResponse response)
response
- the response to setIllegalArgumentException
- if the response is null.public void setCharacterEncoding(String charset)
ResourceResponse
setContentType(java.lang.String)
or
setLocale(java.util.Locale)
, this method overrides it. Calling
setContentType(java.lang.String)
with the String of
text/html
and calling this method with the String of
UTF-8
is equivalent with calling setContentType
with the String of text/html; charset=UTF-8
.
This method can be called repeatedly to change the character encoding. This method has no effect if it is called after getWriter has been called or after the response has been committed.
setCharacterEncoding
in interface ResourceResponse
charset
- a String specifying only the character set defined by
IANA Character Sets (http://www.iana.org/assignments/character-sets)public void setLocale(Locale loc)
ResourceResponse
This method has no effect if it is called after the response has been committed.
setLocale
in interface ResourceResponse
loc
- the new locale of the responsepublic void setContentLength(int len)
ResourceResponse
This method has no effect if it is called after the response has been committed.
setContentLength
in interface ResourceResponse
len
- an integer specifying the length of the content being returned; sets the Content-Length headerpublic void setStatus(int sc)
ResourceResponse
The status code should be a valid value as defined in
IETF
rfc2616 "Hypertext Transfer Protocol -- HTTP/1.1"
. The status code constants "SC_*" defined in
HttpServletResponse
may be used.
This method has no effect if it is called after the response has been committed.
setStatus
in interface ResourceResponse
sc
- an integer specifying the status code for this requestHttpServletResponse
,
HttpServletResponse.setStatus(int)
public int getStatus()
ResourceResponse
getStatus
in interface ResourceResponse
HttpServletResponse
,
HttpServletResponse.getStatus()
public void setContentLengthLong(long len)
ResourceResponse
This method has no effect if it is called after the response has been committed.
setContentLengthLong
in interface ResourceResponse
len
- a long
specifying the length of the content being returned; sets the Content-Length headerJava Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.