java.lang.Object
java.io.InputStream
org.xnio.streams.BufferPipeInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
An
InputStream
implementation which is populated asynchronously with ByteBuffer
instances.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A handler for events relating to the consumption of data from aBufferPipeInputStream
instance. -
Constructor Summary
ConstructorsConstructorDescriptionBufferPipeInputStream
(BufferPipeInputStream.InputHandler inputHandler) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionint
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
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
-
Constructor Details
-
BufferPipeInputStream
Construct a new instance. The giveninputHandler
will be invoked after each buffer is fully read and when the stream is closed.- Parameters:
inputHandler
- the input events handler
-
-
Method Details
-
push
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
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
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
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-