Class ParserToken

    • Constructor Detail

      • ParserToken

        public ParserToken​(Tag type,
                           String text,
                           int start,
                           int end)
        Instantiates a new Parser token.
        Parameters:
        type - the type
        text - the text
        start - the start
        end - the end
      • ParserToken

        public ParserToken​(Tag type,
                           String text,
                           int start)
        Instantiates a new Parser token.
        Parameters:
        type - the type
        text - the text
        start - the start
      • ParserToken

        public ParserToken​(Tag type,
                           String text,
                           int start,
                           int end,
                           String[] variables)
        Instantiates a new Parser token.
        Parameters:
        type - the type
        text - the text
        start - the start
        end - the end
        variables - the variables
    • Method Detail

      • getEndOffset

        public int getEndOffset()
        Gets the ending character offset of the token in the stream.
        Returns:
        the ending character offset
      • getStartOffset

        public int getStartOffset()
        Gets the starting character offset of the token in the stream.
        Returns:
        the starting character offset
      • getText

        public String getText()
        Gets the extracted surface text of the token
        Returns:
        the surface text of the token
      • getType

        public Tag getType()
        Gets the token's associated type
        Returns:
        the token's type
      • getVariable

        public String getVariable​(int index)
        Gets a variable captured with the token.
        Parameters:
        index - the index of the variable
        Returns:
        the variable value or null if the index is invalid or there are no variables
      • getVariableCount

        public int getVariableCount()
        Gets the number of variables associated with the token
        Returns:
        the number of variables
      • getVariables

        public String[] getVariables()
        Gets the token variables as an array of String
        Returns:
        the string array of token variables
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isInstance

        public boolean isInstance​(Tag... tags)
        Checks if the token's tag is an instance of one of the given tags
        Parameters:
        tags - the tags to check
        Returns:
        True if this token's tag is an instance of any of the given tags