• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
LineParser Interface Reference

Interface for parsing lines in the HEAD section of an HTTP message. More...

Inheritance diagram for LineParser:
BasicLineParser

Description

There are individual methods for parsing a request line, a status line, or a header line. The lines to parse are passed in memory, the parser does not depend on any specific IO mechanism. Instances of this interface are expected to be stateless and thread-safe.

Author
Roland Weber
Version
Revision
589374
Date
2007-10-28 09:25:07 -0700 (Sun, 28 Oct 2007)
Since
4.0

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

ProtocolVersion parseProtocolVersion (CharArrayBuffer buffer, ParserCursor cursor) throws ParseException
 Parses the textual representation of a protocol version. More...
 
boolean hasProtocolVersion (CharArrayBuffer buffer, ParserCursor cursor)
 Checks whether there likely is a protocol version in a line. More...
 
RequestLine parseRequestLine (CharArrayBuffer buffer, ParserCursor cursor) throws ParseException
 Parses a request line. More...
 
StatusLine parseStatusLine (CharArrayBuffer buffer, ParserCursor cursor) throws ParseException
 Parses a status line. More...
 
Header parseHeader (CharArrayBuffer buffer) throws ParseException
 Creates a header from a line. More...
 

Member Function Documentation

◆ parseProtocolVersion()

ProtocolVersion parseProtocolVersion ( CharArrayBuffer  buffer,
ParserCursor  cursor 
) throws ParseException

This is needed for parsing request lines (last element) as well as status lines (first element).

Parameters
buffera buffer holding the protocol version to parse
cursorthe parser cursor containing the current position and the bounds within the buffer for the parsing operation
Returns
the parsed protocol version
Exceptions
ParseExceptionin case of a parse error

Implemented in BasicLineParser.

◆ hasProtocolVersion()

boolean hasProtocolVersion ( CharArrayBuffer  buffer,
ParserCursor  cursor 
)

This method implements a heuristic to check for a likely protocol version specification. It does not guarantee that parseProtocolVersion would not detect a parse error. This can be used to detect garbage lines before a request or status line.

Parameters
buffera buffer holding the line to inspect
cursorthe cursor at which to check for a protocol version, or negative for "end of line". Whether the check tolerates whitespace before or after the protocol version is implementation dependent.
Returns
true if there is a protocol version at the argument index (possibly ignoring whitespace), false otherwise

Implemented in BasicLineParser.

◆ parseRequestLine()

RequestLine parseRequestLine ( CharArrayBuffer  buffer,
ParserCursor  cursor 
) throws ParseException
Parameters
buffera buffer holding the line to parse
cursorthe parser cursor containing the current position and the bounds within the buffer for the parsing operation
Returns
the parsed request line
Exceptions
ParseExceptionin case of a parse error

Implemented in BasicLineParser.

◆ parseStatusLine()

StatusLine parseStatusLine ( CharArrayBuffer  buffer,
ParserCursor  cursor 
) throws ParseException
Parameters
buffera buffer holding the line to parse
cursorthe parser cursor containing the current position and the bounds within the buffer for the parsing operation
Returns
the parsed status line
Exceptions
ParseExceptionin case of a parse error

Implemented in BasicLineParser.

◆ parseHeader()

Header parseHeader ( CharArrayBuffer  buffer) throws ParseException

The full header line is expected here. Header continuation lines must be joined by the caller before invoking this method.

Parameters
buffera buffer holding the full header line. This buffer MUST NOT be re-used afterwards, since the returned object may reference the contents later.
Returns
the header in the argument buffer. The returned object MAY be a wrapper for the argument buffer. The argument buffer MUST NOT be re-used or changed afterwards.
Exceptions
ParseExceptionin case of a parse error

Implemented in BasicLineParser.