Package org.eclipse.jetty.util
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:
-
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 TypeMethodDescriptionint
Not implemented.boolean
boolean
boolean
static boolean
static void
quote
(Appendable buffer, String input) Quote a string into an Appendable.static String
Quote a string.static void
quoteIfNeeded
(StringBuilder buf, String str, String delim) Append into buf the provided string, adding quotes if needed.static String
quoteIfNeeded
(String s, String delim) Quote a string.static void
quoteOnly
(Appendable buffer, String input) Quote a string into an Appendable.void
setDouble
(boolean d) void
setSingle
(boolean single) static String
static String
Unquote a string.static String
static String
unquoteOnly
(String s, boolean lenient) Unquote a string, NOT converting unicode sequencesMethods inherited from class java.util.StringTokenizer
hasMoreElements, nextElement
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Enumeration
asIterator
-
Constructor Details
-
QuotedStringTokenizer
-
QuotedStringTokenizer
-
QuotedStringTokenizer
-
QuotedStringTokenizer
-
-
Method Details
-
hasMoreTokens
public boolean hasMoreTokens()- Overrides:
hasMoreTokens
in classStringTokenizer
-
nextToken
- Overrides:
nextToken
in classStringTokenizer
- Throws:
NoSuchElementException
-
nextToken
- Overrides:
nextToken
in classStringTokenizer
- Throws:
NoSuchElementException
-
countTokens
-
quoteIfNeeded
-
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 quotedelim
- the delimiter characters that will trigger automatic quoting
-
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.
-
quoteOnly
Quote a string into an Appendable. Only quotes and backslash are escaped.- Parameters:
buffer
- The Appendableinput
- The String to quote.
-
unquoteOnly
-
unquoteOnly
-
unquote
-
unquote
-
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
-