Package javax.portlet.filter
Class ResourceResponseWrapper
- java.lang.Object
-
- javax.portlet.filter.PortletResponseWrapper
-
- javax.portlet.filter.ResourceResponseWrapper
-
- All Implemented Interfaces:
MimeResponse,PortletResponse,ResourceResponse
public class ResourceResponseWrapper extends PortletResponseWrapper implements ResourceResponse
TheResourceResponseWrapperprovides a convenient implementation of theResourceResponseinterface that can be subclassed by developers wishing to adapt the response. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.- Since:
- 2.0
- See Also:
ResourceResponse
-
-
Field Summary
-
Fields inherited from interface javax.portlet.MimeResponse
CACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT
-
Fields inherited from interface javax.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 PortletURLcreateActionURL()The default behavior of this method is to callcreateActionURL()on the wrapped response object.PortletURLcreateRenderURL()The default behavior of this method is to callcreateRenderURL()on the wrapped response object.ResourceURLcreateResourceURL()The default behavior of this method is to callcreateResourceURL()on the wrapped response object.voidflushBuffer()The default behavior of this method is to callflushBuffer()on the wrapped response object.intgetBufferSize()The default behavior of this method is to callgetBufferSize()on the wrapped response object.CacheControlgetCacheControl()The default behavior of this method is to callgetCacheControl()on the wrapped response object.java.lang.StringgetCharacterEncoding()The default behavior of this method is to callgetCharacterEncoding()on the wrapped response object.java.lang.StringgetContentType()The default behavior of this method is to callgetContentType()on the wrapped response object.java.util.LocalegetLocale()The default behavior of this method is to callgetLocale()on the wrapped response object.java.io.OutputStreamgetPortletOutputStream()The default behavior of this method is to callgetPortletOutputStream()on the wrapped response object.ResourceResponsegetResponse()Return the wrapped response object.java.io.PrintWritergetWriter()The default behavior of this method is to callgetWriter()on the wrapped response object.booleanisCommitted()The default behavior of this method is to callisCommitted()on the wrapped response object.voidreset()The default behavior of this method is to callreset()on the wrapped response object.voidresetBuffer()The default behavior of this method is to callresetBuffer()on the wrapped response object.voidsetBufferSize(int size)The default behavior of this method is to callsetBufferSize(size)on the wrapped response object.voidsetCharacterEncoding(java.lang.String charset)The default behavior of this method is to callsetCharacterEncoding(String charset)on the wrapped response object.voidsetContentLength(int len)The default behavior of this method is to callsetContentLength()on the wrapped response object.voidsetContentType(java.lang.String type)The default behavior of this method is to callsetContentType(type)on the wrapped response object.voidsetLocale(java.util.Locale loc)The default behavior of this method is to callsetLocale(Locale loc)on the wrapped response object.voidsetResponse(ResourceResponse response)Sets the response object being wrapped.-
Methods inherited from class javax.portlet.filter.PortletResponseWrapper
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, setProperty, setResponse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.portlet.PortletResponse
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, setProperty
-
-
-
-
Constructor Detail
-
ResourceResponseWrapper
public ResourceResponseWrapper(ResourceResponse response)
Creates anResourceResponseadaptor wrapping the given response object.- Parameters:
response- the event response to wrap- Throws:
java.lang.IllegalArgumentException- if the response isnull
-
-
Method Detail
-
flushBuffer
public void flushBuffer() throws java.io.IOExceptionThe default behavior of this method is to callflushBuffer()on the wrapped response object.- Specified by:
flushBufferin interfaceMimeResponse- Throws:
java.io.IOException- if an error occurred when writing the output- See Also:
MimeResponse.setBufferSize(int),MimeResponse.getBufferSize(),MimeResponse.isCommitted(),MimeResponse.reset()
-
getBufferSize
public int getBufferSize()
The default behavior of this method is to callgetBufferSize()on the wrapped response object.- Specified by:
getBufferSizein interfaceMimeResponse- Returns:
- the actual buffer size used
- See Also:
MimeResponse.setBufferSize(int),MimeResponse.flushBuffer(),MimeResponse.isCommitted(),MimeResponse.reset()
-
getCharacterEncoding
public java.lang.String getCharacterEncoding()
The default behavior of this method is to callgetCharacterEncoding()on the wrapped response object.- Specified by:
getCharacterEncodingin interfaceMimeResponse- Returns:
- a
Stringspecifying the name of the charset, for example,ISO-8859-1
-
getContentType
public java.lang.String getContentType()
The default behavior of this method is to callgetContentType()on the wrapped response object.- Specified by:
getContentTypein interfaceMimeResponse- Returns:
- the MIME type of the response, or
nullif no content type is set - See Also:
MimeResponse.setContentType(java.lang.String)
-
getLocale
public java.util.Locale getLocale()
The default behavior of this method is to callgetLocale()on the wrapped response object.- Specified by:
getLocalein interfaceMimeResponse- Returns:
- Locale of this response
-
getPortletOutputStream
public java.io.OutputStream getPortletOutputStream() throws java.io.IOExceptionThe default behavior of this method is to callgetPortletOutputStream()on the wrapped response object.- Specified by:
getPortletOutputStreamin interfaceMimeResponse- Returns:
- a
OutputStreamfor writing binary data - Throws:
java.io.IOException- if an input or output exception occurred- See Also:
MimeResponse.setContentType(java.lang.String),MimeResponse.getWriter()
-
getWriter
public java.io.PrintWriter getWriter() throws java.io.IOExceptionThe default behavior of this method is to callgetWriter()on the wrapped response object.- Specified by:
getWriterin interfaceMimeResponse- Returns:
- a
PrintWriterobject that can return character data to the portal - Throws:
java.io.IOException- if an input or output exception occurred- See Also:
MimeResponse.setContentType(java.lang.String),MimeResponse.getPortletOutputStream()
-
isCommitted
public boolean isCommitted()
The default behavior of this method is to callisCommitted()on the wrapped response object.- Specified by:
isCommittedin interfaceMimeResponse- Returns:
- a boolean indicating if the response has been committed
- See Also:
MimeResponse.setBufferSize(int),MimeResponse.getBufferSize(),MimeResponse.flushBuffer(),MimeResponse.reset()
-
reset
public void reset()
The default behavior of this method is to callreset()on the wrapped response object.- Specified by:
resetin interfaceMimeResponse- See Also:
MimeResponse.setBufferSize(int),MimeResponse.getBufferSize(),MimeResponse.flushBuffer(),MimeResponse.isCommitted()
-
resetBuffer
public void resetBuffer()
The default behavior of this method is to callresetBuffer()on the wrapped response object.- Specified by:
resetBufferin interfaceMimeResponse- See Also:
MimeResponse.setBufferSize(int),MimeResponse.getBufferSize(),MimeResponse.isCommitted(),MimeResponse.reset()
-
setBufferSize
public void setBufferSize(int size)
The default behavior of this method is to callsetBufferSize(size)on the wrapped response object.- Specified by:
setBufferSizein interfaceMimeResponse- Parameters:
size- the preferred buffer size- See Also:
MimeResponse.getBufferSize(),MimeResponse.flushBuffer(),MimeResponse.isCommitted(),MimeResponse.reset()
-
setContentType
public void setContentType(java.lang.String type)
The default behavior of this method is to callsetContentType(type)on the wrapped response object.- Specified by:
setContentTypein interfaceMimeResponse- Parameters:
type- the content MIME type- See Also:
PortletRequest.getResponseContentTypes(),MimeResponse.getContentType()
-
getCacheControl
public CacheControl getCacheControl()
The default behavior of this method is to callgetCacheControl()on the wrapped response object.- Specified by:
getCacheControlin interfaceMimeResponse- Returns:
- Cache control for the current response.
-
setCharacterEncoding
public void setCharacterEncoding(java.lang.String charset)
The default behavior of this method is to callsetCharacterEncoding(String charset)on the wrapped response object.- 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(java.util.Locale loc)
The default behavior of this method is to callsetLocale(Locale loc)on the wrapped response object.- Specified by:
setLocalein interfaceResourceResponse- Parameters:
loc- the new locale of the response
-
setContentLength
public void setContentLength(int len)
The default behavior of this method is to callsetContentLength()on the wrapped response object.- Specified by:
setContentLengthin interfaceResourceResponse- Parameters:
len- an integer specifying the length of the content being returned
-
getResponse
public ResourceResponse getResponse()
Return the wrapped response object.- Overrides:
getResponsein classPortletResponseWrapper- Returns:
- the wrapped response
-
setResponse
public void setResponse(ResourceResponse response)
Sets the response object being wrapped.- Parameters:
response- the response to set- Throws:
java.lang.IllegalArgumentException- if the response is null.
-
createActionURL
public PortletURL createActionURL() throws java.lang.IllegalStateException
The default behavior of this method is to callcreateActionURL()on the wrapped response object.- Specified by:
createActionURLin interfaceMimeResponse- Specified by:
createActionURLin interfaceResourceResponse- Returns:
- a portlet action URL
- Throws:
java.lang.IllegalStateException- if the cacheability level of the resource URL triggering thisserveResourcecall is notPAGEand thus does not allow for creating action URLs.
-
createRenderURL
public PortletURL createRenderURL() throws java.lang.IllegalStateException
The default behavior of this method is to callcreateRenderURL()on the wrapped response object.- Specified by:
createRenderURLin interfaceMimeResponse- Specified by:
createRenderURLin interfaceResourceResponse- Returns:
- a portlet render URL
- Throws:
java.lang.IllegalStateException- if the cacheability level of the resource URL triggering thisserveResourcecall is notPAGEand thus does not allow for creating render URLs.
-
createResourceURL
public ResourceURL createResourceURL() throws java.lang.IllegalStateException
The default behavior of this method is to callcreateResourceURL()on the wrapped response object.- Specified by:
createResourceURLin interfaceMimeResponse- Specified by:
createResourceURLin interfaceResourceResponse- Returns:
- a portlet resource URL
- Throws:
java.lang.IllegalStateException- if the cacheability level of the resource URL triggering thisserveResourcecall, or one of the parent calls, have defined a stricter cachability level.
-
-