Package org.apache.http.message
Class TokenParser
java.lang.Object
org.apache.http.message.TokenParser
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
FieldsModifier and TypeFieldDescriptionstatic final charUS-ASCII CR, carriage return (13)static final charDouble quotestatic final charBackward slash / escape characterstatic final charUS-ASCII HT, horizontal-tab (9)static final TokenParserstatic final charUS-ASCII LF, line feed (10)static final charUS-ASCII SP, space (32) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyContent(CharArrayBuffer buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character or any of the given delimiters is encountered.voidcopyQuotedContent(CharArrayBuffer buf, ParserCursor cursor, StringBuilder dst) Transfers content enclosed with quote marks into the destination buffer.voidcopyUnquotedContent(CharArrayBuffer buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character, a quote, or any of the given delimiters is encountered.static BitSetINIT_BITSET(int... b) static booleanisWhitespace(char ch) parseToken(CharArrayBuffer buf, ParserCursor cursor, BitSet delimiters) Extracts from the sequence of chars a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters.parseValue(CharArrayBuffer buf, ParserCursor cursor, 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.voidskipWhiteSpace(CharArrayBuffer buf, ParserCursor cursor) Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.
-
Field Details
-
CR
public static final char CRUS-ASCII CR, carriage return (13)- See Also:
-
LF
public static final char LFUS-ASCII LF, line feed (10)- See Also:
-
SP
public static final char SPUS-ASCII SP, space (32)- See Also:
-
HT
public static final char HTUS-ASCII HT, horizontal-tab (9)- See Also:
-
DQUOTE
public static final char DQUOTEDouble quote- See Also:
-
ESCAPE
public static final char ESCAPEBackward slash / escape character- See Also:
-
INSTANCE
-
-
Constructor Details
-
TokenParser
public TokenParser()
-
-
Method Details
-
INIT_BITSET
-
isWhitespace
public static boolean isWhitespace(char ch) -
parseToken
Extracts from the sequence of chars a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters.- Parameters:
buf- buffer with the sequence of chars to be parsedcursor- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the token is not delimited by any character.
-
parseValue
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- buffer with the sequence of chars to be parsedcursor- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the value is not delimited by any character.
-
skipWhiteSpace
Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.- Parameters:
buf- buffer with the sequence of chars to be parsedcursor- defines the bounds and current position of the buffer
-
copyContent
public void copyContent(CharArrayBuffer buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character or any of the given delimiters is encountered.- Parameters:
buf- buffer with the sequence of chars to be parsedcursor- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the value is delimited by a whitespace only.dst- destination buffer
-
copyUnquotedContent
public void copyUnquotedContent(CharArrayBuffer buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character, a quote, or any of the given delimiters is encountered.- Parameters:
buf- buffer with the sequence of chars to be parsedcursor- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the value is delimited by a whitespace or a quote only.dst- destination buffer
-
copyQuotedContent
Transfers content enclosed with quote marks into the destination buffer.- Parameters:
buf- buffer with the sequence of chars to be parsedcursor- defines the bounds and current position of the bufferdst- destination buffer
-