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 is a class that 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. 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 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.

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 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