org.mortbay.util

Class QuotedStringTokenizer


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 '\'.
Version:
$Id: QuotedStringTokenizer.java,v 1.4 2004/05/09 20:33:04 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
java.util.StringTokenizer

Constructor Summary

QuotedStringTokenizer(String str)
QuotedStringTokenizer(String str, String delim)
QuotedStringTokenizer(String str, String delim, boolean returnTokens)
QuotedStringTokenizer(String str, String delim, boolean returnTokens, boolean returnQuotes)

Method Summary

int
countTokens()
Not implemented.
boolean
hasMoreElements()
boolean
hasMoreTokens()
Object
nextElement()
String
nextToken()
String
nextToken(String delim)
static String
quote(String s, String delim)
Quote a string.
static void
quote(StringBuffer buf, String s)
Quote a string into a StringBuffer.
static String
unquote(String s)
Unquote a string.

Constructor Details

QuotedStringTokenizer

public QuotedStringTokenizer(String str)

QuotedStringTokenizer

public QuotedStringTokenizer(String str,
                             String delim)

QuotedStringTokenizer

public QuotedStringTokenizer(String str,
                             String delim,
                             boolean returnTokens)

QuotedStringTokenizer

public QuotedStringTokenizer(String str,
                             String delim,
                             boolean returnTokens,
                             boolean returnQuotes)

Method Details

countTokens

public int countTokens()
Not implemented.

hasMoreElements

public boolean hasMoreElements()

hasMoreTokens

public boolean hasMoreTokens()

nextElement

public Object nextElement()
            throws NoSuchElementException

nextToken

public String nextToken()
            throws NoSuchElementException

nextToken

public String nextToken(String delim)
            throws NoSuchElementException

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 void quote(StringBuffer buf,
                         String s)
Quote a string into a StringBuffer.
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

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.