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
TheResourceResponseWrapper
provides a convenient implementation of theResourceResponse
interface 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 anResourceResponse
adaptor wrapping the given response object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PortletURL
createActionURL()
The default behavior of this method is to callcreateActionURL()
on the wrapped response object.PortletURL
createRenderURL()
The default behavior of this method is to callcreateRenderURL()
on the wrapped response object.ResourceURL
createResourceURL()
The default behavior of this method is to callcreateResourceURL()
on the wrapped response object.void
flushBuffer()
The default behavior of this method is to callflushBuffer()
on the wrapped response object.int
getBufferSize()
The default behavior of this method is to callgetBufferSize()
on the wrapped response object.CacheControl
getCacheControl()
The default behavior of this method is to callgetCacheControl()
on the wrapped response object.java.lang.String
getCharacterEncoding()
The default behavior of this method is to callgetCharacterEncoding()
on the wrapped response object.java.lang.String
getContentType()
The default behavior of this method is to callgetContentType()
on the wrapped response object.java.util.Locale
getLocale()
The default behavior of this method is to callgetLocale()
on the wrapped response object.java.io.OutputStream
getPortletOutputStream()
The default behavior of this method is to callgetPortletOutputStream()
on the wrapped response object.ResourceResponse
getResponse()
Return the wrapped response object.java.io.PrintWriter
getWriter()
The default behavior of this method is to callgetWriter()
on the wrapped response object.boolean
isCommitted()
The default behavior of this method is to callisCommitted()
on the wrapped response object.void
reset()
The default behavior of this method is to callreset()
on the wrapped response object.void
resetBuffer()
The default behavior of this method is to callresetBuffer()
on the wrapped response object.void
setBufferSize(int size)
The default behavior of this method is to callsetBufferSize(size)
on the wrapped response object.void
setCharacterEncoding(java.lang.String charset)
The default behavior of this method is to callsetCharacterEncoding(String charset)
on the wrapped response object.void
setContentLength(int len)
The default behavior of this method is to callsetContentLength()
on the wrapped response object.void
setContentType(java.lang.String type)
The default behavior of this method is to callsetContentType(type)
on the wrapped response object.void
setLocale(java.util.Locale loc)
The default behavior of this method is to callsetLocale(Locale loc)
on the wrapped response object.void
setResponse(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 anResourceResponse
adaptor 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.IOException
The default behavior of this method is to callflushBuffer()
on the wrapped response object.- Specified by:
flushBuffer
in 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:
getBufferSize
in 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:
getCharacterEncoding
in interfaceMimeResponse
- Returns:
- a
String
specifying 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:
getContentType
in interfaceMimeResponse
- Returns:
- the MIME type of the response, or
null
if 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:
getLocale
in interfaceMimeResponse
- Returns:
- Locale of this response
-
getPortletOutputStream
public java.io.OutputStream getPortletOutputStream() throws java.io.IOException
The default behavior of this method is to callgetPortletOutputStream()
on the wrapped response object.- Specified by:
getPortletOutputStream
in interfaceMimeResponse
- Returns:
- a
OutputStream
for 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.IOException
The default behavior of this method is to callgetWriter()
on the wrapped response object.- Specified by:
getWriter
in interfaceMimeResponse
- Returns:
- a
PrintWriter
object 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:
isCommitted
in 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:
reset
in 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:
resetBuffer
in 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:
setBufferSize
in 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:
setContentType
in 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:
getCacheControl
in 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:
setCharacterEncoding
in 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:
setLocale
in 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:
setContentLength
in interfaceResourceResponse
- Parameters:
len
- an integer specifying the length of the content being returned
-
getResponse
public ResourceResponse getResponse()
Return the wrapped response object.- Overrides:
getResponse
in 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:
createActionURL
in interfaceMimeResponse
- Specified by:
createActionURL
in interfaceResourceResponse
- Returns:
- a portlet action URL
- Throws:
java.lang.IllegalStateException
- if the cacheability level of the resource URL triggering thisserveResource
call is notPAGE
and 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:
createRenderURL
in interfaceMimeResponse
- Specified by:
createRenderURL
in interfaceResourceResponse
- Returns:
- a portlet render URL
- Throws:
java.lang.IllegalStateException
- if the cacheability level of the resource URL triggering thisserveResource
call is notPAGE
and 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:
createResourceURL
in interfaceMimeResponse
- Specified by:
createResourceURL
in interfaceResourceResponse
- Returns:
- a portlet resource URL
- Throws:
java.lang.IllegalStateException
- if the cacheability level of the resource URL triggering thisserveResource
call, or one of the parent calls, have defined a stricter cachability level.
-
-