org.equanda.util
Class StringSplitter

java.lang.Object
  extended by org.equanda.util.StringSplitter
All Implemented Interfaces:
Iterable<String>, Iterator<String>

public class StringSplitter
extends Object
implements Iterator<String>, Iterable<String>

This is a variant of the StringTokenizer classes as provided by the JDK. However, this version allows zero length tokens and does not group seperators.

Author:
Joachim Van der Auwera

Constructor Summary
StringSplitter(char[] string, char sep)
           
StringSplitter(String string, char sep)
           
 
Method Summary
 boolean hasNext()
          Is there another token ?
 StringSplitter iterator()
           
 String next()
          Get the next token
 void remove()
          Remove does not work, only provide to be a complete @class{java.util.Iterator}.
 String rest()
          Returns all the following parts, including delimiters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringSplitter

public StringSplitter(String string,
                      char sep)

StringSplitter

public StringSplitter(char[] string,
                      char sep)
Method Detail

iterator

public StringSplitter iterator()
Specified by:
iterator in interface Iterable<String>

hasNext

public boolean hasNext()
Is there another token ?

Specified by:
hasNext in interface Iterator<String>
Returns:
true if there is another token

next

public String next()
            throws NoSuchElementException
Get the next token

Specified by:
next in interface Iterator<String>
Returns:
Throws:
NoSuchElementException

rest

public String rest()
            throws NoSuchElementException
Returns all the following parts, including delimiters. After the hasNext() is false.

Returns:
Throws:
NoSuchElementException

remove

public void remove()
Remove does not work, only provide to be a complete @class{java.util.Iterator}.

Specified by:
remove in interface Iterator<String>


Copyright © 2007-2009. All Rights Reserved.