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

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by javax.servlet.http.HttpServletResponseWrapper
          extended by org.apache.beehive.netui.pageflow.scoping.internal.ScopedResponseImpl
All Implemented Interfaces
javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse, ScopedResponse

public class ScopedResponseImpl
extends javax.servlet.http.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 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
ScopedResponseImpl(javax.servlet.http.HttpServletResponse servletResponse)
           
 
Method Summary
 void addCookie(javax.servlet.http.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.
 javax.servlet.http.Cookie getCookie(String cookieName)
          Gets a cookie that was added to the response.
 javax.servlet.http.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.
 javax.servlet.http.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 javax.servlet.http.HttpServletResponseWrapper
encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL
 
Methods inherited from class javax.servlet.ServletResponseWrapper
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getResponse, getWriter, isCommitted, 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.http.HttpServletResponse
encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL
 
Methods inherited from interface javax.servlet.ServletResponse
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, setCharacterEncoding, setLocale
 

Constructor Detail

ScopedResponseImpl

public ScopedResponseImpl(javax.servlet.http.HttpServletResponse servletResponse)
Method Detail

sendError

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

sendError

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

setStatus

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

setStatus

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

setContentLength

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

setContentType

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

setBufferSize

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

resetBuffer

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

reset

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

addCookie

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

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

getCookie

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

Specified by:
getCookie in interface ScopedResponse

getCookies

public javax.servlet.http.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 javax.servlet.http.HttpServletResponse
Overrides:
containsHeader in class javax.servlet.http.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 javax.servlet.http.HttpServletResponse
Overrides:
setDateHeader in class javax.servlet.http.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 javax.servlet.http.HttpServletResponse
Overrides:
addDateHeader in class javax.servlet.http.HttpServletResponseWrapper

setHeader

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

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

addHeader

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

Specified by:
addHeader in interface javax.servlet.http.HttpServletResponse
Overrides:
addHeader in class javax.servlet.http.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 javax.servlet.http.HttpServletResponse
Overrides:
setIntHeader in class javax.servlet.http.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 javax.servlet.http.HttpServletResponse
Overrides:
addIntHeader in class javax.servlet.http.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 javax.servlet.http.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 javax.servlet.http.HttpServletResponse
Overrides:
sendRedirect in class javax.servlet.http.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.


Copyright © 2011, Oracle. All rights reserved.