Class Token


  • public class Token
    extends java.lang.Object
    Offset marks the display offset of character - this might be different than the characters position in the char array due existence of multi-char characters.

    Since 1.6 strips '&' in given token text.

    • Constructor Summary

      Constructors 
      Constructor Description
      Token​(java.lang.String text, int offset)
      Creates a new token.
      Token​(java.lang.String text, int offset, int length)
      Creates a new token.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean deepEquals​(Token other)
      Check that all fields are equal (unlike equals(Object)).
      boolean equals​(java.lang.Object other)
      Two tokens are thought equal if their hash code is equal.
      int getLength()
      Returns the length of a token.
      int getOffset()
      Returns token's offset in a source string.
      java.lang.String getTextFromString​(java.lang.String input)
      Return the section of the string denoted by the token
      static java.lang.String[] getTextsFromString​(Token[] tokens, java.lang.String string)
      Get the strings represented by the provided tokens, from the original string they were produced from.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Token

        public Token​(java.lang.String text,
                     int offset)
        Creates a new token.
        Parameters:
        text - the text of the token
        offset - the starting position of this token in parent string
      • Token

        public Token​(java.lang.String text,
                     int offset,
                     int length)
        Creates a new token.
        Parameters:
        text - the text of the token
        offset - the starting position of this token in parent string
        length - length of token
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object other)
        Two tokens are thought equal if their hash code is equal.
        Overrides:
        equals in class java.lang.Object
      • deepEquals

        public boolean deepEquals​(Token other)
        Check that all fields are equal (unlike equals(Object)).
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getLength

        public final int getLength()
        Returns the length of a token.
      • getOffset

        public final int getOffset()
        Returns token's offset in a source string.
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getTextFromString

        public java.lang.String getTextFromString​(java.lang.String input)
        Return the section of the string denoted by the token
      • getTextsFromString

        public static java.lang.String[] getTextsFromString​(Token[] tokens,
                                                            java.lang.String string)
        Get the strings represented by the provided tokens, from the original string they were produced from. For debugging purposes.