ResponseAdapterpublic class HttpServletResponseAdapter extends AbstractResponseAdapter
| Constructor | Description |
|---|---|
HttpServletResponseAdapter(javax.servlet.http.HttpServletResponse response,
Activity activity) |
Instantiates a new HttpServletResponseAdapter.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addHeader(java.lang.String name,
java.lang.String value) |
Add the given single header value to the current list of values
for the given header.
|
boolean |
containsHeader(java.lang.String name) |
Returns a boolean indicating whether the named response header
has already been set.
|
void |
flush() |
Forces any content in the buffer to be written to the client.
|
javax.servlet.http.HttpServletResponse |
getAdaptee() |
Returns the adaptee object to provide response information.
|
java.lang.String |
getContentType() |
Returns the content type used for the MIME body sent in this response.
|
java.lang.String |
getEncoding() |
Returns the name of the character encoding (MIME charset) used for the body
sent in this response.
|
java.lang.String |
getHeader(java.lang.String name) |
Returns the value of the response header with the given name.
|
java.util.Collection<java.lang.String> |
getHeaderNames() |
Returns the names of the headers of this response.
|
java.util.Collection<java.lang.String> |
getHeaders(java.lang.String name) |
Returns the values of the response header with the given name.
|
java.io.OutputStream |
getOutputStream() |
Returns a
OutputStream suitable for writing binary data in the response. |
int |
getStatus() |
Returns the status code.
|
java.io.Writer |
getWriter() |
Returns a
Writer object that can send character text to the client. |
java.lang.String |
redirect(RedirectResponseRule redirectResponseRule) |
Redirects a client to a new URL.
|
void |
redirect(java.lang.String path) |
Redirects a client to a new URL.
|
void |
setContentType(java.lang.String contentType) |
Sets the content type of the response being sent to the client,
if the response has not been committed yet.
|
void |
setEncoding(java.lang.String encoding) |
Sets the character encoding of the response being sent to the client.
|
void |
setHeader(java.lang.String name,
java.lang.String value) |
Set the given single header value under the given header name.
|
void |
setStatus(int status) |
Sets the status code.
|
public HttpServletResponseAdapter(javax.servlet.http.HttpServletResponse response,
Activity activity)
response - the HTTP responseactivity - the activitypublic javax.servlet.http.HttpServletResponse getAdaptee()
ResponseAdaptergetAdaptee in interface ResponseAdaptergetAdaptee in class AbstractResponseAdapterpublic java.lang.String getHeader(java.lang.String name)
ResponseAdapterIf a response header with the given name exists and contains multiple values, the value that was added first will be returned.
name - the name of the response header whose value to returnnull if no header with the given name has been set
on this responsepublic java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
ResponseAdaptername - the name of the response header whose values to returnCollection of the values
of the response header with the given namepublic java.util.Collection<java.lang.String> getHeaderNames()
ResponseAdapterCollection of the names
of the headers of this responsepublic boolean containsHeader(java.lang.String name)
ResponseAdaptername - the header nametrue if the named response header
has already been set; false otherwisepublic void setHeader(java.lang.String name,
java.lang.String value)
ResponseAdaptername - the header namevalue - the header value to setpublic void addHeader(java.lang.String name,
java.lang.String value)
ResponseAdaptername - the header namevalue - the header value to be addedpublic java.lang.String getEncoding()
ResponseAdapterString specifying the name of the character encoding,
for example, UTF-8public void setEncoding(java.lang.String encoding)
throws java.io.UnsupportedEncodingException
ResponseAdapterencoding - a String specifying only the character set
defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)java.io.UnsupportedEncodingException - if character encoding is not supportedpublic java.lang.String getContentType()
ResponseAdapterString specifying the content type,
for example, text/html, or nullpublic void setContentType(java.lang.String contentType)
ResponseAdaptercontentType - a String specifying the MIME type of the contentpublic java.io.OutputStream getOutputStream()
throws java.io.IOException
ResponseAdapterOutputStream suitable for writing binary data in the response.OutputStream for writing binary datajava.io.IOException - if an input or output exception occurspublic java.io.Writer getWriter()
throws java.io.IOException
ResponseAdapterWriter object that can send character text to the client.Writer object that can return character data to the clientjava.io.IOException - if an input or output exception occurspublic void flush()
throws java.io.IOException
ResponseAdapterjava.io.IOException - if an input or output exception occurspublic void redirect(java.lang.String path)
throws java.io.IOException
ResponseAdapterpath - the redirect pathjava.io.IOException - if an input or output exception occurspublic java.lang.String redirect(RedirectResponseRule redirectResponseRule) throws java.io.IOException
ResponseAdapterredirectResponseRule - the redirect response rulejava.io.IOException - if an input or output exception occurspublic int getStatus()
ResponseAdapterpublic void setStatus(int status)
ResponseAdapterstatus - the status codeCopyright © 2008–2018 The Aspectran Project. All rights reserved.