Package org.eclipse.jetty.util
Interface QuotedStringTokenizer
- All Known Implementing Classes:
LegacyQuotedStringTokenizer
,RFC9110QuotedStringTokenizer
public interface QuotedStringTokenizer
A Tokenizer that splits a string into parts, allowing for quotes.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final QuotedStringTokenizer
A QuotedStringTokenizer for comma separated values with optional white space. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
static boolean
boolean
needsQuoting
(char c) void
quote
(Appendable buffer, String input) Quote a string into an Appendable, escaping any characters that need to be escaped.default String
Quote a string.Quote a string.void
quoteIfNeeded
(StringBuilder buf, String str) Append into buf the provided string, adding quotes if needed.Tokenize the passed string into anIterator
of tokens split from the string by delimiters.Unquote a string and expand any escaped characters
-
Field Details
-
CSV
A QuotedStringTokenizer for comma separated values with optional white space.
-
-
Method Details
-
builder
- Returns:
- A Builder for a
QuotedStringTokenizer
.
-
isQuoted
- Parameters:
s
- The string to test- Returns:
- True if the string is quoted.
-
quote
Quote a string. The string is quoted only if quoting is required due to embedded delimiters, quote characters or the empty string.- Parameters:
s
- The string to quote.- Returns:
- quoted string
-
quote
Quote a string into an Appendable, escaping any characters that need to be escaped.- Parameters:
buffer
- The Appendable to append the quoted and escaped string into.input
- The String to quote.
-
unquote
Unquote a string and expand any escaped characters- Parameters:
s
- The string to unquote.- Returns:
- unquoted string with escaped characters expanded.
-
tokenize
Tokenize the passed string into anIterator
of tokens split from the string by delimiters. Tokenization is done as the iterator is advanced.- Parameters:
string
- The string to be tokenized- Returns:
- An iterator of token strings.
-
needsQuoting
boolean needsQuoting(char c) - Parameters:
c
- A character- Returns:
- True if a string containing the character should be quoted.
-
quoteIfNeeded
Quote a string. The string is quoted only if quoting is required due to embedded delimiters, quote characters or the empty string.- Parameters:
s
- The string to quote.- Returns:
- quoted string
-
quoteIfNeeded
Append into buf the provided string, adding quotes if needed.Quoting is determined if any of the characters in the
delim
are found in the inputstr
.- Parameters:
buf
- the buffer to append tostr
- the string to possibly quote
-