Class TokenImpl

java.lang.Object
org.fife.rsta.ac.java.rjc.lexer.TokenImpl
All Implemented Interfaces:
Token, TokenTypes

class TokenImpl extends Object implements Token
Implementation of a token in a Java source file.
Version:
1.0
  • Field Details

    • type

      private int type
    • lexeme

      private String lexeme
      The token's text.
    • line

      private int line
      The line the token is on.
    • column

      private int column
      The column the token is on.
    • offset

      private int offset
      The absolute offset into the source of the token.
    • invalid

      private boolean invalid
      Whether the token is invalid (e.g. an invalid char of String).
  • Constructor Details

    • TokenImpl

      TokenImpl(int type, String lexeme, int line, int column, int offs)
    • TokenImpl

      TokenImpl(int type, String lexeme, int line, int column, int offs, boolean invalid)
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getColumn

      public int getColumn()
      Description copied from interface: Token
      Returns the column (offset into the line) of this token.
      Specified by:
      getColumn in interface Token
      Returns:
      The column of the token.
      See Also:
    • getLength

      public int getLength()
      Description copied from interface: Token
      Returns the length of this token.
      Specified by:
      getLength in interface Token
      Returns:
      The token's length.
    • getLexeme

      public String getLexeme()
      Description copied from interface: Token
      Returns the text of this token.
      Specified by:
      getLexeme in interface Token
      Returns:
      This token's textual value.
    • getLine

      public int getLine()
      Description copied from interface: Token
      Returns the line this token is on.
      Specified by:
      getLine in interface Token
      Returns:
      The token's line number.
      See Also:
    • getOffset

      public int getOffset()
      Description copied from interface: Token
      Returns the offset into the document of this token.
      Specified by:
      getOffset in interface Token
      Returns:
      The token's offset.
      See Also:
    • getType

      public int getType()
      Description copied from interface: Token
      Returns the type of this token.
      Specified by:
      getType in interface Token
      Returns:
      The type of this token.
    • hashCode

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

      public boolean isBasicType()
      Description copied from interface: Token
      Returns whether this token is a primitive data type (int, float, string, etc.).
      Specified by:
      isBasicType in interface Token
      Returns:
      Whether this token is a primitive data type.
    • isIdentifier

      public boolean isIdentifier()
      Description copied from interface: Token
      Returns whether this token is an identifier.
      Specified by:
      isIdentifier in interface Token
      Returns:
      Whether this token is an identifier.
    • isInvalid

      public boolean isInvalid()
      Description copied from interface: Token
      Returns whether this token is invalid.
      Specified by:
      isInvalid in interface Token
      Returns:
      Whether this token is invalid.
    • isOperator

      public boolean isOperator()
      Description copied from interface: Token
      Returns whether this token is an operator.
      Specified by:
      isOperator in interface Token
      Returns:
      Whether this token is an operator.
    • isType

      public boolean isType(int type)
      Description copied from interface: Token
      Returns whether this token is of the specified type.
      Specified by:
      isType in interface Token
      Parameters:
      type - The type to check.
      Returns:
      Whether this token is of the specified type.
    • toString

      public String toString()
      Overrides:
      toString in class Object