All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.util.JCStringTokenizer

java.lang.Object
   |
   +----jclass.util.JCStringTokenizer

public class JCStringTokenizer
extends Object
JCStringTokenizer controls simple linear tokenization of a String. The set of delimiters, which defaults to common whitespace characters, can be specified either during creation or on a per-token basis.

It is similar to java.util.StringTokenizer, but delimiters can be included as literals by preceding them with a backslash character (the default). It also fixes a known problem: if one delimiter immediately follows another, a null string is returned as the token instead of being skipped over. Example usage:

	String token, s = "this, is, a,, test";
	JCStringTokenizer st = new JCStringTokenizer(s);
	while (st.hasMoreTokens()) {
	    token = st.nextToken(',');
		println(token);
  }
 
This prints the following to the console:
	this
	is
	a
	test
 


Variable Index

 o strip_esc

Constructor Index

 o JCStringTokenizer(String)
Creates a tokenizer based on the specified string.

Method Index

 o countTokens(char)
Returns the next number of tokens in the String using the specified delimiter.
 o getEscapeChar()
Gets the escape char (default: \).
 o getPosition()
Returns the current scan position within the string.
 o hasMoreTokens()
Returns true if more tokens exist.
 o nextToken()
Gets the next whitespace-delimited token.
 o nextToken(char)
Gets the next token from delimited string.

The delimeter can be "escaped" by a backslash character.

To include a backslash character, precede it by another backslash character.

 o parse(String, char)
Parses the string using the specified delimiter.
 o parse(String, char, char)
Parses the string using the specified delimiter and escape char.
 o setEscapeChar(char)
Sets the escape char (default: \).

Variables

 o strip_esc
 public boolean strip_esc

Constructors

 o JCStringTokenizer
 public JCStringTokenizer(String s)
Creates a tokenizer based on the specified string.

Methods

 o parse
 public static String[] parse(String s,
                              char delim)
Parses the string using the specified delimiter.

See Also:
nextToken
 o parse
 public static String[] parse(String s,
                              char delim,
                              char escape_char)
Parses the string using the specified delimiter and escape char.

See Also:
setEscapeChar, nextToken
 o getEscapeChar
 public char getEscapeChar()
Gets the escape char (default: \).

 o setEscapeChar
 public void setEscapeChar(char c)
Sets the escape char (default: \). If 0, no escape char is used.

 o nextToken
 public String nextToken()
Gets the next whitespace-delimited token.

 o nextToken
 public String nextToken(char delim)
Gets the next token from delimited string.

The delimeter can be "escaped" by a backslash character.

To include a backslash character, precede it by another backslash character.

 o countTokens
 public int countTokens(char delim)
Returns the next number of tokens in the String using the specified delimiter.

 o hasMoreTokens
 public boolean hasMoreTokens()
Returns true if more tokens exist.

 o getPosition
 public int getPosition()
Returns the current scan position within the string.


All Packages  Class Hierarchy  This Package  Previous  Next  Index