org.restlet.engine.io
Class ReadableSizedSelectionChannel
java.lang.Object
org.restlet.engine.io.WrapperChannel<T>
org.restlet.engine.io.WrapperSelectionChannel<T>
org.restlet.engine.io.BufferedSelectionChannel<ReadableSelectionChannel>
org.restlet.engine.io.ReadableBufferedChannel
org.restlet.engine.io.ReadableSizedSelectionChannel
- All Implemented Interfaces:
- Closeable, Channel, ReadableByteChannel, BlockableChannel, BufferProcessor, CompletionListener, ReadableSelectionChannel, SelectionChannel
public class ReadableSizedSelectionChannel
- extends ReadableBufferedChannel
Readable byte channel enforcing a maximum size and wrapping a selectable
channel.
- Author:
- Jerome Louvel
Method Summary |
protected long |
getAvailableSize()
Returns the remaining size that should be read from the source channel. |
int |
onDrain(Buffer buffer,
int maxDrained,
Object... args)
Drains the byte buffer. |
protected void |
setAvailableSize(long availableSize)
Sets the remaining size that should be read from the source channel. |
ReadableSizedSelectionChannel
public ReadableSizedSelectionChannel(CompletionListener completionListener,
Buffer buffer,
ReadableSelectionChannel source,
long availableSize,
WakeupListener wakeupListener)
- Constructor.
- Parameters:
completionListener
- The listener to callback upon reading completion.buffer
- The source byte buffer, typically remaining from previous read
processing.source
- The source channel.availableSize
- The total available size that can be read from the source
channel.wakeupListener
- The wakeup listener that will be notified.
getAvailableSize
protected long getAvailableSize()
- Returns the remaining size that should be read from the source channel.
- Returns:
- The remaining size that should be read from the source channel.
onDrain
public int onDrain(Buffer buffer,
int maxDrained,
Object... args)
throws IOException
- Description copied from class:
ReadableBufferedChannel
- Drains the byte buffer.
- Specified by:
onDrain
in interface BufferProcessor
- Overrides:
onDrain
in class ReadableBufferedChannel
- Parameters:
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.
- Returns:
- The number of bytes drained.
- Throws:
IOException
setAvailableSize
protected void setAvailableSize(long availableSize)
throws IOException
- Sets the remaining size that should be read from the source channel.
- Parameters:
availableSize
- The remaining size that should be read from the source
channel.
- Throws:
IOException
Copyright © 2005-2013 Restlet.