Package org.apache.http.message
Class TokenParser
- java.lang.Object
-
- org.apache.http.message.TokenParser
-
@Contract(threading=IMMUTABLE) public class TokenParser extends java.lang.Object
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
Fields Modifier and Type Field Description static char
CR
US-ASCII CR, carriage return (13)static char
DQUOTE
Double quotestatic char
ESCAPE
Backward slash / escape characterstatic char
HT
US-ASCII HT, horizontal-tab (9)static TokenParser
INSTANCE
static char
LF
US-ASCII LF, line feed (10)static char
SP
US-ASCII SP, space (32)
-
Constructor Summary
Constructors Constructor Description TokenParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyContent(CharArrayBuffer buf, ParserCursor cursor, java.util.BitSet delimiters, java.lang.StringBuilder dst)
Transfers content into the destination buffer until a whitespace character or any of the given delimiters is encountered.void
copyQuotedContent(CharArrayBuffer buf, ParserCursor cursor, java.lang.StringBuilder dst)
Transfers content enclosed with quote marks into the destination buffer.void
copyUnquotedContent(CharArrayBuffer buf, ParserCursor cursor, java.util.BitSet delimiters, java.lang.StringBuilder dst)
Transfers content into the destination buffer until a whitespace character, a quote, or any of the given delimiters is encountered.static java.util.BitSet
INIT_BITSET(int... b)
static boolean
isWhitespace(char ch)
java.lang.String
parseToken(CharArrayBuffer buf, ParserCursor cursor, java.util.BitSet delimiters)
Extracts from the sequence of chars a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters.java.lang.String
parseValue(CharArrayBuffer buf, ParserCursor cursor, java.util.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.void
skipWhiteSpace(CharArrayBuffer buf, ParserCursor cursor)
Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.
-
-
-
Field Detail
-
CR
public static final char CR
US-ASCII CR, carriage return (13)- See Also:
- Constant Field Values
-
LF
public static final char LF
US-ASCII LF, line feed (10)- See Also:
- Constant Field Values
-
SP
public static final char SP
US-ASCII SP, space (32)- See Also:
- Constant Field Values
-
HT
public static final char HT
US-ASCII HT, horizontal-tab (9)- See Also:
- Constant Field Values
-
DQUOTE
public static final char DQUOTE
Double quote- See Also:
- Constant Field Values
-
ESCAPE
public static final char ESCAPE
Backward slash / escape character- See Also:
- Constant Field Values
-
INSTANCE
public static final TokenParser INSTANCE
-
-
Method Detail
-
INIT_BITSET
public static java.util.BitSet INIT_BITSET(int... b)
-
isWhitespace
public static boolean isWhitespace(char ch)
-
parseToken
public java.lang.String parseToken(CharArrayBuffer buf, ParserCursor cursor, java.util.BitSet delimiters)
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 benull
if the token is not delimited by any character.
-
parseValue
public java.lang.String parseValue(CharArrayBuffer buf, ParserCursor cursor, java.util.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
- buffer with the sequence of chars to be parsedcursor
- defines the bounds and current position of the bufferdelimiters
- set of delimiting characters. Can benull
if the value is not delimited by any character.
-
skipWhiteSpace
public void skipWhiteSpace(CharArrayBuffer buf, ParserCursor cursor)
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, java.util.BitSet delimiters, java.lang.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 benull
if the value is delimited by a whitespace only.dst
- destination buffer
-
copyUnquotedContent
public void copyUnquotedContent(CharArrayBuffer buf, ParserCursor cursor, java.util.BitSet delimiters, java.lang.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 benull
if the value is delimited by a whitespace or a quote only.dst
- destination buffer
-
copyQuotedContent
public void copyQuotedContent(CharArrayBuffer buf, ParserCursor cursor, java.lang.StringBuilder dst)
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
-
-