henplus.commands
Class CommandTokenizer

java.lang.Object
  extended by henplus.commands.CommandTokenizer
All Implemented Interfaces:
Iterator

public class CommandTokenizer
extends Object
implements Iterator

Utility class to split Commands into tokens.


Constructor Summary
CommandTokenizer(String cmd, String separatorPairs)
          Tokenizes a command string.
 
Method Summary
 boolean hasNext()
           
 boolean isCurrentTokenFinished()
          returns, wether the current token is finished.
static void main(String[] argv)
           
 Object next()
           
 String nextToken()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandTokenizer

public CommandTokenizer(String cmd,
                        String separatorPairs)
Tokenizes a command string. Strings are separated at any whitespace character if not within nested element. Handles nesting with the given separatorPairs; separator pairs have to be given always in pairs, even if the opening and closing element is the same. Example could be ""()[]{}. These separator pairs handle strings and elements in all kinds of parentheses.

Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator

nextToken

public String nextToken()

next

public Object next()
Specified by:
next in interface Iterator

isCurrentTokenFinished

public boolean isCurrentTokenFinished()
returns, wether the current token is finished. An token is unfinished if - it is a nested token that has not seen its closing element till the end of the string. - it is a normal token that is not followed by a whitespace


remove

public void remove()
Specified by:
remove in interface Iterator

main

public static void main(String[] argv)


? 1997..2006 Henner Zeller