## com.sun.grizzly.filter
Class ParserProtocolFilter

    java.lang.Object
      com.sun.grizzly.filter.ReadFilter
          com.sun.grizzly.filter.ParserProtocolFilter

All Implemented Interfaces:
  ProtocolFilter

    public abstract class ParserProtocolFilter

extends ReadFilter

Simple ProtocolFilter implementation which read the available bytes and delegate the decision of reading more bytes or not to a ProtocolParser. The ProtocolParser will decide if more bytes are required before continuing the invokation of the ProtocolChain.

Author:
  Jeanfrancois Arcand

Field Summary
`protected boolean` `isSkipRead` Should ParserProtocolFilter read the data from channel

Fields inherited from class com.sun.grizzly.filter.ReadFilter
`continousExecution, UDP_SOCKETADDRESS`

Fields inherited from interface com.sun.grizzly.ProtocolFilter
`SUCCESSFUL_READ`

Constructor Summary
`ParserProtocolFilter()`

Method Summary
`boolean` `execute(Context ctx)` Read available bytes and delegate the processing of them to the next ProtocolFilter in the ProtocolChain.
`protected boolean` `invokeProtocolParser(Context ctx, ProtocolParser parser)` Invoke the `ProtocolParser`.
`protected boolean` `isSkipRead()` Method returns true, if this Filter perform channel read operation on execute, or false - Filter assumes the data was read by previous Filters in a chain.
`abstract ProtocolParser` `newProtocolParser()` Return a new or cached ProtocolParser instance.
`boolean` `postExecute(Context context)` If no bytes were available, close the connection by cancelling the SelectionKey.
`protected void` `setSkipRead(boolean isSkipRead)` Method set if this Filter should perform channel read operation on execute, or should assumes the data was read by previous Filters in a chain.

Methods inherited from class com.sun.grizzly.filter.ReadFilter
`execute, isContinuousExecution, log, setContinuousExecution`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### isSkipRead

    protected boolean isSkipRead

  Should ParserProtocolFilter read the data from channel

Constructor Detail

### ParserProtocolFilter

    public ParserProtocolFilter()

Method Detail

### execute

    public boolean execute(Context ctx)
                    throws IOException

  Read available bytes and delegate the processing of them to the next ProtocolFilter in the ProtocolChain.

  Specified by:
    `execute` in interface `ProtocolFilter`
  Overrides:
    `execute` in class `ReadFilter`
  Parameters:
    `ctx` - `Context`
  Returns:
    `true` if the next ProtocolFilter on the ProtocolChain need to be invoked.
  Throws:
    `IOException`

### invokeProtocolParser

    protected boolean invokeProtocolParser(Context ctx,
                                           ProtocolParser parser)

  Invoke the `ProtocolParser`. If more bytes are required, register the `SelectionKey` back to its associated `SelectorHandler`

  Parameters:
    `ctx` - the Context object.
  Returns:
    `true` if no more bytes are needed.

### postExecute

    public boolean postExecute(Context context)
                        throws IOException

  Description copied from class: `ReadFilter`
  If no bytes were available, close the connection by cancelling the SelectionKey. If bytes were available, register the SelectionKey for new bytes.

  Specified by:
    `postExecute` in interface `ProtocolFilter`
  Overrides:
    `postExecute` in class `ReadFilter`
  Parameters:
    `context` - `Context`
  Returns:
    `true` if the previous ProtocolFilter postExecute method needs to be invoked.
  Throws:
    `IOException`

### newProtocolParser

    public abstract ProtocolParser newProtocolParser()

  Return a new or cached ProtocolParser instance.

### isSkipRead

    protected boolean isSkipRead()

  Method returns true, if this Filter perform channel read operation on execute, or false - Filter assumes the data was read by previous Filters in a chain.

  Returns:
    true, if Filter will perform channel read operation on execute. False - Filter assumes the data was read by previous Filters in a chain.

### setSkipRead

    protected void setSkipRead(boolean isSkipRead)

  Method set if this Filter should perform channel read operation on execute, or should assumes the data was read by previous Filters in a chain.

  Parameters:
    `isSkipRead` - If isSkipRead is true, this Filter will perform channel read operation on execute. If false - Filter assumes the data was read by previous Filters in a chain.

Copyright © 2008 SUN Microsystems. All Rights Reserved.