public class ChannelInputStream extends InputStream implements BufferProcessor
Constructor and Description |
---|
ChannelInputStream(ReadableByteChannel channel)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canLoop(Buffer buffer,
Object... args)
Indicates if the processing loop can continue.
|
boolean |
couldFill(Buffer buffer,
Object... args)
Indicates if the buffer could be filled again.
|
protected Buffer |
getBuffer()
Returns the internal byte buffer.
|
int |
onDrain(Buffer buffer,
int maxDrained,
Object... args)
Drains the byte buffer by returning available bytes as
InputStream bytes. |
int |
onFill(Buffer buffer,
Object... args)
Fills the byte buffer by reading the source channel.
|
void |
onFillEof()
Called back when a fill operation returns with an EOF status.
|
void |
postProcess(int drained)
Does nothing by default.
|
int |
preProcess(int maxDrained,
Object... args)
Does nothing by default.
|
int |
read() |
int |
read(byte[] targetArray,
int offset,
int length) |
available, close, mark, markSupported, read, reset, skip
public ChannelInputStream(ReadableByteChannel channel)
channel
- The channel to read from.public boolean canLoop(Buffer buffer, Object... args)
canLoop
in interface BufferProcessor
buffer
- The IO buffer to drain.args
- The optional arguments to pass back to the callbacks.public boolean couldFill(Buffer buffer, Object... args)
couldFill
in interface BufferProcessor
buffer
- The IO buffer to fill.args
- The optional arguments to pass back to the callbacks.protected Buffer getBuffer()
public int onDrain(Buffer buffer, int maxDrained, Object... args) throws IOException
InputStream
bytes.onDrain
in interface BufferProcessor
buffer
- The IO buffer to drain.maxDrained
- The maximum number of bytes drained by this call.args
- The optional arguments to pass back to the callbacks.IOException
public int onFill(Buffer buffer, Object... args) throws IOException
onFill
in interface BufferProcessor
buffer
- The IO buffer to drain.args
- The optional arguments to pass back to the callbacks.IOException
public void onFillEof()
onFillEof
in interface BufferProcessor
public void postProcess(int drained) throws IOException
postProcess
in interface BufferProcessor
drained
- The number of bytes drained or -1 if the filling source has
ended.IOException
public int preProcess(int maxDrained, Object... args) throws IOException
preProcess
in interface BufferProcessor
maxDrained
- The maximum number of bytes drained by this call or 0 for
unlimited length.args
- The optional arguments to pass back to the callbacks.IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] targetArray, int offset, int length) throws IOException
read
in class InputStream
IOException
Copyright © 2005–2016. All rights reserved.