Top Description Fields Constructors Methods
org.apache.http.message

public Class TokenParser

extends Object
Class Inheritance
Annotations
@Contract
threading:IMMUTABLE
Imports
java.util.BitSet, org.apache.http.annotation.ThreadingBehavior, .Contract, org.apache.http.util.CharArrayBuffer

Low level parser for header field elements. The parsing routines of this class are designed to produce near zero intermediate garbage and make no intermediate copies of input data.

This class is immutable and thread safe.

Since
4.4

Field Summary

Modifier and TypeField and Description
public static final char
CR

US-ASCII CR, carriage return (13)

public static final char
DQUOTE

Double quote

public static final char
ESCAPE

Backward slash / escape character

public static final char
HT

US-ASCII HT, horizontal-tab (9)

public static final TokenParser
public static final char
LF

US-ASCII LF, line feed (10)

public static final char
SP

US-ASCII SP, space (32)

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
copyContent(final CharArrayBuffer
buffer with the sequence of chars to be parsed
buf
,
final ParserCursor
defines the bounds and current position of the buffer
cursor
,
final BitSet
set of delimiting characters. Can be null if the value is delimited by a whitespace only.
delimiters
,
final StringBuilder
destination buffer
dst
)

Transfers content into the destination buffer until a whitespace character or any of the given delimiters is encountered.

public void
copyQuotedContent(final CharArrayBuffer
buffer with the sequence of chars to be parsed
buf
,
final ParserCursor
defines the bounds and current position of the buffer
cursor
,
final StringBuilder
destination buffer
dst
)

Transfers content enclosed with quote marks into the destination buffer.

public void
copyUnquotedContent(final CharArrayBuffer
buffer with the sequence of chars to be parsed
buf
,
final ParserCursor
defines the bounds and current position of the buffer
cursor
,
final BitSet
set of delimiting characters. Can be null if the value is delimited by a whitespace or a quote only.
delimiters
,
final StringBuilder
destination buffer
dst
)

Transfers content into the destination buffer until a whitespace character, a quote, or any of the given delimiters is encountered.

public static BitSet
INIT_BITSET(final int... b)

public static boolean
isWhitespace(final char ch)

public String
parseToken(final CharArrayBuffer
buffer with the sequence of chars to be parsed
buf
,
final ParserCursor
defines the bounds and current position of the buffer
cursor
,
final BitSet
set of delimiting characters. Can be null if the token is not delimited by any character.
delimiters
)

Extracts from the sequence of chars a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters.

public String
parseValue(final CharArrayBuffer
buffer with the sequence of chars to be parsed
buf
,
final ParserCursor
defines the bounds and current position of the buffer
cursor
,
final BitSet
set of delimiting characters. Can be null if the value is not delimited by any character.
delimiters
)

Extracts from the sequence of chars a value which can be enclosed in quote marks and terminated with any of the given delimiters discarding semantically insignificant whitespace characters.

public void
skipWhiteSpace(final CharArrayBuffer
buffer with the sequence of chars to be parsed
buf
,
final ParserCursor
defines the bounds and current position of the buffer
cursor
)

Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CRback to summary
public static final char CR

US-ASCII CR, carriage return (13)

DQUOTEback to summary
public static final char DQUOTE

Double quote

ESCAPEback to summary
public static final char ESCAPE

Backward slash / escape character

HTback to summary
public static final char HT

US-ASCII HT, horizontal-tab (9)

INSTANCEback to summary
public static final TokenParser INSTANCE
LFback to summary
public static final char LF

US-ASCII LF, line feed (10)

SPback to summary
public static final char SP

US-ASCII SP, space (32)

Constructor Detail

TokenParserback to summary
public TokenParser()

Method Detail

copyContentback to summary
public void copyContent(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters, final StringBuilder dst)

Transfers content into the destination buffer until a whitespace character or any of the given delimiters is encountered.

Parameters
buf:CharArrayBuffer

buffer with the sequence of chars to be parsed

cursor:ParserCursor

defines the bounds and current position of the buffer

delimiters:BitSet

set of delimiting characters. Can be null if the value is delimited by a whitespace only.

dst:StringBuilder

destination buffer

copyQuotedContentback to summary
public void copyQuotedContent(final CharArrayBuffer buf, final ParserCursor cursor, final StringBuilder dst)

Transfers content enclosed with quote marks into the destination buffer.

Parameters
buf:CharArrayBuffer

buffer with the sequence of chars to be parsed

cursor:ParserCursor

defines the bounds and current position of the buffer

dst:StringBuilder

destination buffer

copyUnquotedContentback to summary
public void copyUnquotedContent(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters, final StringBuilder dst)

Transfers content into the destination buffer until a whitespace character, a quote, or any of the given delimiters is encountered.

Parameters
buf:CharArrayBuffer

buffer with the sequence of chars to be parsed

cursor:ParserCursor

defines the bounds and current position of the buffer

delimiters:BitSet

set of delimiting characters. Can be null if the value is delimited by a whitespace or a quote only.

dst:StringBuilder

destination buffer

INIT_BITSETback to summary
public static BitSet INIT_BITSET(final int... b)
isWhitespaceback to summary
public static boolean isWhitespace(final char ch)
parseTokenback to summary
public String parseToken(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters)

Extracts from the sequence of chars a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters.

Parameters
buf:CharArrayBuffer

buffer with the sequence of chars to be parsed

cursor:ParserCursor

defines the bounds and current position of the buffer

delimiters:BitSet

set of delimiting characters. Can be null if the token is not delimited by any character.

parseValueback to summary
public String parseValue(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters)

Extracts from the sequence of chars a value which can be enclosed in quote marks and terminated with any of the given delimiters discarding semantically insignificant whitespace characters.

Parameters
buf:CharArrayBuffer

buffer with the sequence of chars to be parsed

cursor:ParserCursor

defines the bounds and current position of the buffer

delimiters:BitSet

set of delimiting characters. Can be null if the value is not delimited by any character.

skipWhiteSpaceback to summary
public void skipWhiteSpace(final CharArrayBuffer buf, final ParserCursor cursor)

Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.

Parameters
buf:CharArrayBuffer

buffer with the sequence of chars to be parsed

cursor:ParserCursor

defines the bounds and current position of the buffer