XNIO API 3.0.7.GA

org.xnio.streams
Class BufferPipeOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.xnio.streams.BufferPipeOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class BufferPipeOutputStream
extends OutputStream

An OutputStream implementation which writes out ByteBuffers to a consumer.


Nested Class Summary
static interface BufferPipeOutputStream.BufferWriter
          A buffer writer for an BufferPipeOutputStream.
 
Constructor Summary
BufferPipeOutputStream(BufferPipeOutputStream.BufferWriter bufferWriterTask)
          Construct a new instance.
 
Method Summary
 Pooled<ByteBuffer> breakPipe()
          Break the pipe and return any filling pooled buffer.
 void close()
          
 void flush()
          
 void write(byte[] b, int off, int len)
          
 void write(int b)
          
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferPipeOutputStream

public BufferPipeOutputStream(BufferPipeOutputStream.BufferWriter bufferWriterTask)
                       throws IOException
Construct a new instance. The internal buffers will have a capacity of bufferSize. The given bufferWriterTask will be called to send buffers, flush the output stream, and handle the end-of-file condition.

Parameters:
bufferWriterTask - the writer task
Throws:
IOException - if an error occurs while initializing the stream
Method Detail

write

public void write(int b)
           throws IOException

Specified by:
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

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

breakPipe

public Pooled<ByteBuffer> breakPipe()
Break the pipe and return any filling pooled buffer. Sets the stream to an EOF condition. Callers to this method should ensure that any threads blocked on BufferPipeOutputStream.BufferWriter.accept(org.xnio.Pooled, boolean) are unblocked, preferably with a BrokenPipeException.

Returns:
the current pooled buffer, or null if none was pending

XNIO API 3.0.7.GA

Copyright © 2010 JBoss, a division of Red Hat, Inc.