org.restlet.engine.io
Class ReadableSizedSelectionChannel

java.lang.Object
  extended by org.restlet.engine.io.WrapperChannel<T>
      extended by org.restlet.engine.io.WrapperSelectionChannel<T>
          extended by org.restlet.engine.io.BufferedSelectionChannel<ReadableSelectionChannel>
              extended by org.restlet.engine.io.ReadableBufferedChannel
                  extended by 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

Constructor Summary
ReadableSizedSelectionChannel(CompletionListener completionListener, Buffer buffer, ReadableSelectionChannel source, long availableSize, WakeupListener wakeupListener)
          Constructor.
 
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.
 
Methods inherited from class org.restlet.engine.io.ReadableBufferedChannel
couldDrain, couldFill, isEndReached, onFill, onMessageCompleted, read, setEndReached
 
Methods inherited from class org.restlet.engine.io.BufferedSelectionChannel
canLoop, close, getBuffer, onFillEof, postProcess, preProcess
 
Methods inherited from class org.restlet.engine.io.WrapperSelectionChannel
getRegistration, isBlocking, setRegistration, toString
 
Methods inherited from class org.restlet.engine.io.WrapperChannel
getWrappedChannel, isOpen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.restlet.engine.io.SelectionChannel
getRegistration
 
Methods inherited from interface org.restlet.engine.io.BlockableChannel
isBlocking
 
Methods inherited from interface java.nio.channels.Channel
close, isOpen
 

Constructor Detail

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.
Method Detail

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.