org.eclipse.net4j.buffer
Class BufferOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.eclipse.net4j.buffer.BufferOutputStream
All Implemented Interfaces:
Closeable, Flushable
Direct Known Subclasses:
ChannelOutputStream

public class BufferOutputStream
extends OutputStream

An output stream that fragments the written byte sequence into fixed-sized buffers and passes them to configured buffer handler.


Field Summary
static boolean DEFAULT_PROPAGATE_CLOSE
           
 
Constructor Summary
BufferOutputStream(IBufferHandler bufferHandler, IBufferProvider bufferProvider, short channelID)
           
BufferOutputStream(IBufferHandler bufferHandler, short channelID)
           
 
Method Summary
 void close()
           
protected  void ensureBuffer()
          Ensures that this BufferOutputStream has a buffer.
 void flush()
          Flushes the current buffer, it's handled over to the buffer handler.
 void flushWithEOS()
           
 Throwable getError()
           
protected  boolean isPropagateClose()
           
 void setError(Throwable error)
           
 String toString()
           
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PROPAGATE_CLOSE

public static final boolean DEFAULT_PROPAGATE_CLOSE
See Also:
Constant Field Values
Constructor Detail

BufferOutputStream

public BufferOutputStream(IBufferHandler bufferHandler,
                          IBufferProvider bufferProvider,
                          short channelID)

BufferOutputStream

public BufferOutputStream(IBufferHandler bufferHandler,
                          short channelID)
Method Detail

getError

public Throwable getError()
Since:
2.0

setError

public void setError(Throwable error)
Since:
2.0

write

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

flush

public void flush()
           throws IOException
Flushes the current buffer, it's handled over to the buffer handler.

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException - Signals that an I/O exception has occurred.
See Also:
currentBuffer, IBufferHandler.handleBuffer(IBuffer)

flushWithEOS

public void flushWithEOS()
                  throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

ensureBuffer

protected void ensureBuffer()
                     throws IOException
Ensures that this BufferOutputStream has a buffer. If the current buffer was flushed a new one is fetched from the buffer provider.

Throws:
IOException - Signals that an I/O exception has occurred.
See Also:
flush(), IBufferProvider.provideBuffer()

isPropagateClose

protected boolean isPropagateClose()


Copyright (c) 2011, 2012 Eike Stepper (Berlin, Germany) and others.