Package org.apache.hc.core5.util
Class Tokenizer
java.lang.Object
org.apache.hc.core5.util.Tokenizer
- Direct Known Subclasses:
TokenParser
Tokenizer that can be used as a foundation for more complex parsing routines.
Methods 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:
- 5.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfaceRepresents a predicate whether the given character is a delimiter. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyContent(CharSequence buf, Tokenizer.Cursor cursor, BitSet bitSet, StringBuilder dst) Deprecated.voidcopyContent(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate, StringBuilder dst) Transfers content into the destination buffer until a whitespace character or any of the given delimiters is encountered.voidcopyQuotedContent(CharSequence buf, Tokenizer.Cursor cursor, StringBuilder dst) Transfers content enclosed with quote marks into the destination buffer.voidcopyUnquotedContent(CharSequence buf, Tokenizer.Cursor cursor, BitSet bitSet, StringBuilder dst) voidcopyUnquotedContent(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate, StringBuilder dst) Transfers content into the destination buffer until a whitespace character, a quote, or any of the given delimiters is encountered.static Tokenizer.Delimiterdelimiters(char delimiter) static Tokenizer.Delimiterdelimiters(char... delimiters) static Tokenizer.Delimiterdelimiters(char delimiter1, char delimiter2) static Tokenizer.Delimiterdelimiters(char delimiter1, char delimiter2, char delimiter3) static Tokenizer.Delimiterdelimiters(BitSet delimiters) static BitSetINIT_BITSET(int... b) Deprecated.Do not use.static booleanisWhitespace(char ch) parseContent(CharSequence buf, Tokenizer.Cursor cursor, BitSet bitSet) Deprecated.parseContent(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate) Extracts from the sequence of chars a token terminated with any of the given delimiters or a whitespace characters.parseToken(CharSequence buf, Tokenizer.Cursor cursor, BitSet bitSet) Deprecated.parseToken(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate) Extracts from the sequence of chars a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters.parseValue(CharSequence buf, Tokenizer.Cursor cursor, BitSet bitSet) Deprecated.parseValue(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate) 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(CharSequence buf, Tokenizer.Cursor cursor) Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.
-
Field Details
-
DQUOTE
public static final char DQUOTEDouble quote- See Also:
-
ESCAPE
public static final char ESCAPEBackward slash / escape character- See Also:
-
CR
public static final int CR- See Also:
-
LF
public static final int LF- See Also:
-
SP
public static final int SP- See Also:
-
HT
public static final int HT- See Also:
-
INSTANCE
-
-
Constructor Details
-
Tokenizer
public Tokenizer()
-
-
Method Details
-
INIT_BITSET
Deprecated.Do not use. -
isWhitespace
public static boolean isWhitespace(char ch) -
delimiters
- Since:
- 5.3
-
delimiters
- Since:
- 5.3
-
delimiters
- Since:
- 5.3
-
delimiters
- Since:
- 5.3
-
delimiters
- Since:
- 5.3
-
parseContent
public String parseContent(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate) Extracts from the sequence of chars a token terminated with any of the given delimiters or a whitespace characters.- Parameters:
buf- buffer with the sequence of chars to be parsedcursor- defines the bounds and current position of the bufferdelimiterPredicate- delimiter predicate. Can benullif the token is not delimited by any character.
-
parseContent
Deprecated. -
parseToken
public String parseToken(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate) 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 bufferdelimiterPredicate- delimiter predicate. Can benullif the token is not delimited by any character.
-
parseToken
Deprecated. -
parseValue
public String parseValue(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate) 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 bufferdelimiterPredicate- delimiter predicate. Can benullif the token is not delimited by any character.
-
parseValue
Deprecated. -
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(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate, 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 bufferdelimiterPredicate- delimiter predicate. Can benullif the token is delimited by a whitespace only.dst- destination buffer
-
copyContent
@Deprecated public void copyContent(CharSequence buf, Tokenizer.Cursor cursor, BitSet bitSet, StringBuilder dst) Deprecated. -
copyUnquotedContent
public void copyUnquotedContent(CharSequence buf, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate, 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 bufferdelimiterPredicate- delimiter predicate. Can benullif the token is delimited by a whitespace or a quote only.dst- destination buffer
-
copyUnquotedContent
@Deprecated public void copyUnquotedContent(CharSequence buf, Tokenizer.Cursor cursor, BitSet bitSet, StringBuilder dst) -
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
-
copyContent(CharSequence, Cursor, Delimiter, StringBuilder)