@Contract(threading=IMMUTABLE) public class TokenParser extends Object
This class is immutable and thread safe.
Modifier and Type | Field and Description |
---|---|
static char |
DQUOTE
Double quote
|
static char |
ESCAPE
Backward slash / escape character
|
static TokenParser |
INSTANCE |
Constructor and Description |
---|
TokenParser() |
Modifier and Type | Method and Description |
---|---|
void |
copyContent(CharSequence 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.
|
void |
copyQuotedContent(CharSequence buf,
ParserCursor cursor,
StringBuilder dst)
Transfers content enclosed with quote marks into the destination buffer.
|
void |
copyUnquotedContent(CharSequence 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 BitSet |
INIT_BITSET(int... b) |
static boolean |
isWhitespace(char ch) |
String |
parseToken(CharSequence 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.
|
String |
parseValue(CharSequence 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.
|
void |
skipWhiteSpace(CharSequence buf,
ParserCursor cursor)
Skips semantically insignificant whitespace characters and moves the cursor to the closest
non-whitespace character.
|
public static final char DQUOTE
public static final char ESCAPE
public static final TokenParser INSTANCE
public static BitSet INIT_BITSET(int... b)
public static boolean isWhitespace(char ch)
public String parseToken(CharSequence buf, ParserCursor cursor, BitSet delimiters)
buf
- buffer with the sequence of chars to be parsedcursor
- defines the bounds and current position of the bufferdelimiters
- set of delimiting characters. Can be null
if the token
is not delimited by any character.public String parseValue(CharSequence buf, ParserCursor cursor, BitSet delimiters)
buf
- buffer with the sequence of chars to be parsedcursor
- defines the bounds and current position of the bufferdelimiters
- set of delimiting characters. Can be null
if the value
is not delimited by any character.public void skipWhiteSpace(CharSequence buf, ParserCursor cursor)
buf
- buffer with the sequence of chars to be parsedcursor
- defines the bounds and current position of the bufferpublic void copyContent(CharSequence buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst)
buf
- buffer with the sequence of chars to be parsedcursor
- defines the bounds and current position of the bufferdelimiters
- set of delimiting characters. Can be null
if the value
is delimited by a whitespace only.dst
- destination bufferpublic void copyUnquotedContent(CharSequence buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst)
buf
- buffer with the sequence of chars to be parsedcursor
- defines the bounds and current position of the bufferdelimiters
- set of delimiting characters. Can be null
if the value
is delimited by a whitespace or a quote only.dst
- destination bufferpublic void copyQuotedContent(CharSequence buf, ParserCursor cursor, StringBuilder dst)
buf
- buffer with the sequence of chars to be parsedcursor
- defines the bounds and current position of the bufferdst
- destination bufferCopyright © 2005–2021 The Apache Software Foundation. All rights reserved.