Package org.xnio.streams

# Class BufferPipeInputStream

java.lang.Object
java.io.InputStream
org.xnio.streams.BufferPipeInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class BufferPipeInputStream extends InputStream
An `InputStream` implementation which is populated asynchronously with `ByteBuffer` instances.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`BufferPipeInputStream.InputHandler`
A handler for events relating to the consumption of data from a `BufferPipeInputStream` instance.

## Constructor Summary

Constructors
Constructor
Description
`BufferPipeInputStream(BufferPipeInputStream.InputHandler inputHandler)`
Construct a new instance.

## Method Summary

Modifier and Type
Method
Description
`int`
`available()`
`void`
`close()`
`void`
`push(ByteBuffer buffer)`
Push a buffer into the queue.
`void`
`push(Pooled<ByteBuffer> pooledBuffer)`
Push a buffer into the queue.
`void`
`pushEof()`
Push the EOF condition into the queue.
`void`
`pushException(IOException e)`
Push an exception condition into the queue.
`int`
`read()`
`int`
`read(byte[] b, int off, int len)`
`long`
`skip(long qty)`

### Methods inherited from class java.io.InputStream

`mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### BufferPipeInputStream

public BufferPipeInputStream(BufferPipeInputStream.InputHandler inputHandler)
Construct a new instance. The given `inputHandler` will be invoked after each buffer is fully read and when the stream is closed.

Parameters:
  `inputHandler` - the input events handler

## Method Details

### push

public void push(ByteBuffer buffer)
Push a buffer into the queue. There is no mechanism to limit the number of pushed buffers; if such a mechanism is desired, it must be implemented externally, for example maybe using a `Semaphore`.

Parameters:
  `buffer` - the buffer from which more data should be read

### push

public void push(Pooled<ByteBuffer> pooledBuffer)
Push a buffer into the queue. There is no mechanism to limit the number of pushed buffers; if such a mechanism is desired, it must be implemented externally, for example maybe using a `Semaphore`.

Parameters:
  `pooledBuffer` - the buffer from which more data should be read

### pushException

public void pushException(IOException e)
Push an exception condition into the queue. After this method is called, no further buffers may be pushed into this instance.

Parameters:
  `e` - the exception to push

### pushEof

public void pushEof()
Push the EOF condition into the queue. After this method is called, no further buffers may be pushed into this instance.

### read

public int read() throws IOException

Specified by:
  `read` in class `InputStream`
Throws:
  `IOException`

### read

public int read(byte[] b, int off, int len) throws IOException

Overrides:
  `read` in class `InputStream`
Throws:
  `IOException`

### available

public int available() throws IOException

Overrides:
  `available` in class `InputStream`
Throws:
  `IOException`

### skip

public long skip(long qty) throws IOException

Overrides:
  `skip` in class `InputStream`
Throws:
  `IOException`

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `InputStream`
Throws:
  `IOException`