DLESE Tools
v1.6.0

org.dlese.dpc.webapps.servlets.filters
Class CharArrayWrapper

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by javax.servlet.http.HttpServletResponseWrapper
          extended by org.dlese.dpc.webapps.servlets.filters.CharArrayWrapper
All Implemented Interfaces:
HttpServletResponse, ServletResponse

public class CharArrayWrapper
extends HttpServletResponseWrapper

A response wrapper that takes the servlet's or JSP's response and saves it into a char[] for use in Filters. The array can then be acted upon using a Filter to do post-processing on the respose content prior to it being sent out. See More Servlets and JavaServer Pages, chapter 9.

Author:
John Weatherley

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
CharArrayWrapper(HttpServletResponse response)
          Constructor for the CharArrayWrapper object
 
Method Summary
 int getContentLength()
          Gets the contentLength attribute of the GenericResponseWrapper object
 String getContentType()
          Gets the contentType attribute of the GenericResponseWrapper object
 String getErrorMsg()
          Gets the errorMsg attribute of the CharArrayWrapper object
 int getStatus()
          Gets the status attribute of the CharArrayWrapper object
 PrintWriter getWriter()
          Replace the normal writer with a writer that ouputs our char[].
 void sendError(int sc)
          DESCRIPTION
 void sendError(int sc, String msg)
          DESCRIPTION
 void setContentLength(int length)
          Sets the contentLength attribute of the GenericResponseWrapper object
 void setContentType(String type)
          Sets the contentType attribute of the GenericResponseWrapper object
 void setStatus(int sc)
          Sets the status attribute of the CharArrayWrapper object
 char[] toCharArray()
          Convert to char[].
 String toString()
          Convert to String.
 
Methods inherited from class javax.servlet.http.HttpServletResponseWrapper
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus
 
Methods inherited from class javax.servlet.ServletResponseWrapper
flushBuffer, getBufferSize, getCharacterEncoding, getLocale, getOutputStream, getResponse, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setLocale, setResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletResponse
flushBuffer, getBufferSize, getCharacterEncoding, getLocale, getOutputStream, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setLocale
 

Constructor Detail

CharArrayWrapper

public CharArrayWrapper(HttpServletResponse response)
Constructor for the CharArrayWrapper object

Parameters:
response - The HttpServletResponse.
Method Detail

getWriter

public PrintWriter getWriter()
Replace the normal writer with a writer that ouputs our char[]. This char[] will then be used when ouputting the response instead of the default writer.

Specified by:
getWriter in interface ServletResponse
Overrides:
getWriter in class ServletResponseWrapper
Returns:
The writer value

toString

public String toString()
Convert to String.

Overrides:
toString in class Object
Returns:
A String representataion of the char[] content.

toCharArray

public char[] toCharArray()
Convert to char[].

Returns:
A char[] of the CharArray content.

sendError

public void sendError(int sc)
               throws IOException
DESCRIPTION

Specified by:
sendError in interface HttpServletResponse
Overrides:
sendError in class HttpServletResponseWrapper
Parameters:
sc - DESCRIPTION
Throws:
IOException - DESCRIPTION

sendError

public void sendError(int sc,
                      String msg)
               throws IOException
DESCRIPTION

Specified by:
sendError in interface HttpServletResponse
Overrides:
sendError in class HttpServletResponseWrapper
Parameters:
sc - DESCRIPTION
msg - DESCRIPTION
Throws:
IOException - DESCRIPTION

setStatus

public void setStatus(int sc)
Sets the status attribute of the CharArrayWrapper object

Specified by:
setStatus in interface HttpServletResponse
Overrides:
setStatus in class HttpServletResponseWrapper
Parameters:
sc - The new status value

getStatus

public int getStatus()
Gets the status attribute of the CharArrayWrapper object

Returns:
The status value

getErrorMsg

public String getErrorMsg()
Gets the errorMsg attribute of the CharArrayWrapper object

Returns:
The errorMsg value

setContentLength

public void setContentLength(int length)
Sets the contentLength attribute of the GenericResponseWrapper object

Specified by:
setContentLength in interface ServletResponse
Overrides:
setContentLength in class ServletResponseWrapper
Parameters:
length - The new contentLength value

getContentLength

public int getContentLength()
Gets the contentLength attribute of the GenericResponseWrapper object

Returns:
The contentLength value

setContentType

public void setContentType(String type)
Sets the contentType attribute of the GenericResponseWrapper object

Specified by:
setContentType in interface ServletResponse
Overrides:
setContentType in class ServletResponseWrapper
Parameters:
type - The new contentType value

getContentType

public String getContentType()
Gets the contentType attribute of the GenericResponseWrapper object

Specified by:
getContentType in interface ServletResponse
Overrides:
getContentType in class ServletResponseWrapper
Returns:
The contentType value

DLESE Tools
v1.6.0