org.norther.tammi.spray.protocol.chain
Class AbstractProtocolResponse

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by org.norther.tammi.spray.filter.chain.ServletResponseWrapper
          extended by org.norther.tammi.spray.filter.chain.HttpServletResponseWrapper
              extended by org.norther.tammi.spray.protocol.chain.AbstractProtocolResponse
All Implemented Interfaces:
EventListener, HttpServletResponse, ServletResponse, Poolable, Recyclable, FilterChainListener
Direct Known Subclasses:
HttpProtocolResponse, HttpServletResponseDecorator

public abstract class AbstractProtocolResponse
extends HttpServletResponseWrapper

An abstract protocol response implementing extended character encoding.

Author:
Ilkka Priha

Field Summary
protected static String SERVER_ID
          The server id attribute.
protected  StringBuilder sharedBuffer
          A string buffer for parsing.
 
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
AbstractProtocolResponse()
          Constructs a new response.
AbstractProtocolResponse(ServletResponse res)
          Constructs a new response with a wrapped one.
 
Method Summary
 void dispose()
          Disposes the object after use.
protected  String encodeURL(String url, boolean redirected)
          Encodes the specified URL with the identifiers from the request.
 String getCharacterEncoding()
           
protected  int getContentLength()
          Gets the content length.
 String getContentType()
           
protected  HttpFilter getHttpFilter()
          Gets the HTTP filter.
protected abstract  boolean isWriterInUse()
          Checks whether a writer is already in use.
 void reset()
           
 void setCharacterEncoding(String enc)
           
 void setContentLength(int value)
           
 void setContentType(String type)
           
 void setLocale(Locale locale)
           
 void setStatus(int code)
           
 
Methods inherited from class org.norther.tammi.spray.filter.chain.HttpServletResponseWrapper
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setResponse, setStatus
 
Methods inherited from class org.norther.tammi.spray.filter.chain.ServletResponseWrapper
completed, disposed, filtered, getExtension, getFilterChain, getFilteredRequest, getFilteredResponse, isDisposed, recycle, recycle, recycled
 
Methods inherited from class javax.servlet.ServletResponseWrapper
flushBuffer, getBufferSize, getLocale, getOutputStream, getResponse, getWriter, isCommitted, resetBuffer, setBufferSize
 
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
flushBuffer, getBufferSize, getLocale, getOutputStream, getWriter, isCommitted, resetBuffer, setBufferSize
 

Field Detail

SERVER_ID

protected static final String SERVER_ID
The server id attribute.


sharedBuffer

protected StringBuilder sharedBuffer
A string buffer for parsing.

Constructor Detail

AbstractProtocolResponse

public AbstractProtocolResponse()
Constructs a new response.


AbstractProtocolResponse

public AbstractProtocolResponse(ServletResponse res)
Constructs a new response with a wrapped one.

Parameters:
res - the wrapped response.
Method Detail

dispose

public void dispose()
Description copied from interface: Recyclable
Disposes the object after use. The method is called when the object is returned to its pool. The dispose method must call its super.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class HttpServletResponseWrapper

setStatus

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

setContentLength

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

getContentType

public String getContentType()
Specified by:
getContentType in interface ServletResponse
Overrides:
getContentType in class ServletResponseWrapper

setContentType

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

getCharacterEncoding

public String getCharacterEncoding()
Specified by:
getCharacterEncoding in interface ServletResponse
Overrides:
getCharacterEncoding in class ServletResponseWrapper

setCharacterEncoding

public void setCharacterEncoding(String enc)
Specified by:
setCharacterEncoding in interface ServletResponse
Overrides:
setCharacterEncoding in class ServletResponseWrapper

setLocale

public void setLocale(Locale locale)
Specified by:
setLocale in interface ServletResponse
Overrides:
setLocale in class ServletResponseWrapper

reset

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

getContentLength

protected int getContentLength()
Gets the content length.

Returns:
the length.

encodeURL

protected String encodeURL(String url,
                           boolean redirected)
Encodes the specified URL with the identifiers from the request.

Parameters:
url - URL to be encoded.
redirected - a flag for redirection.
Returns:
the encoded URL.

getHttpFilter

protected HttpFilter getHttpFilter()
Gets the HTTP filter.

Returns:
the HTTP filter.
Throws:
IllegalStateException - if not available.

isWriterInUse

protected abstract boolean isWriterInUse()
Checks whether a writer is already in use.

Returns:
true if a writer is in use.


Copyright © 2004 The Norther Organization. All rights reserved.