Class QuotedLiteralTokenReader

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

public class QuotedLiteralTokenReader extends TokenReader
TokenReader instance that parses the provided text by looking for the appearance of the provided char.
Should one be found will everything until the next appearance of this char, or until the end of the text, be included in a new StringToken instance.
  • Constructor Details

    • QuotedLiteralTokenReader

      public QuotedLiteralTokenReader(int priority, char character)
      Constructor for creating a new QuotedLiteralTokenReader.
      Parameters:
      priority - The priority this TokenReader should have.
      character - Character used as the quote character.
  • Method Details

    • read

      public Token read(String text, ParsePosition position, ParseWarnCollector collector)
      Checks if the current position is less than the text length and if the character at current position is the character set in this TokenReader.
      Should it be true, iterates through the remaining text until it finds another instance of the character, or hits the end of the text, after which a StringToken with the found String will be returned.
      May return null if the current position is equal or larger than text length, or the character at current position is not the one set.
      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.