Class Token

java.lang.Object
org.omegat.util.Token

public class Token extends 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 Details

    • Token

      public Token(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(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 Details

    • equals

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

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

      public int hashCode()
      Overrides:
      hashCode in class 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 String toString()
      Overrides:
      toString in class Object
    • getTextFromString

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

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