Class TokenReader
java.lang.Object
ch.andre601.expressionparser.tokens.readers.TokenReader
- Direct Known Subclasses:
NonQuotedLiteralTokenReader,NumberTokenReader,PatternTokenReader,QuotedLiteralTokenReader
The token reader is used to find specific patterns within a provided text to then turn into a Token, "tokenizing" the
text over time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintPriority of the TokenReader instance.abstract Tokenread(String text, ParsePosition position, ParseWarnCollector collector) Abstract method that is called by the ExpressionparserEngine to turn the provided String into a token.
-
Constructor Details
-
TokenReader
public TokenReader(int priority) Constructor for creating a new TokenReader.- Parameters:
priority- The priority this TokenReader should have.
-
-
Method Details
-
getPriority
public int getPriority()Priority of the TokenReader instance.- Returns:
- Priority of the TokenReader instance.
-
read
Abstract method that is called by the ExpressionparserEngine to turn the provided String into a token.
The provided ParsePosition instance indicates the current position within the String and should be updated accordingly when parsing the String to a Token.Assuming the DefaultExpressionParserEngine is used, returning
nullwill result in skipping this TokenReader.- Parameters:
text- The text to parse.position- The current position within the text.collector- Instance of theParseWarnCollectorused for the parsing.- Returns:
- Possibly-null Token instance.
-