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
-
Method Summary
Modifier and TypeMethodDescriptionint
Priority of the TokenReader instance.abstract Token
read
(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 providedParsePosition 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
null
will result in skipping this TokenReader.- Parameters:
text
- The text to parse.position
- The current position within the text.collector
- Instance of theParseWarnCollector
used for the parsing.- Returns:
- Possibly-null
Token instance
.
-