Package jadex.commons
Class ExpressionTokenizer
- java.lang.Object
- 
- jadex.commons.ExpressionTokenizer
 
- 
 public class ExpressionTokenizer extends java.lang.ObjectAn expression tokenizer is able to parse a string with respect to different nesting-levels (eg. brackets, quotes).
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.lang.StringallsepsAll separators.protected java.lang.StringcloseThe nesting level delimiters.static java.lang.StringESCAPE_CHARACTERSThe escape characters allow to include separators in the tokens.protected java.lang.StringopenThe nesting level delimiters.protected intposThe current tokenization position.protected booleanretsepReturn the separators.protected java.lang.StringseparatorsThe top level separators.protected java.lang.StringsourceThe source string.
 - 
Constructor SummaryConstructors Constructor Description ExpressionTokenizer(java.lang.String string, java.lang.String separators, java.lang.String[] metas)Create a new tokenizer.ExpressionTokenizer(java.lang.String string, java.lang.String separators, java.lang.String[] metas, boolean retsep)Create a new tokenizer.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcountTokens()Count the number of tokens.booleanhasMoreTokens()Test if there are more tokens available.static voidmain(java.lang.String[] args)Main for testing.protected booleannestingSeparatorAt(int pos)Check if there is a nesting level separator character at the specified position.java.lang.StringnextToken()Get the next token from the string.java.lang.StringremainingTokens()Get the remaining tokens as single string.protected booleanseparatorAt(int pos)Check if there is a separator character at the specified position.voidsetPosition(int pos)Set the parse position manually.
 
- 
- 
- 
Field Detail- 
ESCAPE_CHARACTERSpublic static final java.lang.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
 
 - 
sourceprotected java.lang.String source The source string.
 - 
separatorsprotected java.lang.String separators The top level separators.
 - 
openprotected java.lang.String open The nesting level delimiters.
 - 
closeprotected java.lang.String close The nesting level delimiters.
 - 
retsepprotected boolean retsep Return the separators.
 - 
allsepsprotected java.lang.String allseps All separators.
 - 
posprotected int pos The current tokenization position.
 
- 
 - 
Constructor Detail- 
ExpressionTokenizerpublic ExpressionTokenizer(java.lang.String string, java.lang.String separators, java.lang.String[] metas)Create a new tokenizer.- Parameters:
- string- The string.
- separators- The separator chars.
- metas- The nesting level delimiters.
 
 - 
ExpressionTokenizerpublic ExpressionTokenizer(java.lang.String string, java.lang.String separators, java.lang.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- 
nextTokenpublic java.lang.String nextToken() Get the next token from the string.- Returns:
- The next token.
 
 - 
remainingTokenspublic java.lang.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.
 
 - 
hasMoreTokenspublic boolean hasMoreTokens() Test if there are more tokens available.
 - 
countTokenspublic int countTokens() Count the number of tokens.- Returns:
- The number of tokens.
 
 - 
setPositionpublic void setPosition(int pos) Set the parse position manually. Be careful when using this method!.- Parameters:
- pos- The new position.
 
 - 
separatorAtprotected boolean separatorAt(int pos) Check if there is a separator character at the specified position.- Parameters:
- pos- The position to check.
- Returns:
- true, if the position contains a separator.
 
 - 
nestingSeparatorAtprotected boolean nestingSeparatorAt(int pos) Check if there is a nesting level separator character at the specified position.- Parameters:
- pos- The position to check.
- Returns:
- true, if the position contains a separator.
 
 - 
mainpublic static void main(java.lang.String[] args) Main for testing.
 
- 
 
-