ehcache

net.sf.ehcache.constructs.web
Class GenericResponseWrapper

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by javax.servlet.http.HttpServletResponseWrapper
          extended by net.sf.ehcache.constructs.web.GenericResponseWrapper
All Implemented Interfaces:
java.io.Serializable, javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse

public class GenericResponseWrapper
extends javax.servlet.http.HttpServletResponseWrapper
implements java.io.Serializable

Provides a wrapper for HttpServletResponseWrapper.

It is used to wrap the real Response so that we can modify it after that the target of the request has delivered its response.

It uses the Wrapper pattern.

Version:
$Id: GenericResponseWrapper.java 519 2007-07-27 07:11:45Z gregluck $
Author:
Greg Luck
See Also:
Serialized Form

Field Summary
 
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
GenericResponseWrapper(javax.servlet.http.HttpServletResponse response, java.io.OutputStream outstr)
          Creates a GenericResponseWrapper
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds a cookie.
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a header.
 java.lang.String encodeRedirectUrl(java.lang.String s)
          Override the deprecated method and call non-deprecated method
 java.lang.String encodeUrl(java.lang.String s)
          Override the deprecated method and call non-deprecated method
 void flush()
          Flushes all the streams for this response.
 void flushBuffer()
          Flushes buffer and commits response to client.
 int getContentLength()
          Gets the content length.
 java.lang.String getContentType()
          Gets the content type.
 java.util.Collection getCookies()
          Gets all the cookies.
 java.util.Collection getHeaders()
          Gets the headers.
 javax.servlet.ServletOutputStream getOutputStream()
          Gets the outputstream.
 int getStatus()
          Returns the status code for this response.
 java.io.PrintWriter getWriter()
          Gets the print writer.
 void reset()
          Resets the response.
 void resetBuffer()
          Resets the buffers.
 void sendError(int i)
          Send the error.
 void sendError(int i, java.lang.String string)
          Send the error.
 void sendRedirect(java.lang.String string)
          Send the redirect.
 void setContentLength(int length)
          Sets the content length.
 void setContentType(java.lang.String type)
          Sets the content type.
 void setHeader(java.lang.String name, java.lang.String value)
           
 void setStatus(int code)
          Sets the status code for this response.
 void setStatus(int code, java.lang.String msg)
          Sets the status code for this response.
 
Methods inherited from class javax.servlet.http.HttpServletResponseWrapper
addDateHeader, addIntHeader, containsHeader, encodeRedirectURL, encodeURL, setDateHeader, setIntHeader
 
Methods inherited from class javax.servlet.ServletResponseWrapper
getBufferSize, getCharacterEncoding, getLocale, getResponse, isCommitted, 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, getLocale, isCommitted, setBufferSize, setCharacterEncoding, setLocale
 

Constructor Detail

GenericResponseWrapper

public GenericResponseWrapper(javax.servlet.http.HttpServletResponse response,
                              java.io.OutputStream outstr)
Creates a GenericResponseWrapper

Method Detail

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
Gets the outputstream.

Specified by:
getOutputStream in interface javax.servlet.ServletResponse
Overrides:
getOutputStream in class javax.servlet.ServletResponseWrapper

setStatus

public void setStatus(int code)
Sets the status code for this response.

Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse
Overrides:
setStatus in class javax.servlet.http.HttpServletResponseWrapper

sendError

public void sendError(int i,
                      java.lang.String string)
               throws java.io.IOException
Send the error. If the response is not ok, most of the logic is bypassed and the error is sent raw Also, the content is not cached.

Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
Overrides:
sendError in class javax.servlet.http.HttpServletResponseWrapper
Parameters:
i - the status code
string - the error message
Throws:
java.io.IOException

sendError

public void sendError(int i)
               throws java.io.IOException
Send the error. If the response is not ok, most of the logic is bypassed and the error is sent raw Also, the content is not cached.

Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
Overrides:
sendError in class javax.servlet.http.HttpServletResponseWrapper
Parameters:
i - the status code
Throws:
java.io.IOException

sendRedirect

public void sendRedirect(java.lang.String string)
                  throws java.io.IOException
Send the redirect. If the response is not ok, most of the logic is bypassed and the error is sent raw. Also, the content is not cached.

Specified by:
sendRedirect in interface javax.servlet.http.HttpServletResponse
Overrides:
sendRedirect in class javax.servlet.http.HttpServletResponseWrapper
Parameters:
string - the URL to redirect to
Throws:
java.io.IOException

setStatus

public void setStatus(int code,
                      java.lang.String msg)
Sets the status code for this response.

Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse
Overrides:
setStatus in class javax.servlet.http.HttpServletResponseWrapper

getStatus

public int getStatus()
Returns the status code for this response.


setContentLength

public void setContentLength(int length)
Sets the content length.

Specified by:
setContentLength in interface javax.servlet.ServletResponse
Overrides:
setContentLength in class javax.servlet.ServletResponseWrapper

getContentLength

public int getContentLength()
Gets the content length.


setContentType

public void setContentType(java.lang.String type)
Sets the content type.

Specified by:
setContentType in interface javax.servlet.ServletResponse
Overrides:
setContentType in class javax.servlet.ServletResponseWrapper

getContentType

public java.lang.String getContentType()
Gets the content type.

Specified by:
getContentType in interface javax.servlet.ServletResponse
Overrides:
getContentType in class javax.servlet.ServletResponseWrapper

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Gets the print writer.

Specified by:
getWriter in interface javax.servlet.ServletResponse
Overrides:
getWriter in class javax.servlet.ServletResponseWrapper
Throws:
java.io.IOException

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Adds a header.

Specified by:
addHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
addHeader in class javax.servlet.http.HttpServletResponseWrapper

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Specified by:
setHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
setHeader in class javax.servlet.http.HttpServletResponseWrapper
See Also:
addHeader(java.lang.String, java.lang.String)

getHeaders

public java.util.Collection getHeaders()
Gets the headers.


addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Adds a cookie.

Specified by:
addCookie in interface javax.servlet.http.HttpServletResponse
Overrides:
addCookie in class javax.servlet.http.HttpServletResponseWrapper

getCookies

public java.util.Collection getCookies()
Gets all the cookies.


flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Flushes buffer and commits response to client.

Specified by:
flushBuffer in interface javax.servlet.ServletResponse
Overrides:
flushBuffer in class javax.servlet.ServletResponseWrapper
Throws:
java.io.IOException

reset

public void reset()
Resets the response.

Specified by:
reset in interface javax.servlet.ServletResponse
Overrides:
reset in class javax.servlet.ServletResponseWrapper

resetBuffer

public void resetBuffer()
Resets the buffers.

Specified by:
resetBuffer in interface javax.servlet.ServletResponse
Overrides:
resetBuffer in class javax.servlet.ServletResponseWrapper

flush

public void flush()
           throws java.io.IOException
Flushes all the streams for this response.

Throws:
java.io.IOException

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String s)
Override the deprecated method and call non-deprecated method

Specified by:
encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse
Overrides:
encodeRedirectUrl in class javax.servlet.http.HttpServletResponseWrapper

encodeUrl

public java.lang.String encodeUrl(java.lang.String s)
Override the deprecated method and call non-deprecated method

Specified by:
encodeUrl in interface javax.servlet.http.HttpServletResponse
Overrides:
encodeUrl in class javax.servlet.http.HttpServletResponseWrapper

ehcache