Package org.omegat.util
Class Token
- java.lang.Object
-
- org.omegat.util.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.
-
-
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 (unlikeequals(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 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.int
hashCode()
java.lang.String
toString()
-
-
-
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:
equals
in classjava.lang.Object
-
deepEquals
public boolean deepEquals(Token other)
Check that all fields are equal (unlikeequals(Object)
).
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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:
toString
in 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.
-
-