Jadex 0.96-beta1

jadex.util
Class ExpressionTokenizer

java.lang.Object
  extended by jadex.util.ExpressionTokenizer

public class ExpressionTokenizer
extends Object

An expression tokenizer is able to parse a string with respect to different nesting-levels (eg. brackets, quotes).


Field Summary
static String ESCAPE_CHARACTERS
          The escape characters allow to include separators in the tokens.
 
Constructor Summary
ExpressionTokenizer(String string, String separators, String[] metas)
          Create a new tokenizer.
ExpressionTokenizer(String string, String separators, String[] metas, boolean retsep)
          Create a new tokenizer.
 
Method Summary
 int countTokens()
          Count the number of tokens.
 boolean hasMoreTokens()
          Test if there are more tokens available.
static void main(String[] args)
          Main for testing.
 String nextToken()
          Get the next token from the string.
 String remainingTokens()
          Get the remaining tokens as single string.
 void setPosition(int pos)
          Set the parse position manually.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ESCAPE_CHARACTERS

public static final String ESCAPE_CHARACTERS
The escape characters allow to include separators in the tokens. E.g. with escape character '\' it is possible to parse "(\))".

See Also:
Constant Field Values
Constructor Detail

ExpressionTokenizer

public ExpressionTokenizer(String string,
                           String separators,
                           String[] metas)
Create a new tokenizer.

Parameters:
string - The string.
separators - The separator chars.
metas - The nesting level delimiters.

ExpressionTokenizer

public ExpressionTokenizer(String string,
                           String separators,
                           String[] metas,
                           boolean retsep)
Create a new tokenizer.

Parameters:
string - The string.
separators - The separator chars.
metas - The nesting level delimiters.
retsep - Return the separator chars.
Method Detail

nextToken

public String nextToken()
Get the next token from the string.

Returns:
The next token.

remainingTokens

public String remainingTokens()
Get the remaining tokens as single string. When separators are to be returned, the remaining string will start with the next separator. Otherwise, the separators at the current position are skipped.

Returns:
The remaining tokens token.

hasMoreTokens

public boolean hasMoreTokens()
Test if there are more tokens available.


countTokens

public int countTokens()
Count the number of tokens.

Returns:
The number of tokens.

setPosition

public void setPosition(int pos)
Set the parse position manually. Be careful when using this method!.

Parameters:
pos - The new position.

main

public static void main(String[] args)
Main for testing.


Jadex 0.96-beta1

Submit a bug or feature
For further API reference and developer documentation, see the Jadex User Guide and the Jadex Tutorial. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, and working code examples.

Copyright (C) 2002-2007 Lars Braubach, Alexander Pokahr - University of Hamburg. Use is subject to license terms.