|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
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
| Method Summary | |
|---|---|
ByteBuffer |
allocate(boolean useDirect,
boolean useView,
int size)
Allocate a ByteBuffer |
int |
contentLength()
Return the stream content-length. |
Handler |
getHandler()
The Handler associated with this algorithm. |
int |
getPort()
Return the port |
Class |
getReadTask(SelectorThread selectorThread)
Return the class responsible for handling OP_READ. |
int |
headerLength()
Return the stream header length. |
boolean |
parse(ByteBuffer byteBuffer)
Parse the ByteBuffer and try to determine if the bytes
stream has been fully read from the SocketChannel. |
ByteBuffer |
postParse(ByteBuffer byteBuffer)
After parsing the bytes, post process the ByteBuffer |
ByteBuffer |
preParse(ByteBuffer byteBuffer)
Before parsing the bytes, initialize and prepare the algorithm. |
void |
recycle()
Recycle the algorithm. |
ByteBuffer |
rollbackParseState(ByteBuffer byteBuffer)
Rollback the ByteBuffer to its previous state in case
an error as occured. |
void |
setPort(int port)
Set the port this algorithm is used. |
void |
setSocketChannel(SocketChannel socketChannel)
Set the SocketChannel used by this algorithm |
| Method Detail |
|---|
int contentLength()
int headerLength()
ByteBuffer allocate(boolean useDirect,
boolean useView,
int size)
ByteBuffer
useDirect - allocate a direct ByteBuffer.useView - allocate a view ByteBuffer.size - the size of the newly created ByteBuffer.
ByteBufferByteBuffer preParse(ByteBuffer byteBuffer)
byteBuffer - the ByteBuffer used by this algorithm
ByteBuffer used by this algorithmboolean parse(ByteBuffer byteBuffer)
ByteBuffer and try to determine if the bytes
stream has been fully read from the SocketChannel.
ByteBuffer postParse(ByteBuffer byteBuffer)
ByteBuffer
byteBuffer - the ByteBuffer used by this algorithm
ByteBuffer used by this algorithmvoid recycle()
ByteBuffer rollbackParseState(ByteBuffer byteBuffer)
ByteBuffer to its previous state in case
an error as occured.
Handler getHandler()
Handler associated with this algorithm.
void setSocketChannel(SocketChannel socketChannel)
SocketChannel used by this algorithm
void setPort(int port)
port this algorithm is used.
int getPort()
Class getReadTask(SelectorThread selectorThread)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||