public class Token
extends java.lang.Object
Since 1.6 strips '&' in given token text.
Constructor and 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.
|
Modifier and Type | Method and 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() |
public Token(java.lang.String text, int offset)
text
- the text of the tokenoffset
- the starting position of this token in parent stringpublic Token(java.lang.String text, int offset, int length)
text
- the text of the tokenoffset
- the starting position of this token in parent stringlength
- length of tokenpublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public boolean deepEquals(Token other)
equals(Object)
).public int hashCode()
hashCode
in class java.lang.Object
public final int getLength()
public final int getOffset()
public final java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getTextFromString(java.lang.String input)
public static java.lang.String[] getTextsFromString(Token[] tokens, java.lang.String string)