Class JavaToken


  • public class JavaToken
    extends Object
    A token from a parsed source file. (Awkwardly named "Java"Token since JavaCC already generates an internal class Token.) It is a node in a double linked list called token list.
    • Field Detail

      • INVALID

        public static final JavaToken INVALID
    • Constructor Detail

      • JavaToken

        public JavaToken​(int kind,
                         String text)
      • JavaToken

        public JavaToken​(int kind)
        Create a token of a certain kind.
    • Method Detail

      • getKind

        public int getKind()
      • getText

        public String getText()
      • setRange

        public void setRange​(Range range)
      • setText

        public void setText​(String text)
      • asString

        public String asString()
      • toTokenRange

        public TokenRange toTokenRange()
        Returns:
        the token range that goes from the beginning to the end of the token list this token is a part of.
      • valid

        public boolean valid()
        Used by the parser while constructing nodes. No tokens should be invalid when the parser is done.
      • invalid

        public boolean invalid()
        Used by the parser while constructing nodes. No tokens should be invalid when the parser is done.
      • insert

        public void insert​(JavaToken newToken)
        Inserts newToken into the token list just before this token.
      • insertAfter

        public void insertAfter​(JavaToken newToken)
        Inserts newToken into the token list just after this token.
      • deleteToken

        public void deleteToken()
        Links the tokens around the current token together, making the current token disappear from the list.
      • replaceToken

        public void replaceToken​(JavaToken newToken)
        Replaces the current token with newToken.
      • findLastToken

        public JavaToken findLastToken()
        Returns:
        the last token in the token list.
      • findFirstToken

        public JavaToken findFirstToken()
        Returns:
        the first token in the token list.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object