com.pmease.quickbuild.execution.killtree
Class QuotedStringTokenizer

java.lang.Object
  extended by java.util.StringTokenizer
      extended by com.pmease.quickbuild.execution.killtree.QuotedStringTokenizer
All Implemented Interfaces:
java.util.Enumeration<java.lang.Object>

public class QuotedStringTokenizer
extends java.util.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 '\'.

See Also:
StringTokenizer

Constructor Summary
QuotedStringTokenizer(java.lang.String str)
           
QuotedStringTokenizer(java.lang.String str, java.lang.String delim)
           
QuotedStringTokenizer(java.lang.String str, java.lang.String delim, boolean returnDelimiters)
           
QuotedStringTokenizer(java.lang.String str, java.lang.String delim, boolean returnDelimiters, boolean returnQuotes)
           
 
Method Summary
static byte convertHexDigit(byte b)
           
 int countTokens()
          Not implemented.
 boolean getDouble()
           
 boolean getSingle()
           
 boolean hasMoreElements()
           
 boolean hasMoreTokens()
           
 java.lang.Object nextElement()
           
 java.lang.String nextToken()
           
 java.lang.String nextToken(java.lang.String delim)
           
static java.lang.String quote(java.lang.String s)
          Quote a string.
static void quote(java.lang.StringBuffer buf, java.lang.String s)
          Quote a string into a StringBuffer.
static java.lang.String quote(java.lang.String s, java.lang.String delim)
          Quote a string.
 void setDouble(boolean d)
           
 void setSingle(boolean single)
           
 java.lang.String[] toArray()
           
static java.lang.String[] tokenize(java.lang.String str)
           
static java.lang.String[] tokenize(java.lang.String str, java.lang.String delimiters)
           
static java.lang.String unquote(java.lang.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(java.lang.String str,
                             java.lang.String delim,
                             boolean returnDelimiters,
                             boolean returnQuotes)
Parameters:
str - String to tokenize.
delim - List of delimiter characters as string. Can be null, to default to ' \t\n\r'
returnDelimiters - If true, nextToken() will include the delimiters, not just tokenized tokens.
returnQuotes - If true, nextToken() will include the quotation characters when they are present.

QuotedStringTokenizer

public QuotedStringTokenizer(java.lang.String str,
                             java.lang.String delim,
                             boolean returnDelimiters)

QuotedStringTokenizer

public QuotedStringTokenizer(java.lang.String str,
                             java.lang.String delim)

QuotedStringTokenizer

public QuotedStringTokenizer(java.lang.String str)
Method Detail

tokenize

public static java.lang.String[] tokenize(java.lang.String str)

tokenize

public static java.lang.String[] tokenize(java.lang.String str,
                                          java.lang.String delimiters)

toArray

public java.lang.String[] toArray()

hasMoreTokens

public boolean hasMoreTokens()
Overrides:
hasMoreTokens in class java.util.StringTokenizer

nextToken

public java.lang.String nextToken()
                           throws java.util.NoSuchElementException
Overrides:
nextToken in class java.util.StringTokenizer
Throws:
java.util.NoSuchElementException

nextToken

public java.lang.String nextToken(java.lang.String delim)
                           throws java.util.NoSuchElementException
Overrides:
nextToken in class java.util.StringTokenizer
Throws:
java.util.NoSuchElementException

hasMoreElements

public boolean hasMoreElements()
Specified by:
hasMoreElements in interface java.util.Enumeration<java.lang.Object>
Overrides:
hasMoreElements in class java.util.StringTokenizer

nextElement

public java.lang.Object nextElement()
                             throws java.util.NoSuchElementException
Specified by:
nextElement in interface java.util.Enumeration<java.lang.Object>
Overrides:
nextElement in class java.util.StringTokenizer
Throws:
java.util.NoSuchElementException

countTokens

public int countTokens()
Not implemented.

Overrides:
countTokens in class java.util.StringTokenizer

quote

public static java.lang.String quote(java.lang.String s,
                                     java.lang.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 java.lang.String quote(java.lang.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(java.lang.StringBuffer buf,
                         java.lang.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 java.lang.String unquote(java.lang.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

convertHexDigit

public static byte convertHexDigit(byte b)
Parameters:
b - An ASCII encoded character 0-9 a-f A-F
Returns:
The byte value of the character 0-16.


Copyright © 2005-2010 PMEase Inc. All Rights Reserved.