java.lang.Object
com.pnfsoftware.jeb.util.encoding.jflex.Token
All Implemented Interfaces:
Comparable<Token>

public class Token extends Object implements Comparable<Token>
A Token in a Document. Tokens do NOT store a reference to the underlying SyntaxDocument, and must generally be obtained from the SyntaxDocument methods. The reason for not storing the SyntaxDocument is simply for memory, as the number of Tokens per document can be large, you may end up with twice the memory in a SyntaxDocument with Tokens than a simple PlainDocument.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final short
    The kind of the Document.
    final int
     
    final byte
    the pair value to use if this token is one of a pair: This is how it is used: The opening part will have a positive number X The closing part will have a negative number X X should be unique for a pair: e.g.
    final long
     
    final TokenType
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Token(TokenType type, long start, int length)
    Constructs a new token
    Token(TokenType type, long start, int length, byte pairValue)
    Construct a new part of pair token
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    long
    end()
    return the end position of the token.
    boolean
     
    int
     
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • type

      public final TokenType type
    • start

      public final long start
    • length

      public final int length
    • pairValue

      public final byte pairValue
      the pair value to use if this token is one of a pair: This is how it is used: The opening part will have a positive number X The closing part will have a negative number X X should be unique for a pair: e.g. for [ pairValue = +1 for ] pairValue = -1
    • kind

      public final short kind
      The kind of the Document. This is only needed if proper Parsing of a document is needed and it makes certain operations faster. You can use any of the supplied Generic Values, or create your language specific uses by using USER_FIRST + x;
      See Also:
  • Constructor Details

    • Token

      public Token(TokenType type, long start, int length)
      Constructs a new token
    • Token

      public Token(TokenType type, long start, int length, byte pairValue)
      Construct a new part of pair token
  • Method Details

    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Token t)
      Specified by:
      compareTo in interface Comparable<Token>
    • end

      public long end()
      return the end position of the token.
      Returns:
      start + length