Class NumberTokenReader

java.lang.Object
ch.andre601.expressionparser.tokens.readers.TokenReader
ch.andre601.expressionparser.tokens.readers.NumberTokenReader

public class NumberTokenReader extends TokenReader
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 Details

    • NumberTokenReader

      public NumberTokenReader(int priority)
      Constructor for creating a new NumberTokenReader.
      Parameters:
      priority - The priority this TokenReader should have.
  • Method Details

    • read

      public Token read(String text, ParsePosition position, ParseWarnCollector collector)
      Takes the provided Text and parses the content from its current position using a NumberFormat instance. Returns a NumberToken if the position is not the same after parsing, else null.
      Specified by:
      read in class TokenReader
      Parameters:
      text - The text to parse.
      position - The current position within the text.
      collector - Instance of the ParseWarnCollector used for the parsing.
      Returns:
      Possibly-null Token instance.