com.basecmp.core.servlets
Class TransformableHttpServletResponse

java.lang.Object
  extended byHttpServletResponseWrapper
      extended bycom.basecmp.core.servlets.TransformableHttpServletResponse

public class TransformableHttpServletResponse
extends HttpServletResponseWrapper

HttpServletResponseWrapper implements a transform()-method which provides the means to transform the orignal response using a Tranformer-Object (see Jakarta-Commons-Collection for details on tranformers). The transformation-result is delivered by toString(). The original request ist not manipulated because this wrapper buffers all writing access in an internal Buffer. It is in the responsibilty of the programmer to write the transformation-result after having executed all transformations to the original response. Created on 14.05.2006

See Also:
Serialized Form
Author:
Wolfgang Schröder

Nested Class Summary
 class TransformableHttpServletResponse.BufferedServletOutputStream
           
 
Constructor Summary
TransformableHttpServletResponse(HttpServletResponse response)
           
 
Method Summary
 void flushBuffer()
           
 java.lang.String getContentType()
           
 ServletOutputStream getOutputStream()
           
 java.io.PrintWriter getWriter()
           
 boolean isOutputStream()
           
 void setContentLength(int length)
           
 void setContentType(java.lang.String contentType)
           
 byte[] toByteArray()
           
 java.lang.String toString()
          Delivers the string representation of the captured outputstream/printwriter (after flushing), including all executed tranformations, if any were executed.
 void transform(Transformer transformer)
          Execute tranform-method on the given Transformer using the internal CharArrayWriter (which captured the original response stream) as the input-object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransformableHttpServletResponse

public TransformableHttpServletResponse(HttpServletResponse response)
Method Detail

flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Throws:
java.io.IOException

getContentType

public java.lang.String getContentType()

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws java.io.IOException
Throws:
java.io.IOException

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Throws:
java.io.IOException

isOutputStream

public boolean isOutputStream()

setContentLength

public void setContentLength(int length)

setContentType

public void setContentType(java.lang.String contentType)

toByteArray

public byte[] toByteArray()

toString

public java.lang.String toString()
Delivers the string representation of the captured outputstream/printwriter (after flushing), including all executed tranformations, if any were executed.


transform

public void transform(Transformer transformer)
Execute tranform-method on the given Transformer using the internal CharArrayWriter (which captured the original response stream) as the input-object. After transformation the transformed result is the new content of the outputstream/printwriter. If anything wents wrong, the old content is kept.



Copyright © 2004 by basecmp® - Professional Web Solutions