de.enough.polish.util
Class StringTokenizer

java.lang.Object
  extended by de.enough.polish.util.StringTokenizer
All Implemented Interfaces:
Enumeration

public class StringTokenizer
extends Object
implements Enumeration

Provides a simplified version of the J2SE StringTokenizer class for J2ME applications.

Note:: This implementation behaves like the J2SE StringTokenizer, so empty tokens are not counted and are skipped in the nextToken()/hasMoreTokens() methods. If you need to obtain empty tokens as well, please use StringUtil.split(...) instead.

Copyright (c) Enough Software 2005 - 2009

Author:
Robert Virkus, j2mepolish@enough.de
See Also:
TextUtil.split(String, char), TextUtil.split(String, char, int)

Constructor Summary
StringTokenizer(String input, char delimiter)
          Creates a new StringTokenizer.
StringTokenizer(String input, String delimiters)
          Creates a new StringTokenizer.
 
Method Summary
 int countTokens()
          Retrieves the number of tokens which are left in this tokenizer.
 boolean hasMoreElements()
           
 boolean hasMoreTokens()
          Determines whether there are more tokens left.
 Object nextElement()
           
 String nextToken()
          Retrieves the next token.
 void reset(String input, char delim)
          Resets this StringTokenizer.
 void reset(String input, String delimiters)
          Resets this StringTokenizer.
protected  void updateTokenStartPosition(String input, char[] chars, String delimiters)
          Updates the token start position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTokenizer

public StringTokenizer(String input,
                       char delimiter)
Creates a new StringTokenizer.

Parameters:
input - the input, e.g. "one;two;three"
delimiter - the delimiter char, e.g. ';'
Throws:
NullPointerException - when the input is null

StringTokenizer

public StringTokenizer(String input,
                       String delimiters)
Creates a new StringTokenizer.

Parameters:
input - the input, e.g. "one;two;three"
delimiters - the delimiters, e.g. ";:\t\n"
Throws:
NullPointerException - when the input is null
Method Detail

reset

public void reset(String input,
                  char delim)
Resets this StringTokenizer.

Parameters:
input - the input, e.g. "one;two;three"
delim - the delimiter char, e.g. ';'
Throws:
NullPointerException - when the input is null

reset

public void reset(String input,
                  String delimiters)
Resets this StringTokenizer.

Parameters:
input - the input, e.g. "one;two;three"
delimiters - the delimiters, e.g. ";:\t\n"
Throws:
NullPointerException - when the input is null

updateTokenStartPosition

protected void updateTokenStartPosition(String input,
                                        char[] chars,
                                        String delimiters)
Updates the token start position.

Parameters:
input - the input text
chars - the characters of the input text
delimiters - the delimiter characters

hasMoreTokens

public boolean hasMoreTokens()
Determines whether there are more tokens left.

Returns:
true when there are more tokens left.

nextToken

public String nextToken()
Retrieves the next token.

Returns:
the next token.
Throws:
NoSuchElementException - when there are no more elements.

countTokens

public int countTokens()
Retrieves the number of tokens which are left in this tokenizer. The current position is not modified.

Returns:
the number of tokens which are left in this tokenizer.

hasMoreElements

public boolean hasMoreElements()
Specified by:
hasMoreElements in interface Enumeration

nextElement

public Object nextElement()
Specified by:
nextElement in interface Enumeration