org.norther.tammi.spray.filter.chain
Class ServletOutputStreamWrapper

java.lang.Object
  extended by java.io.OutputStream
      extended by javax.servlet.ServletOutputStream
          extended by org.norther.tammi.spray.filter.chain.ServletOutputStreamWrapper
All Implemented Interfaces:
Closeable, Flushable

public class ServletOutputStreamWrapper
extends ServletOutputStream

A servlet output stream wrapper supporting a flush callback.

Note that the wrapped stream is not closed by the close method of this stream.

Author:
Ilkka Priha

Constructor Summary
ServletOutputStreamWrapper()
          Constructs a new output stream.
ServletOutputStreamWrapper(OutputStream out)
          Constructs a new output stream with an adapter.
ServletOutputStreamWrapper(OutputStream out, Flushable flush)
          Constructs a new output stream with an adapter and callback.
ServletOutputStreamWrapper(OutputStream out, Flushable flush, byte[] buf)
          Constructs a new output stream with an adapter, callback and an external buffer.
ServletOutputStreamWrapper(OutputStream out, Flushable flush, int size)
          Constructs a new output stream with an adapter, callback and a specific buffer size.
 
Method Summary
 void close()
          Marks the stream as closed, but doesn't close the wrapped one.
 void flush()
           
 int getBufferSize()
          Gets the buffer size.
 int getByteCount()
          Gets the byte count.
 boolean isChunked()
          Checks wheher chunked.
 boolean isClosed()
          Check whether the stream is closed.
 boolean isFlushed()
          Gets the flushed flag.
 boolean reset()
          Resets the stream if it has not been flushed.
 boolean setChunked(boolean chunk)
          Sets chunked if not yet flushed.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
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.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletOutputStreamWrapper

public ServletOutputStreamWrapper()
Constructs a new output stream.


ServletOutputStreamWrapper

public ServletOutputStreamWrapper(OutputStream out)
Constructs a new output stream with an adapter.

Parameters:
out - the wrapped output stream.

ServletOutputStreamWrapper

public ServletOutputStreamWrapper(OutputStream out,
                                  Flushable flush)
Constructs a new output stream with an adapter and callback.

Parameters:
out - the wrapped output stream.
flush - a flushable callback.

ServletOutputStreamWrapper

public ServletOutputStreamWrapper(OutputStream out,
                                  Flushable flush,
                                  int size)
Constructs a new output stream with an adapter, callback and a specific buffer size.

Parameters:
out - the wrapped output stream.
flush - a flushable callback.
size - the buffer size.

ServletOutputStreamWrapper

public ServletOutputStreamWrapper(OutputStream out,
                                  Flushable flush,
                                  byte[] buf)
Constructs a new output stream with an adapter, callback and an external buffer.

Parameters:
out - the wrapped output stream.
flush - a flushable callback.
buf - the buffer.
Method Detail

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Marks the stream as closed, but doesn't close the wrapped one.

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException - on errors.

reset

public boolean reset()
Resets the stream if it has not been flushed.

Returns:
true if reset.

getBufferSize

public int getBufferSize()
Gets the buffer size.

Returns:
the buffer size.

getByteCount

public int getByteCount()
Gets the byte count.

Returns:
the byte count.

isFlushed

public boolean isFlushed()
Gets the flushed flag.

Returns:
true if flushed.

isChunked

public boolean isChunked()
Checks wheher chunked.

Returns:
true if chunked.

setChunked

public boolean setChunked(boolean chunk)
Sets chunked if not yet flushed.

Parameters:
chunk - a chunk flag.
Returns:
true if set.

isClosed

public boolean isClosed()
Check whether the stream is closed.

Returns:
true if closed, otherwise false.


Copyright © 2004 The Norther Organization. All rights reserved.