de.oio.bugkilla.splitter
Class SplitterServletOutputStreamImpl

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--javax.servlet.ServletOutputStream
              |
              +--de.oio.bugkilla.splitter.SplitterServletOutputStreamImpl

public class SplitterServletOutputStreamImpl
extends javax.servlet.ServletOutputStream

A class to write the incomning response data synchronously in a ByteArrayOutputStream. The SplitterServletOutputSreamImpl wrappes the original response stream from the given HttpServletResponse object. If the container invokes the method getOutputStream oder getWriter of the response and an instance of this class is used to write in the written data will be saved independently in a seperate stream.

Author:
swinkler

Constructor Summary
SplitterServletOutputStreamImpl(javax.servlet.http.HttpServletResponse response)
          Constructs a new SplitterServletOutputStreamImpl that splits the response data into a seperate buffer.
 
Method Summary
 void close()
          Closes the original response output stream.
 byte[] getContent()
          Returns the content that is written into the original response stream as a byte array.
 java.lang.String getContentAsString()
          Returns the content that is written into the original response stream as a String.
 void write(byte[] b)
          Writes b.length bytes from the specified byte array to the original reponse output stream and synchronously into a local stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to the original reponse output stream and synchronously into a local stream.
 void write(int b)
          Writes the specified byte to the original reponse output stream and synchronously into a local stream
 
Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitterServletOutputStreamImpl

public SplitterServletOutputStreamImpl(javax.servlet.http.HttpServletResponse response)
Constructs a new SplitterServletOutputStreamImpl that splits the response data into a seperate buffer. The buffer is a ByteArrayOutputStream the original response content is also written into.

Parameters:
response - - the response its data should also be written in the seperated stream
Method Detail

getContent

public byte[] getContent()
Returns the content that is written into the original response stream as a byte array.

Returns:
the response content

getContentAsString

public java.lang.String getContentAsString()
Returns the content that is written into the original response stream as a String.

Returns:
the response content

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to the original reponse output stream and synchronously into a local stream

Specified by:
write in class java.io.OutputStream
Parameters:
b - - the byte.
Throws:
java.io.IOException - - if an I/O error occurs.

write

public void write(byte[] b)
           throws java.io.IOException
Writes b.length bytes from the specified byte array to the original reponse output stream and synchronously into a local stream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - - the data.
Throws:
java.io.IOException - - if an I/O error occurs.
See Also:
write(byte[] b, int off, int len)

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes len bytes from the specified byte array starting at offset off to the original reponse output stream and synchronously into a local stream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - - the data.
off - - the start offset in the data.
len - - the number of bytes to write.
Throws:
java.io.IOException - - if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.

close

public void close()
           throws java.io.IOException
Closes the original response output stream. Before invoking close of the superclass the saved content is given to the guard class of the response.

Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - - if an I/O error occurs.


Copyright © Orientation in Objects GmbH. All Rights Reserved.