public class MimeResponseWrapper extends PortletResponseWrapper implements MimeResponse
MimeResponseWrapper provides
a convenient implementation of the MimeResponse 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. MimeResponse.CopyCACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT| Constructor and Description |
|---|
MimeResponseWrapper(MimeResponse response) |
| Modifier and Type | Method and Description |
|---|---|
<T extends PortletURL & ActionURL> |
createActionURL()
Creates an action URL targeting the portlet.
|
ActionURL |
createActionURL(MimeResponse.Copy option)
Creates an action URL targeting the portlet.
|
<T extends PortletURL & RenderURL> |
createRenderURL()
Creates a render URL targeting the portlet.
|
RenderURL |
createRenderURL(MimeResponse.Copy option)
Creates a render URL targeting the portlet.
|
ResourceURL |
createResourceURL()
Creates a resource URL targeting the portlet.
|
void |
flushBuffer()
Forces any content in the buffer to be written to the underlying output stream.
|
int |
getBufferSize()
Returns the actual buffer size used for the response.
|
CacheControl |
getCacheControl()
Returns the cache control object allowing to set
specific cache settings valid for the markup
returned in this response.
|
String |
getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this
response.
|
String |
getContentType()
Returns the MIME type that can be used to contribute markup to the render
response.
|
Locale |
getLocale()
Returns the locale assigned to the response.
|
OutputStream |
getPortletOutputStream()
Returns a
OutputStream suitable for writing binary data in
the response. |
MimeResponse |
getResponse()
Return the wrapped response object.
|
PrintWriter |
getWriter()
Returns a PrintWriter object that can send character text to the portal.
|
boolean |
isCommitted()
Returns a boolean indicating if the response has been committed.
|
void |
reset()
Clears any data that exists in the buffer as well as the properties set.
|
void |
resetBuffer()
Clears the content of the underlying buffer in the response without
clearing properties set.
|
void |
setBufferSize(int size)
Sets the preferred buffer size for the body of the response.
|
void |
setContentType(String type)
Sets
the MIME type for the response.
|
void |
setResponse(MimeResponse response)
Sets the response object being wrapped.
|
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty, setResponseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setPropertypublic MimeResponseWrapper(MimeResponse response)
response - public MimeResponse getResponse()
getResponse in class PortletResponseWrapperpublic void setResponse(MimeResponse response)
response - the response to setIllegalArgumentException - if the response is null.public void flushBuffer()
throws IOException
MimeResponseflushBuffer in interface MimeResponseIOException - if an error occurred when writing the outputMimeResponse.setBufferSize(int),
MimeResponse.getBufferSize(),
MimeResponse.isCommitted(),
MimeResponse.reset()public int getBufferSize()
MimeResponsegetBufferSize in interface MimeResponseMimeResponse.setBufferSize(int),
MimeResponse.flushBuffer(),
MimeResponse.isCommitted(),
MimeResponse.reset()public String getCharacterEncoding()
MimeResponseSee RFC 2047 for more information about character encoding and MIME.
getCharacterEncoding in interface MimeResponseString specifying the name of the charset, for
example, ISO-8859-1public String getContentType()
MimeResponse
If no content type was set previously using the MimeResponse.setContentType(java.lang.String)
method this method returns null.
getContentType in interface MimeResponsenull if no
content type is setMimeResponse.setContentType(java.lang.String)public Locale getLocale()
MimeResponsegetLocale in interface MimeResponsepublic OutputStream getPortletOutputStream() throws IOException
MimeResponseOutputStream suitable for writing binary data in
the response. The portlet container does not encode the binary data.
Before calling this method the content type of the render response must
be set using the MimeResponse.setContentType(java.lang.String) method.
Calling flush() on the OutputStream commits the response.
Either this method or MimeResponse.getWriter() may be called to write the body,
not both.
getPortletOutputStream in interface MimeResponseOutputStream for writing binary dataIOException - if an input or output exception occurredMimeResponse.setContentType(java.lang.String),
MimeResponse.getWriter()public PrintWriter getWriter() throws IOException
MimeResponse
Before calling this method the content type of the render response should
be set using the MimeResponse.setContentType(java.lang.String) method.
Either this method or MimeResponse.getPortletOutputStream() may be called to
write the body, not both.
getWriter in interface MimeResponsePrintWriter object that can return character
data to the portalIOException - if an input or output exception occurredMimeResponse.setContentType(java.lang.String),
MimeResponse.getPortletOutputStream()public boolean isCommitted()
MimeResponseisCommitted in interface MimeResponseMimeResponse.setBufferSize(int),
MimeResponse.getBufferSize(),
MimeResponse.flushBuffer(),
MimeResponse.reset()public void reset()
MimeResponseIllegalStateException.reset in interface MimeResponseMimeResponse.setBufferSize(int),
MimeResponse.getBufferSize(),
MimeResponse.flushBuffer(),
MimeResponse.isCommitted()public void resetBuffer()
MimeResponseIllegalStateException.resetBuffer in interface MimeResponseMimeResponse.setBufferSize(int),
MimeResponse.getBufferSize(),
MimeResponse.isCommitted(),
MimeResponse.reset()public void setBufferSize(int size)
MimeResponse
This method must be called before any response body content is written;
if content has been written, or the portlet container does not support
buffering, this method may throw an IllegalStateException.
setBufferSize in interface MimeResponsesize - the preferred buffer sizeMimeResponse.getBufferSize(),
MimeResponse.flushBuffer(),
MimeResponse.isCommitted(),
MimeResponse.reset()public CacheControl getCacheControl()
MimeResponsegetCacheControl in interface MimeResponsepublic <T extends PortletURL & ActionURL> T createActionURL() throws IllegalStateException
MimeResponseIf a request is triggered by the URL, it results in an action request.
The returned action URL will not contain any private render parameters per default not contain any parameters from the current request.
The returned URL can be further extended by adding portlet-specific action parameters, portlet mode, and window state. If no additional portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.
Public render parameters do not need to be explicitly added to the returned action URL, unless the public render parameter value is to be changed. Any public render parameters associated with the portlet will automatically be available during action request processing resulting from activation of the URL.
If a public render parameter value is set or removed on an action URL, then the public render parameter will be set to the new value or removed when the URL is activated.
The effect of this method is the same as calling MimeResponse.createRenderURL(Copy)
with the parameter set to PUBLIC.
createActionURL in interface MimeResponseIllegalStateExceptionpublic ActionURL createActionURL(MimeResponse.Copy option) throws IllegalStateException
MimeResponseIf a request is triggered by the URL, it results in an action request.
The new action URL will contain render parameters from the
current request as specified by the option parameter.
The returned URL can be further extended by adding action parameters, portlet mode, and window state. If no additional portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.
If a public render parameter value is set or removed on an action URL, then the public render parameter will be set to the new value or removed when the URL is activated.
createActionURL in interface MimeResponseoption - Specifies how current parameters are to be copied to the URLIllegalStateExceptionMimeResponse.Copypublic <T extends PortletURL & RenderURL> T createRenderURL() throws IllegalStateException
MimeResponseIf a request is triggered by the URL, it results in a render request.
The returned render URL will not contain any private render parameters from the current request.
The created URL will per default not contain any parameters of the current render request.
The returned URL can be further extended by adding portlet-specific render parameters, portlet mode, and window state. If no portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.
If a public render parameter value is set or removed on a render URL, then the public render parameter will be set to the new value or removed when the URL is activated.
The effect of this method is the same as calling MimeResponse.createRenderURL(Copy)
with the parameter set to PUBLIC.
createRenderURL in interface MimeResponseIllegalStateExceptionpublic RenderURL createRenderURL(MimeResponse.Copy option) throws IllegalStateException
MimeResponseIf a request is triggered by the URL, it results in a render request.
The new render URL will contain render parameters from the
current request as specified by the option parameter.
If a public render parameter value is set or removed on a render URL, then the public render parameter will be set to the new value or removed when the URL is activated.
createRenderURL in interface MimeResponseoption - Specifies how current parameters are to be copied to the URLIllegalStateExceptionMimeResponse.Copypublic ResourceURL createResourceURL() throws IllegalStateException
MimeResponse
If a request is triggered by the ResourceURL, it results in a serve
resource request of the ResourceServingPortlet interface.
The security settings can be changed for the URL. If the security settings are not explicitly set, the values governing the current request are preserved. The current render parameters, portlet mode, and window state are preserved depending on the cacheability setting for the returned resource URL.
If cacheability is set to PORTLET or PAGE, the values of the render
parameters, portlet mode, and window state are preserved.
Otherwise, they will not be preserved.
If allowed by the cacheability setting, public and private render parameters are added to the URL with their current values. The render parameter values cannot be changed on the URL.
The URL can be further extended by adding portlet-specific resource parameters.
The URL will contain the current
cacheability setting of the parent resource by default.
If no parent resource is available, PAGE is the default.
ResourceServingPortlet interface.
The returned URL can be further extended by adding portlet-specific parameters .
The created URL will by default contain the current
cacheability setting of the parent resource.
If no parent resource is available, PAGE is the default.
createResourceURL in interface MimeResponseIllegalStateExceptionpublic void setContentType(String type)
MimeResponseMimeResponse.getWriter() or
MimeResponse.getPortletOutputStream().
If the content type is not set using this method, the preferred
content type as returned by PortletRequest.getResponseContentType() is used.
Calling setContentType after getWriter or
getOutputStream does not change the content type.
setContentType in interface MimeResponsetype - the content MIME typePortletRequest.getResponseContentTypes(),
MimeResponse.getContentType()Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.