com.indexdata.torus2.util
Class EscapingStringTokenizer

java.lang.Object
  extended by com.indexdata.torus2.util.EscapingStringTokenizer
All Implemented Interfaces:
Enumeration<String>

public class EscapingStringTokenizer
extends Object
implements Enumeration<String>

Escaping/Quoting string tokenizer, based on the code from the Polyglot Project http://www.cs.cornell.edu/projects/polyglot/


Field Summary
protected  String delim
           
protected  char escape
           
protected  String escapedDelims
           
protected  int len
           
protected  int pos
           
protected  String quotes
           
protected  boolean returnDelims
           
protected  String str
           
 
Constructor Summary
EscapingStringTokenizer(String str)
          Constructs a string tokenizer for the specified string.
EscapingStringTokenizer(String str, String delim)
          Constructs a string tokenizer for the specified string.
EscapingStringTokenizer(String str, String delim, String quotes, char escape, boolean returnDelims)
          Constructs a string tokenizer for the specified string.
EscapingStringTokenizer(String str, String delim, String quotes, char escape, boolean returnDelims, String escapedDelims)
          Constructs a string tokenizer for the specified string.
 
Method Summary
 int countTokens()
          Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.
 boolean hasMoreElements()
          Returns the same value as the hasMoreTokens method.
 boolean hasMoreTokens()
          Tests if there are more tokens available from this tokenizer's string.
 String nextElement()
          Returns the same value as the nextToken method, except that its declared return value is Object rather than String.
 String nextToken()
          Returns the next token from this string tokenizer.
 String nextToken(String delim)
          Returns the next token in this string tokenizer's string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

str

protected final String str

delim

protected String delim

quotes

protected final String quotes

escape

protected final char escape

returnDelims

protected final boolean returnDelims

pos

protected int pos

len

protected final int len

escapedDelims

protected final String escapedDelims
Constructor Detail

EscapingStringTokenizer

public EscapingStringTokenizer(String str)
Constructs a string tokenizer for the specified string. The default delimiters for StringTokenizer are used. "\"\'" are used as quotes, and '\\' is used as the escape character.


EscapingStringTokenizer

public EscapingStringTokenizer(String str,
                               String delim)
Constructs a string tokenizer for the specified string. "\"\'" are used as quotes, and '\\' is used as the escape character.


EscapingStringTokenizer

public EscapingStringTokenizer(String str,
                               String delim,
                               String quotes,
                               char escape,
                               boolean returnDelims)
Constructs a string tokenizer for the specified string. Quotes cannot be delimiters, and the escape character can be neither a quote nor a delimiter.


EscapingStringTokenizer

public EscapingStringTokenizer(String str,
                               String delim,
                               String quotes,
                               char escape,
                               boolean returnDelims,
                               String escapedDelims)
Constructs a string tokenizer for the specified string. Quotes cannot be delimiters, and the escape character can be neither a quote nor a delimiter.

Method Detail

hasMoreTokens

public boolean hasMoreTokens()
Tests if there are more tokens available from this tokenizer's string. Pre-condition: not inside a quoted string (token).


nextToken

public String nextToken()
Returns the next token from this string tokenizer.


nextToken

public String nextToken(String delim)
Returns the next token in this string tokenizer's string.


countTokens

public int countTokens()
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.


hasMoreElements

public boolean hasMoreElements()
Returns the same value as the hasMoreTokens method.

Specified by:
hasMoreElements in interface Enumeration<String>

nextElement

public String nextElement()
Returns the same value as the nextToken method, except that its declared return value is Object rather than String.

Specified by:
nextElement in interface Enumeration<String>


Copyright © 2008-2013 Index Data. All Rights Reserved.