Class QuotedStringTokenizer
java.lang.Object
java.util.StringTokenizer
org.eclipse.jetty.util.QuotedStringTokenizer
- All Implemented Interfaces:
Enumeration<Object>
StringTokenizer with Quoting support.
This class is a copy of the java.util.StringTokenizer API and
the behaviour is the same, except that single and double quoted
string values are recognised.
Delimiters within quotes are not considered delimiters.
Quotes can be escaped with '\'.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate Stringprivate booleanprivate booleanprivate intprivate intprivate booleanprivate booleanprivate booleanprivate Stringprivate StringBufferprivate static final char[] -
Constructor Summary
ConstructorsConstructorDescriptionQuotedStringTokenizer(String str, String delim) QuotedStringTokenizer(String str, String delim, boolean returnDelimiters) QuotedStringTokenizer(String str, String delim, boolean returnDelimiters, boolean returnQuotes) -
Method Summary
Modifier and TypeMethodDescriptionintNot implemented.booleanbooleanbooleanbooleanstatic booleanprivate static booleanisValidEscaping(char c) Check that char c (which is preceded by a backslash) is a valid escape sequence.static voidquote(Appendable buffer, String input) Quote a string into an Appendable.static StringQuote a string.static StringquoteIfNeeded(String s, String delim) Quote a string.static voidquoteOnly(Appendable buffer, String input) Quote a string into an Appendable.voidsetDouble(boolean d) voidsetSingle(boolean single) static Stringstatic StringUnquote a string.static Stringstatic StringunquoteOnly(String s, boolean lenient) Unquote a string, NOT converting unicode sequences
-
Field Details
-
__delim
- See Also:
-
_string
-
_delim
-
_returnQuotes
private boolean _returnQuotes -
_returnDelimiters
private boolean _returnDelimiters -
_token
-
_hasToken
private boolean _hasToken -
_i
private int _i -
_lastStart
private int _lastStart -
_double
private boolean _double -
_single
private boolean _single -
escapes
private static final char[] escapes
-
-
Constructor Details
-
QuotedStringTokenizer
-
QuotedStringTokenizer
-
QuotedStringTokenizer
-
QuotedStringTokenizer
-
-
Method Details
-
hasMoreTokens
public boolean hasMoreTokens()- Overrides:
hasMoreTokensin classStringTokenizer
-
nextToken
- Overrides:
nextTokenin classStringTokenizer- Throws:
NoSuchElementException
-
nextToken
- Overrides:
nextTokenin classStringTokenizer- Throws:
NoSuchElementException
-
hasMoreElements
public boolean hasMoreElements()- Specified by:
hasMoreElementsin interfaceEnumeration<Object>- Overrides:
hasMoreElementsin classStringTokenizer
-
nextElement
- Specified by:
nextElementin interfaceEnumeration<Object>- Overrides:
nextElementin classStringTokenizer- Throws:
NoSuchElementException
-
countTokens
-
quoteIfNeeded
-
quote
-
quoteOnly
Quote a string into an Appendable. Only quotes and backslash are escaped.- Parameters:
buffer- The Appendableinput- The String to quote.
-
quote
Quote a string into an Appendable. The characters ", \, \n, \r, \t, \f and \b are escaped- Parameters:
buffer- The Appendableinput- The String to quote.
-
unquoteOnly
-
unquoteOnly
-
unquote
-
unquote
-
isValidEscaping
private static boolean isValidEscaping(char c) Check that char c (which is preceded by a backslash) is a valid escape sequence. -
isQuoted
-
getDouble
public boolean getDouble()- Returns:
- handle double quotes if true
-
setDouble
public void setDouble(boolean d) - Parameters:
d- handle double quotes if true
-
getSingle
public boolean getSingle()- Returns:
- handle single quotes if true
-
setSingle
public void setSingle(boolean single) - Parameters:
single- handle single quotes if true
-