javax.portlet.filter
Class ResourceResponseWrapper

java.lang.Object
  extended by javax.portlet.filter.PortletResponseWrapper
      extended by javax.portlet.filter.ResourceResponseWrapper
All Implemented Interfaces
MimeResponse, PortletResponse, ResourceResponse

public class ResourceResponseWrapper
extends PortletResponseWrapper
implements ResourceResponse

The ResourceResponseWrapper provides a convenient implementation of the ResourceResponse 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.ResourceResponse
HTTP_STATUS_CODE
 
Fields inherited from interface javax.portlet.MimeResponse
CACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT
 
Constructor Summary
ResourceResponseWrapper(ResourceResponse response)
          Creates an ResourceResponse adaptor wrapping the given response object.
 
Method Summary
 PortletURL createActionURL()
          The default behavior of this method is to call createActionURL() on the wrapped response object.
 PortletURL createRenderURL()
          The default behavior of this method is to call createRenderURL() on the wrapped response object.
 ResourceURL createResourceURL()
          The default behavior of this method is to call createResourceURL() on the wrapped response object.
 void flushBuffer()
          The default behavior of this method is to call flushBuffer() on the wrapped response object.
 int getBufferSize()
          The default behavior of this method is to call getBufferSize() on the wrapped response object.
 CacheControl getCacheControl()
          The default behavior of this method is to call getCacheControl() on the wrapped response object.
 String getCharacterEncoding()
          The default behavior of this method is to call getCharacterEncoding() on the wrapped response object.
 String getContentType()
          The default behavior of this method is to call getContentType() on the wrapped response object.
 Locale getLocale()
          The default behavior of this method is to call getLocale() on the wrapped response object.
 OutputStream getPortletOutputStream()
          The default behavior of this method is to call getPortletOutputStream() on the wrapped response object.
 ResourceResponse getResponse()
          Return the wrapped response object.
 PrintWriter getWriter()
          The default behavior of this method is to call getWriter() on the wrapped response object.
 boolean isCommitted()
          The default behavior of this method is to call isCommitted() on the wrapped response object.
 void reset()
          The default behavior of this method is to call reset() on the wrapped response object.
 void resetBuffer()
          The default behavior of this method is to call resetBuffer() on the wrapped response object.
 void setBufferSize(int size)
          The default behavior of this method is to call setBufferSize(size) on the wrapped response object.
 void setCharacterEncoding(String charset)
          The default behavior of this method is to call setCharacterEncoding(String charset) on the wrapped response object.
 void setContentLength(int len)
          The default behavior of this method is to call setContentLength() on the wrapped response object.
 void setContentType(String type)
          The default behavior of this method is to call setContentType(type) on the wrapped response object.
 void setLocale(Locale loc)
          The default behavior of this method is to call setLocale(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 an ResourceResponse adaptor wrapping the given response object.

Parameters
response - the event response to wrap
Throws
IllegalArgumentException - if the response is null
Method Detail

flushBuffer

public void flushBuffer()
                 throws IOException
The default behavior of this method is to call flushBuffer() on the wrapped response object.

Specified by:
flushBuffer in interface MimeResponse
Throws
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 call getBufferSize() on the wrapped response object.

Specified by:
getBufferSize in interface MimeResponse
Returns
the actual buffer size used
See Also
MimeResponse.setBufferSize(int), MimeResponse.flushBuffer(), MimeResponse.isCommitted(), MimeResponse.reset()

getCharacterEncoding

public String getCharacterEncoding()
The default behavior of this method is to call getCharacterEncoding() on the wrapped response object.

Specified by:
getCharacterEncoding in interface MimeResponse
Returns
a String specifying the name of the charset, for example, ISO-8859-1

getContentType

public String getContentType()
The default behavior of this method is to call getContentType() on the wrapped response object.

Specified by:
getContentType in interface MimeResponse
Returns
the MIME type of the response, or null if no content type is set
See Also
MimeResponse.setContentType(java.lang.String)

getLocale

public Locale getLocale()
The default behavior of this method is to call getLocale() on the wrapped response object.

Specified by:
getLocale in interface MimeResponse
Returns
Locale of this response

getPortletOutputStream

public OutputStream getPortletOutputStream()
                                    throws IOException
The default behavior of this method is to call getPortletOutputStream() on the wrapped response object.

Specified by:
getPortletOutputStream in interface MimeResponse
Returns
a OutputStream for writing binary data
Throws
IOException - if an input or output exception occurred
See Also
MimeResponse.setContentType(java.lang.String), MimeResponse.getWriter()

getWriter

public PrintWriter getWriter()
                      throws IOException
The default behavior of this method is to call getWriter() on the wrapped response object.

Specified by:
getWriter in interface MimeResponse
Returns
a PrintWriter object that can return character data to the portal
Throws
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 call isCommitted() on the wrapped response object.

Specified by:
isCommitted in interface MimeResponse
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 call reset() on the wrapped response object.

Specified by:
reset in interface MimeResponse
See Also
MimeResponse.setBufferSize(int), MimeResponse.getBufferSize(), MimeResponse.flushBuffer(), MimeResponse.isCommitted()

resetBuffer

public void resetBuffer()
The default behavior of this method is to call resetBuffer() on the wrapped response object.

Specified by:
resetBuffer in interface MimeResponse
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 call setBufferSize(size) on the wrapped response object.

Specified by:
setBufferSize in interface MimeResponse
Parameters
size - the preferred buffer size
See Also
MimeResponse.getBufferSize(), MimeResponse.flushBuffer(), MimeResponse.isCommitted(), MimeResponse.reset()

setContentType

public void setContentType(String type)
The default behavior of this method is to call setContentType(type) on the wrapped response object.

Specified by:
setContentType in interface MimeResponse
Parameters
type - the content MIME type
See Also
PortletRequest.getResponseContentTypes(), MimeResponse.getContentType()

getCacheControl

public CacheControl getCacheControl()
The default behavior of this method is to call getCacheControl() on the wrapped response object.

Specified by:
getCacheControl in interface MimeResponse
Returns
Cache control for the current response.

setCharacterEncoding

public void setCharacterEncoding(String charset)
The default behavior of this method is to call setCharacterEncoding(String charset) on the wrapped response object.

Specified by:
setCharacterEncoding in interface ResourceResponse
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)
The default behavior of this method is to call setLocale(Locale loc) on the wrapped response object.

