Class NumberTokenReader
java.lang.Object
ch.andre601.expressionparser.tokens.readers.TokenReader
ch.andre601.expressionparser.tokens.readers.NumberTokenReader
TokenReader instance
that reads the provided text by trying to parse it through a
NumberFormatter
and creates a NumberToken instance
should a valid number
be found.-
Constructor Summary
ConstructorDescriptionNumberTokenReader
(int priority) Constructor for creating a new NumberTokenReader. -
Method Summary
Modifier and TypeMethodDescriptionread
(String text, ParsePosition position, ParseWarnCollector collector) Takes the provided Text and parses the content from its current position using aNumberFormat
instance.Methods inherited from class ch.andre601.expressionparser.tokens.readers.TokenReader
getPriority
-
Constructor Details
-
NumberTokenReader
public NumberTokenReader(int priority) Constructor for creating a new NumberTokenReader.- Parameters:
priority
- The priority this TokenReader should have.
-
-
Method Details
-
read
Takes the provided Text and parses the content from its current position using aNumberFormat
instance. Should the new position not be the same as the old and the parsed Number instance not be null, returns a newNumberToken
with the retrievedNumber
instance, elsenull
.
Should aNumberFormatException
be raised by the NumberFormat instance's parsing will also aParseWarnCollector Entry
be made containing the exception message.- Specified by:
read
in classTokenReader
- 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.
-