## com.sun.grizzly.util
Interface StreamAlgorithm

Deprecated. Use the ProtocolParser instead.

    public interface StreamAlgorithm

Generic parsing interface that can be used to implement protocol specific logic parsing.

Author:
  Jean-Francois Arcand

Method Summary
`ByteBuffer` `allocate(boolean useDirect, boolean useView, int size)` Deprecated. Allocate a `ByteBuffer`
`int` `contentLength()` Deprecated. Return the stream content-length.
`Interceptor` `getHandler()` Deprecated. The `Interceptor` associated with this algorithm.
`int` `getPort()` Deprecated. Return the port
`int` `headerLength()` Deprecated. Return the stream header length.
`boolean` `parse(ByteBuffer byteBuffer)` Deprecated. Parse the `ByteBuffer` and try to determine if the bytes stream has been fully read from the `SocketChannel`.
`ByteBuffer` `postParse(ByteBuffer byteBuffer)` Deprecated. After parsing the bytes, post process the `ByteBuffer`
`ByteBuffer` `preParse(ByteBuffer byteBuffer)` Deprecated. Before parsing the bytes, initialize and prepare the algorithm.
`void` `recycle()` Deprecated. Recycle the algorithm.
`ByteBuffer` `rollbackParseState(ByteBuffer byteBuffer)` Deprecated. Rollback the `ByteBuffer` to its previous state in case an error as occured.
`void` `setPort(int port)` Deprecated. Set the `port` this algorithm is used.
`void` `setSocketChannel(SocketChannel socketChannel)` Deprecated. Set the `SocketChannel` used by this algorithm

Method Detail

### contentLength

    int contentLength()

  Deprecated.
  Return the stream content-length. If the content-length wasn't parsed, return -1.

  Returns:
    content length or -1 if content length was not parsed

### headerLength

    int headerLength()

  Deprecated.
  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' .

  Returns:
    header length

### allocate

    ByteBuffer allocate(boolean useDirect,
                        boolean useView,
                        int size)

  Deprecated.
  Allocate a `ByteBuffer`

  Parameters:
    `useDirect` - allocate a direct `ByteBuffer`.
    `useView` - allocate a view `ByteBuffer`.
    `size` - the size of the newly created `ByteBuffer`.
  Returns:
    a new `ByteBuffer`

### preParse

    ByteBuffer preParse(ByteBuffer byteBuffer)

  Deprecated.
  Before parsing the bytes, initialize and prepare the algorithm.

  Parameters:
    `byteBuffer` - the `ByteBuffer` used by this algorithm
  Returns:
    `ByteBuffer` used by this algorithm

### parse

    boolean parse(ByteBuffer byteBuffer)

  Deprecated.
  Parse the `ByteBuffer` and try to determine if the bytes stream has been fully read from the `SocketChannel`.

  Parameters:
    `byteBuffer` - the bytes read.
  Returns:
    true if the algorithm determines the end of the stream.

### postParse

    ByteBuffer postParse(ByteBuffer byteBuffer)

  Deprecated.
  After parsing the bytes, post process the `ByteBuffer`

  Parameters:
    `byteBuffer` - the `ByteBuffer` used by this algorithm
  Returns:
    `ByteBuffer` used by this algorithm

### recycle

    void recycle()

  Deprecated.
  Recycle the algorithm.

### rollbackParseState

    ByteBuffer rollbackParseState(ByteBuffer byteBuffer)

  Deprecated.
  Rollback the `ByteBuffer` to its previous state in case an error as occured.

  Parameters:
    `byteBuffer` -
  Returns:
    `ByteBuffer`

### getHandler

    Interceptor getHandler()

  Deprecated.
  The `Interceptor` associated with this algorithm.

  Returns:
    `Interceptor`

### setSocketChannel

    void setSocketChannel(SocketChannel socketChannel)

  Deprecated.
  Set the `SocketChannel` used by this algorithm

  Parameters:
    `socketChannel` - set `SocketChannel`

### setPort

    void setPort(int port)

  Deprecated.
  Set the `port` this algorithm is used.

  Parameters:
    `port` - port number

### getPort

    int getPort()

  Deprecated.
  Return the port

  Returns:
    port number being used

Copyright © 2008 SUN Microsystems. All Rights Reserved.