Package com.fathzer.soft.javaluator
Class Tokenizer
java.lang.Object
com.fathzer.soft.javaluator.Tokenizer
A String tokenizer that accepts delimiters that are greater than one character.
- Author:
- Jean-Marc Astesana
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests whether this tokens trims the tokens returned bytokenize(String)method.voidsetTrimTokens(boolean trimTokens) Sets the trimTokens attribute.Converts a string into tokens.
-
Constructor Details
-
Tokenizer
Constructor.
By default, this tokenizer trims all the tokens.- Parameters:
delimiters- the delimiters of the tokenizer, usually, the operators symbols, the brackets and the function argument separator are used as delimiter in the string.
-
-
Method Details
-
isTrimTokens
public boolean isTrimTokens()Tests whether this tokens trims the tokens returned bytokenize(String)method.- Returns:
- true if tokens are trimmed.
-
setTrimTokens
public void setTrimTokens(boolean trimTokens) Sets the trimTokens attribute.- Parameters:
trimTokens- true to have the tokens returned bytokenize(String)method trimmed.
Note that empty tokens are always omitted by this class.
-
tokenize
Converts a string into tokens.
Example: The result for the expression "-1+min(10,3)" evaluated for a DoubleEvaluator is an iterator on "-", "1", "+", "min", "(", "10", ",", "3", ")".- Parameters:
string- The string to be split into tokens- Returns:
- The tokens
-