public class ReadableBufferedChannel extends BufferedSelectionChannel<ReadableSelectionChannel> implements ReadableSelectionChannel, CompletionListener
Constructor and Description |
---|
ReadableBufferedChannel(CompletionListener completionListener,
Buffer buffer,
ReadableSelectionChannel source,
WakeupListener wakeupListener)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
couldDrain(Buffer buffer,
Object... args)
Indicates if the buffer could be drained again.
|
boolean |
couldFill(Buffer buffer,
Object... args)
Indicates if the buffer could be filled again.
|
protected boolean |
isEndReached()
Indicates if the end of the channel has been reached.
|
int |
onDrain(Buffer buffer,
int maxDrained,
Object... args)
Drains the byte buffer.
|
int |
onFill(Buffer buffer,
Object... args)
Fills the byte buffer by writing the current message.
|
void |
onMessageCompleted(boolean eofDetected)
Callback invoked upon IO completion.
|
int |
read(ByteBuffer targetBuffer)
Reads some bytes and put them into the destination buffer.
|
protected void |
setEndReached(boolean endReached)
Indicates if the end of the channel has been reached.
|
canLoop, close, getBuffer, onFillEof, postProcess, preProcess
getRegistration, isBlocking, setRegistration, toString
getWrappedChannel, isOpen
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getRegistration
isBlocking
public ReadableBufferedChannel(CompletionListener completionListener, Buffer buffer, ReadableSelectionChannel source, WakeupListener wakeupListener)
completionListener
- The listener to callback upon reading completion.buffer
- The source byte buffer, typically remaining from previous read
processing.source
- The source channel.wakeupListener
- The wakeup listener that will be notified.public boolean couldDrain(Buffer buffer, Object... args)
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 boolean isEndReached()
public void onMessageCompleted(boolean eofDetected) throws IOException
CompletionListener.onMessageCompleted(boolean)
if the end has been
reached.onMessageCompleted
in interface CompletionListener
eofDetected
- Indicates if the end of network connection was detected.IOException
public int onDrain(Buffer buffer, int maxDrained, Object... args) throws IOException
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 final 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 int read(ByteBuffer targetBuffer) throws IOException
read
in interface ReadableByteChannel
targetBuffer
- The target buffer.IOException
protected void setEndReached(boolean endReached) throws IOException
endReached
- True if the end of the channel has been reached.IOException
Copyright © 2005–2014. All rights reserved.