Package org.omegat.util
Class Token
- java.lang.Object
-
- org.omegat.util.Token
-
public class Token extends java.lang.ObjectOffset 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandeepEquals(Token other)Check that all fields are equal (unlikeequals(Object)).booleanequals(java.lang.Object other)Two tokens are thought equal if their hash code is equal.intgetLength()Returns the length of a token.intgetOffset()Returns token's offset in a source string.java.lang.StringgetTextFromString(java.lang.String input)Return the section of the string denoted by the tokenstatic 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.inthashCode()java.lang.StringtoString()
-
-
-
Constructor Detail
-
Token
public Token(java.lang.String text, int offset)Creates a new token.- Parameters:
text- the text of the tokenoffset- 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 tokenoffset- the starting position of this token in parent stringlength- 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:
equalsin classjava.lang.Object
-
deepEquals
public boolean deepEquals(Token other)
Check that all fields are equal (unlikeequals(Object)).
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.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:
toStringin classjava.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.
-
-