Package jakarta.portlet.filter
Class ResourceResponseWrapper
- java.lang.Object
-
- jakarta.portlet.filter.PortletResponseWrapper
-
- jakarta.portlet.filter.MimeResponseWrapper
-
- jakarta.portlet.filter.ResourceResponseWrapper
-
- All Implemented Interfaces:
MimeResponse,PortletResponse,ResourceResponse
public class ResourceResponseWrapper extends MimeResponseWrapper implements ResourceResponse
TheResourceResponseWrapperprovides a convenient implementation of theResourceResponseinterface that can be subclassed by developers. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.- Since:
- 2.0
- See Also:
ResourceResponse
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.portlet.MimeResponse
MimeResponse.Copy
-
-
Field Summary
-
Fields inherited from interface jakarta.portlet.MimeResponse
CACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT
-
Fields inherited from interface jakarta.portlet.ResourceResponse
HTTP_STATUS_CODE
-
-
Constructor Summary
Constructors Constructor Description ResourceResponseWrapper(ResourceResponse response)Creates anResourceResponseadaptor wrapping the given response object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceResponsegetResponse()Return the wrapped response object.intgetStatus()Gets the current HTTP status code for the response.voidsetCharacterEncoding(String charset)Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.voidsetContentLength(int len)Sets the length of the content body in the response.voidsetContentLengthLong(long len)Sets the length of the content body in the response.voidsetLocale(Locale loc)Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.voidsetResponse(ResourceResponse response)Sets the response object being wrapped.voidsetStatus(int sc)Sets the HTTP status code for this request.-
Methods inherited from class jakarta.portlet.filter.MimeResponseWrapper
createActionURL, createActionURL, createRenderURL, createRenderURL, createResourceURL, flushBuffer, getBufferSize, getCacheControl, getCharacterEncoding, getContentType, getLocale, getPortletOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setContentType, setResponse
-
Methods inherited from class jakarta.portlet.filter.PortletResponseWrapper
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty, setResponse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.portlet.MimeResponse
flushBuffer, getBufferSize, getCacheControl, getCharacterEncoding, getContentType, getLocale, getPortletOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setContentType
-
Methods inherited from interface jakarta.portlet.PortletResponse
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty
-
Methods inherited from interface jakarta.portlet.ResourceResponse
createActionURL, createActionURL, createRenderURL, createRenderURL, createResourceURL
-
-
-
-
Constructor Detail
-
ResourceResponseWrapper
public ResourceResponseWrapper(ResourceResponse response)
Creates anResourceResponseadaptor wrapping the given response object.- Parameters:
response- the event response to wrap- Throws:
IllegalArgumentException- if the response isnull
-
-
Method Detail
-
getResponse
public ResourceResponse getResponse()
Return the wrapped response object.- Overrides:
getResponsein classMimeResponseWrapper- Returns:
- the wrapped response
-
setResponse
public void setResponse(ResourceResponse response)
Sets the response object being wrapped.- Parameters:
response- the response to set- Throws:
IllegalArgumentException- if the response is null.
-
setCharacterEncoding
public void setCharacterEncoding(String charset)
Description copied from interface:ResourceResponseSets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. If the character encoding has already been set by either the portlet container,setContentType(java.lang.String)orsetLocale(java.util.Locale), this method overrides it. CallingsetContentType(java.lang.String)with the String oftext/htmland calling this method with the String ofUTF-8is equivalent with callingsetContentTypewith the String oftext/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.
- Specified by:
setCharacterEncodingin interfaceResourceResponse- Parameters:
charset- a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)
-
setLocale
public void setLocale(Locale loc)
Description copied from interface:ResourceResponseSets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. This method should be called before a call to getWriter(). By default, the response locale is the default locale provided by the portlet container.This method has no effect if it is called after the response has been committed.
- Specified by:
setLocalein interfaceResourceResponse- Parameters:
loc- the new locale of the response
-
setContentLength
public void setContentLength(int len)
Description copied from interface:ResourceResponseSets the length of the content body in the response.This method has no effect if it is called after the response has been committed.
- Specified by:
setContentLengthin interfaceResourceResponse- Parameters:
len- an integer specifying the length of the content being returned; sets the Content-Length header
-
setStatus
public void setStatus(int sc)
Description copied from interface:ResourceResponseSets the HTTP status code for this request.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
HttpServletResponsemay be used.This method has no effect if it is called after the response has been committed.
- Specified by:
setStatusin interfaceResourceResponse- Parameters:
sc- an integer specifying the status code for this request- See Also:
HttpServletResponse,HttpServletResponse.setStatus(int)
-
getStatus
public int getStatus()
Description copied from interface:ResourceResponseGets the current HTTP status code for the response.- Specified by:
getStatusin interfaceResourceResponse- Returns:
- The HTTP status code
- See Also:
HttpServletResponse,HttpServletResponse.getStatus()
-
setContentLengthLong
public void setContentLengthLong(long len)
Description copied from interface:ResourceResponseSets the length of the content body in the response.This method has no effect if it is called after the response has been committed.
- Specified by:
setContentLengthLongin interfaceResourceResponse- Parameters:
len- alongspecifying the length of the content being returned; sets the Content-Length header
-
-