FileDocCategorySizeDatePackage
StreamAlgorithm.javaAPI DocGlassfish v2 API5240Fri May 04 22:37:06 BST 2007com.sun.enterprise.web.connector.grizzly

StreamAlgorithm

public interface StreamAlgorithm
This interface defines the methods an instance of a ReadTask will invoke. The ReadTask will use an implementation of this interface tp predict if the NIO code>ByteBuffer has been fully read and can be processed. ReadTask will invoke the method in the following order: (a) allocate(...) (b) preParse(...) (c) parse(...) (d) contentLength() AND headerLength(); (d) postParse(...) The algorithm will stop once (c) return true
author
Jean-Francois Arcand

Fields Summary
Constructors Summary
Methods Summary
public java.nio.ByteBufferallocate(boolean useDirect, boolean useView, int size)
Allocate a ByteBuffer

param
useDirect allocate a direct ByteBuffer.
param
useView allocate a view ByteBuffer.
param
size the size of the newly created ByteBuffer.
return
a new ByteBuffer

public intcontentLength()
Return the stream content-length. If the content-length wasn't parsed, return -1.

public HandlergetHandler()
The Handler associated with this algorithm.

public intgetPort()
Return the port

public java.lang.ClassgetReadTask(SelectorThread selectorThread)
Return the class responsible for handling OP_READ.

public intheaderLength()
Return the stream header length. The header length is the length between the start of the stream and the first occurance of character '\r\n' .

public booleanparse(java.nio.ByteBuffer byteBuffer)
Parse the ByteBuffer and try to determine if the bytes stream has been fully read from the SocketChannel.

paran
byteBuffer the bytes read.
return
true if the algorithm determines the end of the stream.

public java.nio.ByteBufferpostParse(java.nio.ByteBuffer byteBuffer)
After parsing the bytes, post process the ByteBuffer

param
byteBuffer the ByteBuffer used by this algorithm
return
ByteBuffer used by this algorithm

public java.nio.ByteBufferpreParse(java.nio.ByteBuffer byteBuffer)
Before parsing the bytes, initialize and prepare the algorithm.

param
byteBuffer the ByteBuffer used by this algorithm
return
ByteBuffer used by this algorithm

public voidrecycle()
Recycle the algorithm.

public java.nio.ByteBufferrollbackParseState(java.nio.ByteBuffer byteBuffer)
Rollback the ByteBuffer to its previous state in case an error as occured.

public voidsetPort(int port)
Set the port this algorithm is used.

public voidsetSocketChannel(java.nio.channels.SocketChannel socketChannel)
Set the SocketChannel used by this algorithm