|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.servlet.ServletResponseWrapper
javax.servlet.http.HttpServletResponseWrapper
jodd.decora.BufferResponseWrapper
public class BufferResponseWrapper
Buffered servlet response wrapper.
| Field Summary | |
|---|---|
protected Buffer |
buffer
|
protected static java.lang.String |
CONTENT_LENGTH
|
protected static java.lang.String |
CONTENT_TYPE
|
protected static java.lang.String |
LAST_MODIFIED
|
protected LastModifiedData |
lastModifiedData
|
| Fields inherited from interface javax.servlet.http.HttpServletResponse |
|---|
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY |
| Constructor Summary | |
|---|---|
BufferResponseWrapper(javax.servlet.http.HttpServletResponse originalResponse,
LastModifiedData lastModifiedData)
|
|
| Method Summary | |
|---|---|
void |
addDateHeader(java.lang.String name,
long value)
|
void |
addHeader(java.lang.String name,
java.lang.String value)
Prevents setting content-length if buffering enabled. |
void |
addIntHeader(java.lang.String name,
int value)
Prevents setting content-length if buffering enabled. |
protected boolean |
bufferContentType(java.lang.String contentType,
java.lang.String mimeType,
java.lang.String encoding)
Determines if some content type has to be buffered. |
protected boolean |
bufferStatusCode(int statusCode)
Determines if buffering should be used for some HTTP status code. |
protected void |
disableBuffering()
Disables buffering by transferring the output to original destinations. |
protected void |
enableBuffering()
Enables buffering by transferring the output to the buffer. |
void |
flushBuffer()
Prevents flushing buffer if buffering enabled. |
byte[] |
getBufferedBytes()
Returns buffered bytes or null if buffering was not enabled. |
char[] |
getBufferedChars()
Returns buffered content or null if buffering was not enabled. |
javax.servlet.ServletOutputStream |
getOutputStream()
Returns buffered output stream if buffering is enabled, otherwise returns the original stream. |
java.io.PrintWriter |
getWriter()
Returns buffered writer if buffering is enabled, otherwise returns the original writer. |
boolean |
isBufferingEnabled()
Returns true if buffering is enabled. |
boolean |
isBufferStreamBased()
Returns true if underlying buffer was written to
using getOutputStream() (as opposed to getWriter(). |
protected void |
preResponseCommit()
Called just before stream or writer is accessed. |
void |
sendError(int statusCode)
|
void |
sendError(int statusCode,
java.lang.String reason)
|
void |
sendRedirect(java.lang.String location)
|
void |
setContentLength(int contentLength)
Prevents content-length being set if buffering enabled. |
void |
setContentType(java.lang.String type)
Sets the content type and enables or disables buffering. |
void |
setDateHeader(java.lang.String name,
long value)
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Prevents setting content-length fif buffering enabled. |
void |
setIntHeader(java.lang.String name,
int value)
Prevents setting content-length if buffering enabled. |
void |
setStatus(int statusCode)
|
void |
setStatus(int statusCode,
java.lang.String reason)
|
protected void |
stopBufferingForStatusCode(int statusCode)
|
| Methods inherited from class javax.servlet.http.HttpServletResponseWrapper |
|---|
addCookie, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL |
| Methods inherited from class javax.servlet.ServletResponseWrapper |
|---|
getBufferSize, getCharacterEncoding, getContentType, getLocale, getResponse, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setLocale, 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, setLocale |
| Field Detail |
|---|
protected static final java.lang.String CONTENT_TYPE
protected static final java.lang.String CONTENT_LENGTH
protected static final java.lang.String LAST_MODIFIED
protected final LastModifiedData lastModifiedData
protected Buffer buffer
| Constructor Detail |
|---|
public BufferResponseWrapper(javax.servlet.http.HttpServletResponse originalResponse,
LastModifiedData lastModifiedData)
| Method Detail |
|---|
protected void preResponseCommit()
protected void enableBuffering()
protected void disableBuffering()
public boolean isBufferingEnabled()
true if buffering is enabled.
public boolean isBufferStreamBased()
true if underlying buffer was written to
using getOutputStream() (as opposed to getWriter().
If buffering was not enabled at all, false will be returned,
therefore an additional check is required.
public java.io.PrintWriter getWriter()
throws java.io.IOException
getWriter in interface javax.servlet.ServletResponsegetWriter in class javax.servlet.ServletResponseWrapperjava.io.IOException
public javax.servlet.ServletOutputStream getOutputStream()
throws java.io.IOException
getOutputStream in interface javax.servlet.ServletResponsegetOutputStream in class javax.servlet.ServletResponseWrapperjava.io.IOExceptionpublic char[] getBufferedChars()
null if buffering was not enabled.
public byte[] getBufferedBytes()
null if buffering was not enabled.
protected boolean bufferContentType(java.lang.String contentType,
java.lang.String mimeType,
java.lang.String encoding)
true.
contentType - full content-type, e.g. "text/html; charset=utf-8"mimeType - extracted mime-type, e.g. "text/html"encoding - extracted encoding, e.g. "utf-8" (may be null)public void setContentType(java.lang.String type)
setContentType in interface javax.servlet.ServletResponsesetContentType in class javax.servlet.ServletResponseWrapper
public void flushBuffer()
throws java.io.IOException
flushBuffer in interface javax.servlet.ServletResponseflushBuffer in class javax.servlet.ServletResponseWrapperjava.io.IOExceptionpublic void setContentLength(int contentLength)
setContentLength in interface javax.servlet.ServletResponsesetContentLength in class javax.servlet.ServletResponseWrapper
public void setHeader(java.lang.String name,
java.lang.String value)
setHeader in interface javax.servlet.http.HttpServletResponsesetHeader in class javax.servlet.http.HttpServletResponseWrapper
public void addHeader(java.lang.String name,
java.lang.String value)
addHeader in interface javax.servlet.http.HttpServletResponseaddHeader in class javax.servlet.http.HttpServletResponseWrapper
public void setIntHeader(java.lang.String name,
int value)
setIntHeader in interface javax.servlet.http.HttpServletResponsesetIntHeader in class javax.servlet.http.HttpServletResponseWrapper
public void addIntHeader(java.lang.String name,
int value)
addIntHeader in interface javax.servlet.http.HttpServletResponseaddIntHeader in class javax.servlet.http.HttpServletResponseWrapper
public void setDateHeader(java.lang.String name,
long value)
setDateHeader in interface javax.servlet.http.HttpServletResponsesetDateHeader in class javax.servlet.http.HttpServletResponseWrapper
public void addDateHeader(java.lang.String name,
long value)
addDateHeader in interface javax.servlet.http.HttpServletResponseaddDateHeader in class javax.servlet.http.HttpServletResponseWrapperpublic void setStatus(int statusCode)
setStatus in interface javax.servlet.http.HttpServletResponsesetStatus in class javax.servlet.http.HttpServletResponseWrapper
public void setStatus(int statusCode,
java.lang.String reason)
setStatus in interface javax.servlet.http.HttpServletResponsesetStatus in class javax.servlet.http.HttpServletResponseWrapper
public void sendError(int statusCode)
throws java.io.IOException
sendError in interface javax.servlet.http.HttpServletResponsesendError in class javax.servlet.http.HttpServletResponseWrapperjava.io.IOException
public void sendError(int statusCode,
java.lang.String reason)
throws java.io.IOException
sendError in interface javax.servlet.http.HttpServletResponsesendError in class javax.servlet.http.HttpServletResponseWrapperjava.io.IOException
public void sendRedirect(java.lang.String location)
throws java.io.IOException
sendRedirect in interface javax.servlet.http.HttpServletResponsesendRedirect in class javax.servlet.http.HttpServletResponseWrapperjava.io.IOExceptionprotected void stopBufferingForStatusCode(int statusCode)
protected boolean bufferStatusCode(int statusCode)
true only for status code 200.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||