org.mortbay.util
Class QuotedStringTokenizer

java.lang.Object
  extended byjava.util.StringTokenizer
      extended byorg.mortbay.util.QuotedStringTokenizer
All Implemented Interfaces:
Enumeration

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 doulbe quoted string values are recognized. Delimiters within quotes are not considered delimiters. Quotes can be escaped with '\'.

Author:
Greg Wilkins (gregw)
See Also:
StringTokenizer

Constructor Summary
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
 int countTokens()
          Not implemented.
 boolean getDouble()
           
 boolean getSingle()
           
 boolean hasMoreElements()
           
 boolean hasMoreTokens()
           
 Object nextElement()
           
 String nextToken()
           
 String nextToken(String delim)
           
static String quote(String s)
          Quote a string.
static void quote(StringBuffer buf, String s)
          Quote a string into a StringBuffer.
static String quote(String s, String delim)
          Quote a string.
static void quoteIfNeeded(StringBuffer buf, String s)
          Quote a string into a StringBuffer.
 void setDouble(boolean d)
           
 void setSingle(boolean single)
           
static String unquote(String s)
          Unquote a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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,
                             String delim)

QuotedStringTokenizer

public QuotedStringTokenizer(String str)
Method Detail

hasMoreTokens

public boolean hasMoreTokens()

nextToken

public String nextToken()
                 throws NoSuchElementException
Throws:
NoSuchElementException

nextToken

public String nextToken(String delim)
                 throws NoSuchElementException
Throws:
NoSuchElementException

hasMoreElements

public boolean hasMoreElements()

nextElement

public Object nextElement()
                   throws NoSuchElementException
Throws:
NoSuchElementException

countTokens

public int countTokens()
Not implemented.


quote

public static String quote(String s,
                           String delim)
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

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

quote

public static void quote(StringBuffer buf,
                         String s)
Quote a string into a StringBuffer. The characters ", \, \n, \r, \t, \f and \b are escaped

Parameters:
buf - The StringBuffer
s - The String to quote.

quoteIfNeeded

public static void quoteIfNeeded(StringBuffer buf,
                                 String s)
Quote a string into a StringBuffer. The characters ", \, \n, \r, \t, \f and \b are escaped

Parameters:
buf - The StringBuffer
s - The String to quote.

unquote

public static String unquote(String s)
Unquote a string.

Parameters:
s - The string to unquote.
Returns:
quoted string

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


Copyright © {inceptionYear}-2007 Mort Bay Consulting. All Rights Reserved.