public abstract class

AbstractMessageParser

extends Object
implements NHttpMessageParser<T extends HttpMessage>
java.lang.Object
   ↳ org.apache.http.impl.nio.codecs.AbstractMessageParser<T extends org.apache.http.HttpMessage>
Known Direct Subclasses

Class Overview

Abstract NHttpMessageParser that serves as a base for all message parser implementations.

The following parameters can be used to customize the behavior of this class:

Summary

Fields
protected final LineParser lineParser
Public Constructors
AbstractMessageParser(SessionInputBuffer buffer, LineParser parser, HttpParams params)
Creates an instance of this class.
Public Methods
int fillBuffer(ReadableByteChannel channel)
Fills the internal buffer of the parser with input data from the given ReadableByteChannel.
T parse()
Attempts to parse a complete message head from the content of the internal buffer.
void reset()
Resets the parser.
Protected Methods
abstract T createMessage(CharArrayBuffer buffer)
Creates HttpMessage instance based on the content of the input buffer containing the first line of the incoming HTTP message.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.nio.NHttpMessageParser

Fields

protected final LineParser lineParser

Public Constructors

public AbstractMessageParser (SessionInputBuffer buffer, LineParser parser, HttpParams params)

Creates an instance of this class.

Parameters
buffer the session input buffer.
parser the line parser.
params HTTP parameters.

Public Methods

public int fillBuffer (ReadableByteChannel channel)

Fills the internal buffer of the parser with input data from the given ReadableByteChannel.

Parameters
channel the input channel
Returns
  • number of bytes read.
Throws
IOException

public T parse ()

Attempts to parse a complete message head from the content of the internal buffer. If the message in the input buffer is incomplete this method will return null.

Returns
  • HTTP message head, if available, null otherwise.
Throws
HttpException
IOException

public void reset ()

Resets the parser. The parser will be ready to start parsing another HTTP message.

Protected Methods

protected abstract T createMessage (CharArrayBuffer buffer)

Creates HttpMessage instance based on the content of the input buffer containing the first line of the incoming HTTP message.

Parameters
buffer the line buffer.
Returns
  • HTTP message.
Throws
HttpException in case of HTTP protocol violation
ParseException in case of a parse error.