Specified by:
setLocale in interface ResourceResponse
Parameters
loc - the new locale of the response

setContentLength

public void setContentLength(int len)
The default behavior of this method is to call setContentLength() on the wrapped response object.

Specified by:
setContentLength in interface ResourceResponse
Parameters
len - an integer specifying the length of the content being returned

getResponse

public ResourceResponse getResponse()
Return the wrapped response object.

Overrides:
getResponse in class PortletResponseWrapper
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.

createActionURL

public PortletURL createActionURL()
                           throws IllegalStateException
The default behavior of this method is to call createActionURL() on the wrapped response object.

Specified by:
createActionURL in interface MimeResponse
Specified by:
createActionURL in interface ResourceResponse
Returns
a portlet action URL
Throws
IllegalStateException - if the cacheability level of the resource URL triggering this serveResource call is not PAGE and thus does not allow for creating action URLs.

createRenderURL

public PortletURL createRenderURL()
                           throws IllegalStateException
The default behavior of this method is to call createRenderURL() on the wrapped response object.

Specified by:
createRenderURL in interface MimeResponse
Specified by:
createRenderURL in interface ResourceResponse
Returns
a portlet render URL
Throws
IllegalStateException - if the cacheability level of the resource URL triggering this serveResource call is not PAGE and thus does not allow for creating render URLs.

createResourceURL

public ResourceURL createResourceURL()
                              throws IllegalStateException
The default behavior of this method is to call createResourceURL() on the wrapped response object.

Specified by:
createResourceURL in interface MimeResponse
Specified by:
createResourceURL in interface ResourceResponse
Returns
a portlet resource URL
Throws
IllegalStateException - if the cacheability level of the resource URL triggering this serveResource call, or one of the parent calls, have defined a stricter cachability level.


Copyright © 2011, Oracle. All rights reserved.