|
|||||||||
| Home >> All >> org >> infohazard >> maverick >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.infohazard.maverick.util
Class FakeHttpServletResponse

java.lang.Objectjavax.servlet.ServletResponseWrapper
javax.servlet.http.HttpServletResponseWrapper
org.infohazard.maverick.util.FakeHttpServletResponse
- All Implemented Interfaces:
- javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse
- public class FakeHttpServletResponse
- extends javax.servlet.http.HttpServletResponseWrapper
Stores data written to the response and allows it to be obtained later.
| Field Summary | |
protected Buffer |
buffer
Actually holds all the output data. |
protected java.lang.String |
charset
We need to track the charset which is applied to the response using setContentType so that we can intelligently convert between streams and readers. |
private static org.apache.commons.logging.Log |
log
Logger. |
protected static java.lang.String |
NO_BUFFER_MSG
|
| Fields inherited from class javax.servlet.ServletResponseWrapper |
|
| Constructor Summary | |
FakeHttpServletResponse(javax.servlet.http.HttpServletResponse wrapMe)
Creates a response wrapper which buffers the output. |
|
| Method Summary | |
void |
addCookie(javax.servlet.http.Cookie cookie)
The default behavior of this method is to call addCookie(Cookie cookie) on the wrapped response object. |
void |
addDateHeader(java.lang.String name,
long date)
The default behavior of this method is to call addDateHeader(String name, long date) on the wrapped response object. |
void |
addHeader(java.lang.String name,
java.lang.String value)
The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object. |
void |
addIntHeader(java.lang.String name,
int value)
The default behavior of this method is to call addIntHeader(String name, int value) on the wrapped response object. |
void |
flushBuffer()
Forces any content in the buffer to be written to the client. |
protected javax.servlet.http.HttpServletResponse |
getHttpResponse()
|
java.io.Reader |
getOutputAsReader()
Provides the buffered output as a Reader. |
java.lang.String |
getOutputAsString()
Provides the buffered output as a String. |
javax.servlet.ServletOutputStream |
getOutputStream()
Returns a javax.servlet.ServletOutputStream suitable for writing binary data in the response. |
java.io.PrintWriter |
getWriter()
Returns a PrintWriter object that
can send character text to the client. |
int |
outputSize()
|
boolean |
prefersReader()
|
void |
sendError(int sc)
This actually sends to the real response and flags an error condition. |
void |
sendError(int sc,
java.lang.String msg)
This actually sends to the real response and flags an error condition. |
void |
setContentLength(int len)
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header. |
void |
setContentType(java.lang.String type)
Sets the content type of the response being sent to the client, if the response has not been committed yet. |
void |
setDateHeader(java.lang.String name,
long date)
The default behavior of this method is to call setDateHeader(String name, long date) on the wrapped response object. |
void |
setHeader(java.lang.String name,
java.lang.String value)
The default behavior of this method is to return setHeader(String name, String value) on the wrapped response object. |
void |
setIntHeader(java.lang.String name,
int value)
The default behavior of this method is to call setIntHeader(String name, int value) on the wrapped response object. |
void |
setLocale(java.util.Locale loc)
Sets the locale of the response, if the response has not been committed yet. |
void |
setStatus(int sc)
The default behavior of this method is to call setStatus(int sc) on the wrapped response object. |
void |
setStatus(int sc,
java.lang.String sm)
The default behavior of this method is to call setStatus(int sc, String sm) on the wrapped response object. |
| Methods inherited from class javax.servlet.http.HttpServletResponseWrapper |
containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, sendRedirect |
| Methods inherited from class javax.servlet.ServletResponseWrapper |
getBufferSize, getCharacterEncoding, getContentType, getLocale, getResponse, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setResponse |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.ServletResponse |
getBufferSize, getCharacterEncoding, getContentType, getLocale, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding |
| Field Detail |
log
private static org.apache.commons.logging.Log log
- Logger.
NO_BUFFER_MSG
protected static final java.lang.String NO_BUFFER_MSG
- See Also:
- Constant Field Values
charset
protected java.lang.String charset
- We need to track the charset which is applied to the response
using setContentType so that we can intelligently convert between
streams and readers. If null, the default encoding is assumed.
buffer
protected Buffer buffer
- Actually holds all the output data.
| Constructor Detail |
FakeHttpServletResponse
public FakeHttpServletResponse(javax.servlet.http.HttpServletResponse wrapMe)
- Creates a response wrapper which buffers the output.
| Method Detail |
prefersReader
public boolean prefersReader()
getOutputAsReader
public java.io.Reader getOutputAsReader() throws java.io.UnsupportedEncodingException
- Provides the buffered output as a Reader. If output was written
using a ServletOutputStream, the charset defined in the content-type
is used to decode the data. If no charset is set, the default
encoding is assumed.
getOutputAsString
public java.lang.String getOutputAsString() throws java.io.UnsupportedEncodingException
- Provides the buffered output as a String. If output was written
using a ServletOutputStream, the charset defined in the content-type
is used to decode the data. If no charset is set, the default
encoding is assumed.
outputSize
public int outputSize()
getOutputStream
public javax.servlet.ServletOutputStream getOutputStream() throws java.io.IOException
- Description copied from interface:
javax.servlet.ServletResponse - Returns a javax.servlet.ServletOutputStream suitable for writing binary
data in the response. The servlet container does not encode the
binary data.
Calling flush() on the ServletOutputStream commits the response. Either this method or ServletResponse.getWriter()>
ServletResponse.getWriter()55 may be called to write the body, not both.
getWriter
public java.io.PrintWriter getWriter() throws java.io.IOException
- Description copied from interface:
javax.servlet.ServletResponse - Returns a
PrintWriterobject that can send character text to the client. ThePrintWriteruses the character encoding returned by ServletResponse.getCharacterEncoding()>ServletResponse.getCharacterEncoding()55 . If the response's character encoding has not been specified as described ingetCharacterEncoding(i.e., the method just returns the default valueISO-8859-1),getWriterupdates it toISO-8859-1.Calling flush() on the
PrintWritercommits the response.Either this method or ServletResponse.getOutputStream()>
ServletResponse.getOutputStream()55 may be called to write the body, not both.
setContentType
public void setContentType(java.lang.String type)
- Description copied from interface:
javax.servlet.ServletResponse - Sets the content type of the response being sent to
the client, if the response has not been committed yet.
The given content type may include a character encoding
specification, for example,
text/html;charset=UTF-8. The response's character encoding is only set from the given content type if this method is called beforegetWriteris called.This method may be called repeatedly to change content type and character encoding. This method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after
getWriterhas been called or after the response has been committed.Containers must communicate the content type and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the
Content-Typeheader is used.
setContentLength
public void setContentLength(int len)
- Description copied from interface:
javax.servlet.ServletResponse - Sets the length of the content body in the response
In HTTP servlets, this method sets the HTTP Content-Length header.
flushBuffer
public void flushBuffer()
throws java.io.IOException
- Description copied from interface:
javax.servlet.ServletResponse - Forces any content in the buffer to be written to the client. A call
to this method automatically commits the response, meaning the status
code and headers will be written.
setLocale
public void setLocale(java.util.Locale loc)
- Description copied from interface:
javax.servlet.ServletResponse - Sets the locale of the response, if the response has not been
committed yet. It also sets the response's character encoding
appropriately for the locale, if the character encoding has not
been explicitly set using ServletResponse.setContentType(java.lang.String)>
ServletResponse.setContentType(java.lang.String)55 or ServletResponse.setCharacterEncoding(java.lang.String)>ServletResponse.setCharacterEncoding(java.lang.String)55 ,getWriterhasn't been called yet, and the response hasn't been committed yet. If the deployment descriptor contains alocale-encoding-mapping-listelement, and that element provides a mapping for the given locale, that mapping is used. Otherwise, the mapping from locale to character encoding is container dependent.This method may be called repeatedly to change locale and character encoding. The method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after ServletResponse.setContentType(java.lang.String)>
ServletResponse.setContentType(java.lang.String)55 has been called with a charset specification, after ServletResponse.setCharacterEncoding(java.lang.String)>ServletResponse.setCharacterEncoding(java.lang.String)55 has been called, aftergetWriterhas been called, or after the response has been committed.Containers must communicate the locale and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the locale is communicated via the
Content-Languageheader, the character encoding as part of theContent-Typeheader for text media types. Note that the character encoding cannot be communicated via HTTP headers if the servlet does not specify a content type; however, it is still used to encode text written via the servlet response's writer.
addCookie
public void addCookie(javax.servlet.http.Cookie cookie)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to call addCookie(Cookie cookie)
on the wrapped response object.
setDateHeader
public void setDateHeader(java.lang.String name, long date)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to call setDateHeader(String name, long date)
on the wrapped response object.
addDateHeader
public void addDateHeader(java.lang.String name, long date)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to call addDateHeader(String name, long date)
on the wrapped response object.
setHeader
public void setHeader(java.lang.String name, java.lang.String value)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to return setHeader(String name, String value)
on the wrapped response object.
addHeader
public void addHeader(java.lang.String name, java.lang.String value)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to return addHeader(String name, String value)
on the wrapped response object.
setIntHeader
public void setIntHeader(java.lang.String name, int value)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to call setIntHeader(String name, int value)
on the wrapped response object.
addIntHeader
public void addIntHeader(java.lang.String name, int value)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to call addIntHeader(String name, int value)
on the wrapped response object.
sendError
public void sendError(int sc)
throws java.io.IOException
- This actually sends to the real response and flags an error condition.
sendError
public void sendError(int sc,
java.lang.String msg)
throws java.io.IOException
- This actually sends to the real response and flags an error condition.
setStatus
public void setStatus(int sc)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to call setStatus(int sc)
on the wrapped response object.
setStatus
public void setStatus(int sc,
java.lang.String sm)
- Description copied from class:
javax.servlet.http.HttpServletResponseWrapper - The default behavior of this method is to call setStatus(int sc, String sm)
on the wrapped response object.
getHttpResponse
protected javax.servlet.http.HttpServletResponse getHttpResponse()
|
|||||||||
| Home >> All >> org >> infohazard >> maverick >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC