org.apache.beehive.netui.pageflow.scoping.internal
Class ScopedResponseImpl

Object
  extended by ServletResponseWrapper
      extended by HttpServletResponseWrapper
          extended by ScopedResponseImpl
All Implemented Interfaces:
HttpServletResponse, ServletResponse, ScopedResponse

public class ScopedResponseImpl
extends HttpServletResponseWrapper
implements ScopedResponse

A wrapper around HttpServletResponse, associated with a given scope-key. Delegates to the wrapped response object for some functionality, but prevents output or error codes or forwards from actually happening.


Field Summary
 
Fields inherited from interface 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
ScopedResponseImpl(HttpServletResponse response)
           
 
Method Summary
 void addCookie(Cookie cookie)
          Add a cookie to the response.
 void addDateHeader(String name, long date)
          Adds a response header with the given name and date-value.
 void addHeader(String name, String value)
          Adds a response header with the given name and value.
 void addIntHeader(String name, int value)
          Adds a response header with the given name and integer value.
protected  void addObjectHeader(String name, Object val)
           
 void applyRedirect()
          Actually send the redirect that was suggested by sendRedirect(java.lang.String).
 boolean containsHeader(String name)
          Returns true if this response containes the given header.
 boolean didRedirect()
          Tell whether a browser redirect was sent.
 void flushBuffer()
           
 Cookie getCookie(String cookieName)
          Gets a cookie that was added to the response.
 Cookie[] getCookies()
          Gets all Cookies that were added to the response.
 Object getFirstHeader(String name)
          Gets the first header with the given name.
 Map getHeaders()
          Gets all headers.
 List getHeaders(String name)
          Gets all headers with the given name.
 HttpServletResponse getOuterResponse()
           
 String getRedirectURI()
          Get the redirect URI.
 int getStatusCode()
          Get the status code on the response.
 String getStatusMessage()
          Get the status message on the response.
 boolean isError()
          Tell whether the response is in error.
 void reset()
           
 void resetBuffer()
           
 void sendError(int i)
           
 void sendError(int i, String s)
           
 void sendRedirect(String redirectURI)
           
 void setBufferSize(int i)
           
 void setContentLength(int i)
           
 void setContentType(String s)
           
 void setDateHeader(String name, long date)
          Sets a response header with the given name and date-value.
 void setHeader(String name, String value)
          Sets a response header with the given name and value.
 void setIntHeader(String name, int value)
          Sets a response header with the given name and integer value.
protected  void setObjectHeader(String name, Object val)
           
 void setStatus(int i)
           
 void setStatus(int i, String s)
           
 
Methods inherited from class HttpServletResponseWrapper
encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL
 
Methods inherited from class ServletResponseWrapper
getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getResponse, getWriter, isCommitted, setCharacterEncoding, setLocale, setResponse
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface HttpServletResponse
encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL
 
Methods inherited from interface ServletResponse
getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, setCharacterEncoding, setLocale
 

Constructor Detail

ScopedResponseImpl

public ScopedResponseImpl(HttpServletResponse response)
Method Detail

sendError

public void sendError(int i,
                      String s)
               throws IOException
Specified by:
sendError in interface HttpServletResponse
Overrides:
sendError in class HttpServletResponseWrapper
Throws:
IOException

sendError

public void sendError(int i)
               throws IOException
Specified by:
sendError in interface HttpServletResponse
Overrides:
sendError in class HttpServletResponseWrapper
Throws:
IOException

setStatus

public void setStatus(int i)
Specified by:
setStatus in interface HttpServletResponse
Overrides:
setStatus in class HttpServletResponseWrapper

setStatus

public void setStatus(int i,
                      String s)
Specified by:
setStatus in interface HttpServletResponse
Overrides:
setStatus in class HttpServletResponseWrapper

setContentLength

public void setContentLength(int i)
Specified by:
setContentLength in interface ServletResponse
Overrides:
setContentLength in class ServletResponseWrapper

setContentType

public void setContentType(String s)
Specified by:
setContentType in interface ServletResponse
Overrides:
setContentType in class ServletResponseWrapper

setBufferSize

public void setBufferSize(int i)
Specified by:
setBufferSize in interface ServletResponse
Overrides:
setBufferSize in class ServletResponseWrapper

flushBuffer

public void flushBuffer()
                 throws IOException
Specified by:
flushBuffer in interface ServletResponse
Overrides:
flushBuffer in class ServletResponseWrapper
Throws:
IOException

resetBuffer

public void resetBuffer()
Specified by:
resetBuffer in interface ServletResponse
Overrides:
resetBuffer in class ServletResponseWrapper

reset

public void reset()
Specified by:
reset in interface ServletResponse
Overrides:
reset in class ServletResponseWrapper

addCookie

public void addCookie(Cookie cookie)
Add a cookie to the response.

Specified by:
addCookie in interface HttpServletResponse
Overrides:
addCookie in class HttpServletResponseWrapper

getCookie

public Cookie getCookie(String cookieName)
Gets a cookie that was added to the response.

Specified by:
getCookie in interface ScopedResponse

getCookies

public Cookie[] getCookies()
Gets all Cookies that were added to the response.

Specified by:
getCookies in interface ScopedResponse

containsHeader

public boolean containsHeader(String name)
Returns true if this response containes the given header.

Specified by:
containsHeader in interface HttpServletResponse
Overrides:
containsHeader in class HttpServletResponseWrapper

setDateHeader

public void setDateHeader(String name,
                          long date)
Sets a response header with the given name and date-value.

Specified by:
setDateHeader in interface HttpServletResponse
Overrides:
setDateHeader in class HttpServletResponseWrapper

addDateHeader

public void addDateHeader(String name,
                          long date)
Adds a response header with the given name and date-value.

Specified by:
addDateHeader in interface HttpServletResponse
Overrides:
addDateHeader in class HttpServletResponseWrapper

setHeader

public void setHeader(String name,
                      String value)
Sets a response header with the given name and value.

Specified by:
setHeader in interface HttpServletResponse
Overrides:
setHeader in class HttpServletResponseWrapper

addHeader

public void addHeader(String name,
                      String value)
Adds a response header with the given name and value.

Specified by:
addHeader in interface HttpServletResponse
Overrides:
addHeader in class HttpServletResponseWrapper

setIntHeader

public void setIntHeader(String name,
                         int value)
Sets a response header with the given name and integer value.

Specified by:
setIntHeader in interface HttpServletResponse
Overrides:
setIntHeader in class HttpServletResponseWrapper

addIntHeader

public void addIntHeader(String name,
                         int value)
Adds a response header with the given name and integer value.

Specified by:
addIntHeader in interface HttpServletResponse
Overrides:
addIntHeader in class HttpServletResponseWrapper

getHeaders

public Map getHeaders()
Gets all headers.

Specified by:
getHeaders in interface ScopedResponse
Returns:
a Map of header-name (String) -> headers (List).

getHeaders

public List getHeaders(String name)
Gets all headers with the given name.

Specified by:
getHeaders in interface ScopedResponse
Returns:
a List of headers (String, Integer, Date, Cookie), or null if none are found.

getFirstHeader

public Object getFirstHeader(String name)
Gets the first header with the given name.

Specified by:
getFirstHeader in interface ScopedResponse
Returns:
an Object (String, Integer, Date, Cookie) that is the first header with the given name, or null if none is found.

addObjectHeader

protected void addObjectHeader(String name,
                               Object val)

setObjectHeader

protected void setObjectHeader(String name,
                               Object val)

getOuterResponse

public HttpServletResponse getOuterResponse()
Specified by:
getOuterResponse in interface ScopedResponse

isError

public boolean isError()
Description copied from interface: ScopedResponse
Tell whether the response is in error.

Specified by:
isError in interface ScopedResponse
Returns:
true if HttpServletResponse.sendError(int,String) or HttpServletResponse.sendError(int) was called.

getStatusCode

public int getStatusCode()
Description copied from interface: ScopedResponse
Get the status code on the response.

Specified by:
getStatusCode in interface ScopedResponse
Returns:
the status code, set by HttpServletResponse.setStatus(int), HttpServletResponse.sendError(int,String), or HttpServletResponse.sendError(int); -1 if no status was set explicitly.

getStatusMessage

public String getStatusMessage()
Description copied from interface: ScopedResponse
Get the status message on the response.

Specified by:
getStatusMessage in interface ScopedResponse
Returns:
the status code, set by HttpServletResponse.sendError(int,String), or null if none was set.

sendRedirect

public void sendRedirect(String redirectURI)
                  throws IOException
Specified by:
sendRedirect in interface HttpServletResponse
Overrides:
sendRedirect in class HttpServletResponseWrapper
Throws:
IOException

applyRedirect

public void applyRedirect()
                   throws IOException
Actually send the redirect that was suggested by sendRedirect(java.lang.String).

Specified by:
applyRedirect in interface ScopedResponse
Throws:
IllegalStateException - if sendRedirect(java.lang.String) was not called.
IOException - if HttpServletResponse.sendRedirect(java.lang.String) causes an IOException.

didRedirect

public boolean didRedirect()
Description copied from interface: ScopedResponse
Tell whether a browser redirect was sent.

Specified by:
didRedirect in interface ScopedResponse
Returns:
true if HttpServletResponse.sendRedirect(java.lang.String) was called.

getRedirectURI

public String getRedirectURI()
Description copied from interface: ScopedResponse
Get the redirect URI.

Specified by:
getRedirectURI in interface ScopedResponse
Returns:
the URI passed to HttpServletResponse.sendRedirect(java.lang.String), or null if there was no redirect.