org.restlet.engine.io
Class BufferedSelectionChannel<T extends SelectionChannel>

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<T>
All Implemented Interfaces:
Closeable, Channel, BlockableChannel, BufferProcessor, SelectionChannel
Direct Known Subclasses:
ReadableBufferedChannel, WritableBufferedChannel

public abstract class BufferedSelectionChannel<T extends SelectionChannel>
extends WrapperSelectionChannel<T>
implements BufferProcessor

Byte channel wrapping a byte buffer.


Constructor Summary
BufferedSelectionChannel(Buffer buffer, T source, WakeupListener wakeupListener)
          Constructor.
 
Method Summary
 boolean canLoop(Buffer buffer, Object... args)
          Indicates if the processing loop can continue.
 void close()
          Delegates to the wrapped channel.
 Buffer getBuffer()
          Returns the source buffer.
 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.
 
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.BufferProcessor
couldFill, onDrain, onFill
 
Methods inherited from interface java.nio.channels.Channel
isOpen
 

Constructor Detail

BufferedSelectionChannel

public BufferedSelectionChannel(Buffer buffer,
                                T source,
                                WakeupListener wakeupListener)
Constructor.

Parameters:
buffer - The source byte buffer, typically remaining from previous read processing.
source - The source channel.
wakeupListener - The wakeup listener that will be notified.
Method Detail

canLoop

public boolean canLoop(Buffer buffer,
                       Object... args)
Indicates if the processing loop can continue.

Specified by:
canLoop in interface BufferProcessor
Parameters:
buffer - The IO buffer to drain.
args - The optional arguments to pass back to the callbacks.
Returns:
True if the processing loop can continue.

close

public void close()
           throws IOException
Description copied from class: WrapperChannel
Delegates to the wrapped channel.

Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Overrides:
close in class WrapperChannel<T extends SelectionChannel>
Throws:
IOException

getBuffer

public Buffer getBuffer()
Returns the source buffer.

Returns:
The source buffer.

onFillEof

public void onFillEof()
Called back when a fill operation returns with an EOF status.

Specified by:
onFillEof in interface BufferProcessor

postProcess

public void postProcess(int drained)
                 throws IOException
Does nothing by default.

Specified by:
postProcess in interface BufferProcessor
Parameters:
drained - The number of bytes drained or -1 if the filling source has ended.
Throws:
IOException

preProcess

public int preProcess(int maxDrained,
                      Object... args)
               throws IOException
Does nothing by default.

Specified by:
preProcess in interface BufferProcessor
Parameters:
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.
Returns:
The number of bytes drained or -1 if the filling source has ended.
Throws:
IOException


Copyright © 2005-2013 Restlet.