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.Copy
CACHE_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, setResponse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty
public MimeResponseWrapper(MimeResponse response)
response
- public MimeResponse getResponse()
getResponse
in class PortletResponseWrapper
public void setResponse(MimeResponse response)
response
- the response to setIllegalArgumentException
- if the response is null.public void flushBuffer() throws IOException
MimeResponse
flushBuffer
in interface MimeResponse
IOException
- if an error occurred when writing the outputMimeResponse.setBufferSize(int)
,
MimeResponse.getBufferSize()
,
MimeResponse.isCommitted()
,
MimeResponse.reset()
public int getBufferSize()
MimeResponse
getBufferSize
in interface MimeResponse
MimeResponse.setBufferSize(int)
,
MimeResponse.flushBuffer()
,
MimeResponse.isCommitted()
,
MimeResponse.reset()
public String getCharacterEncoding()
MimeResponse
See RFC 2047 for more information about character encoding and MIME.
getCharacterEncoding
in interface MimeResponse
String
specifying the name of the charset, for
example, ISO-8859-1
public 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 MimeResponse
null
if no
content type is setMimeResponse.setContentType(java.lang.String)
public Locale getLocale()
MimeResponse
getLocale
in interface MimeResponse
public OutputStream getPortletOutputStream() throws IOException
MimeResponse
OutputStream
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 MimeResponse
OutputStream
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 MimeResponse
PrintWriter
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()
MimeResponse
isCommitted
in interface MimeResponse
MimeResponse.setBufferSize(int)
,
MimeResponse.getBufferSize()
,
MimeResponse.flushBuffer()
,
MimeResponse.reset()
public void reset()
MimeResponse
IllegalStateException
.reset
in interface MimeResponse
MimeResponse.setBufferSize(int)
,
MimeResponse.getBufferSize()
,
MimeResponse.flushBuffer()
,
MimeResponse.isCommitted()
public void resetBuffer()
MimeResponse
IllegalStateException
.resetBuffer
in interface MimeResponse
MimeResponse.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 MimeResponse
size
- the preferred buffer sizeMimeResponse.getBufferSize()
,
MimeResponse.flushBuffer()
,
MimeResponse.isCommitted()
,
MimeResponse.reset()
public CacheControl getCacheControl()
MimeResponse
getCacheControl
in interface MimeResponse
public <T extends PortletURL & ActionURL> T createActionURL() throws IllegalStateException
MimeResponse
If 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 MimeResponse
IllegalStateException
public ActionURL createActionURL(MimeResponse.Copy option) throws IllegalStateException
MimeResponse
If 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 MimeResponse
option
- Specifies how current parameters are to be copied to the URLIllegalStateException
MimeResponse.Copy
public <T extends PortletURL & RenderURL> T createRenderURL() throws IllegalStateException
MimeResponse
If 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 MimeResponse
IllegalStateException
public RenderURL createRenderURL(MimeResponse.Copy option) throws IllegalStateException
MimeResponse
If 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 MimeResponse
option
- Specifies how current parameters are to be copied to the URLIllegalStateException
MimeResponse.Copy
public 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 MimeResponse
IllegalStateException
public void setContentType(String type)
MimeResponse
MimeResponse.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 MimeResponse
type
- 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.