java.util
Class StringTokenizer

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

public class StringTokenizer
extends Object
implements Enumeration

This class has been developed to parse strings with delimiters

Author:
Juan Antonio Brenha Moral

Constructor Summary
StringTokenizer(String s)
          Assigns the delimeter as ',' by default.
StringTokenizer(String s, String delimiter)
          The constructor
 
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()
          Method implemented by interface requirement
 boolean hasMoreTokens()
          Method used to know if exists new tokens
 Object nextElement()
          Method implemented by interface requirement
 String nextToken()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTokenizer

public StringTokenizer(String s)
Assigns the delimeter as ',' by default.

Parameters:
s - String to be StringTokenizer

StringTokenizer

public StringTokenizer(String s,
                       String delimiter)
The constructor

Parameters:
s -
delimiter -
Method Detail

countTokens

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

Returns:
the number of tokens remaining in the string using the current delimiter set.

hasMoreTokens

public boolean hasMoreTokens()
Method used to know if exists new tokens

Returns:
true iff there are more tokens

hasMoreElements

public boolean hasMoreElements()
Method implemented by interface requirement

Specified by:
hasMoreElements in interface Enumeration

nextToken

public String nextToken()
                 throws NoSuchElementException
Returns:
Next token
Throws:
NoSuchElementException - If there is no token left

nextElement

public Object nextElement()
Method implemented by interface requirement

Specified by:
nextElement in interface Enumeration
Returns:
Returns Object which must be cast appropriately. Returns null if no more objects are available.