Package org.eclipse.jetty.util
Class QuotedStringTokenizer
- java.lang.Object
-
- java.util.StringTokenizer
-
- org.eclipse.jetty.util.QuotedStringTokenizer
-
- All Implemented Interfaces:
Enumeration<Object>
public class QuotedStringTokenizer extends StringTokenizer
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:
StringTokenizer
-
-
Constructor Summary
Constructors Constructor Description QuotedStringTokenizer(String str)
QuotedStringTokenizer(String str, String delim)
QuotedStringTokenizer(String str, String delim, boolean returnDelimiters)
QuotedStringTokenizer(String str, String delim, boolean returnDelimiters, boolean returnQuotes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
countTokens()
Not implemented.boolean
getDouble()
boolean
getSingle()
boolean
hasMoreElements()
boolean
hasMoreTokens()
static boolean
isQuoted(String s)
Object
nextElement()
String
nextToken()
String
nextToken(String delim)
static void
quote(Appendable buffer, String input)
Quote a string into an Appendable.static String
quote(String s)
Quote a string.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
unquote(String s)
static String
unquote(String s, boolean lenient)
Unquote a string.static String
unquoteOnly(String s)
static String
unquoteOnly(String s, boolean lenient)
Unquote a string, NOT converting unicode sequences-
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 Detail
-
QuotedStringTokenizer
public QuotedStringTokenizer(String str, String delim, boolean returnDelimiters, boolean returnQuotes)
-
QuotedStringTokenizer
public QuotedStringTokenizer(String str, String delim, boolean returnDelimiters)
-
QuotedStringTokenizer
public QuotedStringTokenizer(String str)
-
-
Method Detail
-
hasMoreTokens
public boolean hasMoreTokens()
- Overrides:
hasMoreTokens
in classStringTokenizer
-
nextToken
public String nextToken() throws NoSuchElementException
- Overrides:
nextToken
in classStringTokenizer
- Throws:
NoSuchElementException
-
nextToken
public String nextToken(String delim) throws NoSuchElementException
- Overrides:
nextToken
in classStringTokenizer
- Throws:
NoSuchElementException
-
hasMoreElements
public boolean hasMoreElements()
- Specified by:
hasMoreElements
in interfaceEnumeration<Object>
- Overrides:
hasMoreElements
in classStringTokenizer
-
nextElement
public Object nextElement() throws NoSuchElementException
- Specified by:
nextElement
in interfaceEnumeration<Object>
- Overrides:
nextElement
in classStringTokenizer
- Throws:
NoSuchElementException
-
countTokens
public int countTokens()
Not implemented.- Overrides:
countTokens
in classStringTokenizer
-
quoteIfNeeded
public static String quoteIfNeeded(String s, String delim)
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.delim
- the delimiter to use to quote the string- Returns:
- quoted string
-
quote
public static String quote(String s)
Quote a string. The string is quoted only if quoting is required due to embeded delimiters, quote characters or the empty string.- Parameters:
s
- The string to quote.- Returns:
- quoted string
-
quoteOnly
public static void quoteOnly(Appendable buffer, String input)
Quote a string into an Appendable. Only quotes and backslash are escaped.- Parameters:
buffer
- The Appendableinput
- The String to quote.
-
quote
public static void quote(Appendable buffer, String input)
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
public static String unquoteOnly(String s, boolean lenient)
Unquote a string, NOT converting unicode sequences- Parameters:
s
- The string to unquote.lenient
- if true, will leave in backslashes that aren't valid escapes- Returns:
- quoted string
-
unquote
public static String unquote(String s, boolean lenient)
Unquote a string.- Parameters:
s
- The string to unquote.lenient
- true if unquoting should be lenient to escaped content, leaving some alone, false if string unescaping- Returns:
- quoted string
-
isQuoted
public static boolean isQuoted(String s)
-
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
-
-