org.restlet.engine.io
Class ReadableChunkedChannel

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.ReadableChunkedChannel
All Implemented Interfaces:
Closeable, Channel, ReadableByteChannel, BlockableChannel, BufferProcessor, CompletionListener, ReadableSelectionChannel, SelectionChannel

public class ReadableChunkedChannel
extends ReadableBufferedChannel

Readable byte channel capable of decoding chunked entities.


Constructor Summary
ReadableChunkedChannel(CompletionListener completionListener, Buffer buffer, ReadableSelectionChannel source, WakeupListener wakeupListener)
          Constructor.
 
Method Summary
protected  void clearLineBuilder()
          Clears the line builder and adjust its state.
protected  ChunkState getChunkState()
          Returns the chunk state.
protected  StringBuilder getLineBuilder()
          Returns the line builder to parse chunk size or trailer.
protected  BufferState getLineBuilderState()
          Returns the line builder state.
protected  int getRemainingChunkSize()
          Returns the remaining chunk size that should be read from the source channel.
 int onDrain(Buffer buffer, int maxDrained, Object... args)
          Drains the byte buffer.
protected  void setChunkState(ChunkState chunkState)
          Sets the chunk state.
protected  void setLineBuilderState(BufferState lineBuilderState)
          Sets the line builder state.
protected  void setRemainingChunkSize(int remainingChunkSize)
          Sets the remaining chunk 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

ReadableChunkedChannel

public ReadableChunkedChannel(CompletionListener completionListener,
                              Buffer buffer,
                              ReadableSelectionChannel source,
                              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.
wakeupListener - The wakeup listener that will be notified.
Method Detail

clearLineBuilder

protected void clearLineBuilder()
Clears the line builder and adjust its state.


getChunkState

protected ChunkState getChunkState()
Returns the chunk state.

Returns:
The chunk state.

getLineBuilder

protected StringBuilder getLineBuilder()
Returns the line builder to parse chunk size or trailer.

Returns:
The line builder to parse chunk size or trailer.

getLineBuilderState

protected BufferState getLineBuilderState()
Returns the line builder state.

Returns:
The line builder state.

getRemainingChunkSize

protected int getRemainingChunkSize()
Returns the remaining chunk size that should be read from the source channel.

Returns:
The remaining chunk size that should be read from the source channel.

onDrain

public int onDrain(Buffer buffer,
                   int maxDrained,
                   Object... args)
            throws IOException
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 "functional" bytes drained.
Throws:
IOException

setChunkState

protected void setChunkState(ChunkState chunkState)
Sets the chunk state.

Parameters:
chunkState - The chunk state.

setLineBuilderState

protected void setLineBuilderState(BufferState lineBuilderState)
Sets the line builder state.

Parameters:
lineBuilderState - The line builder state.

setRemainingChunkSize

protected void setRemainingChunkSize(int remainingChunkSize)
Sets the remaining chunk size that should be read from the source channel.

Parameters:
remainingChunkSize - The remaining chunk size that should be read from the source channel.


Copyright © 2005-2013 Restlet.