- java.lang.Object
-
- java.io.InputStream
-
- org.xnio.streams.BufferPipeInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class BufferPipeInputStream extends java.io.InputStreamAnInputStreamimplementation which is populated asynchronously withByteBufferinstances.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceBufferPipeInputStream.InputHandlerA handler for events relating to the consumption of data from aBufferPipeInputStreaminstance.
-
Constructor Summary
Constructors Constructor Description BufferPipeInputStream(BufferPipeInputStream.InputHandler inputHandler)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()voidpush(java.nio.ByteBuffer buffer)Push a buffer into the queue.voidpush(Pooled<java.nio.ByteBuffer> pooledBuffer)Push a buffer into the queue.voidpushEof()Push the EOF condition into the queue.voidpushException(java.io.IOException e)Push an exception condition into the queue.intread()intread(byte[] b, int off, int len)longskip(long qty)
-
-
-
Constructor Detail
-
BufferPipeInputStream
public BufferPipeInputStream(BufferPipeInputStream.InputHandler inputHandler)
Construct a new instance. The giveninputHandlerwill be invoked after each buffer is fully read and when the stream is closed.- Parameters:
inputHandler- the input events handler
-
-
Method Detail
-
push
public void push(java.nio.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 aSemaphore.- Parameters:
buffer- the buffer from which more data should be read
-
push
public void push(Pooled<java.nio.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 aSemaphore.- Parameters:
pooledBuffer- the buffer from which more data should be read
-
pushException
public void pushException(java.io.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 java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long qty) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
-