    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

##

strip_esc

##

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

##

countTokens(char)
  Returns the next number of tokens in the String using the specified delimiter.
getPosition()
  Returns the current scan position within the string.
hasMoreTokens()
  Returns true if more tokens exist.
nextToken()
  Gets the next whitespace-delimited token.
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.

##

strip_esc

      public boolean strip_esc

##

JCStringTokenizer

      public JCStringTokenizer(String s)

  Creates a tokenizer based on the specified string.

##

nextToken

      public String nextToken()

  Gets the next whitespace-delimited token.

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.

countTokens

      public int countTokens(char delim)

  Returns the next number of tokens in the String using the specified delimiter.

hasMoreTokens

      public boolean hasMoreTokens()

  Returns true if more tokens exist.

getPosition

      public int getPosition()

  Returns the current scan position within the string.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index