Package banner.types
Class Token
- java.lang.Object
-
- banner.types.Token
-
- All Implemented Interfaces:
Comparable<Token>
public class Token extends Object implements Comparable<Token>
Represents a single token of text. Note that the token does not know what Mention it is a part of, if any.- Author:
- Bob
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Token token2)booleancontains(int index)booleanequals(Object obj)intgetEnd()intgetEnd(boolean ignoreWhitespace)SentencegetSentence()intgetStart()intgetStart(boolean ignoreWhitespace)StringgetText()inthashCode()intlength()StringtoString()
-
-
-
Constructor Detail
-
Token
public Token(Sentence sentence, int start, int end)
The token is from character start to character end - 1- Parameters:
sentence-start-end-
-
-
Method Detail
-
getText
public String getText()
- Returns:
- The text for this token
-
getStart
public int getStart()
- Returns:
- The start index for this token, inclusive
-
getEnd
public int getEnd()
- Returns:
- The end index for this token, exclusive
-
getStart
public int getStart(boolean ignoreWhitespace)
- Returns:
- The start index for this token, inclusive
-
getEnd
public int getEnd(boolean ignoreWhitespace)
- Returns:
- The end index for this token, exclusive
-
contains
public boolean contains(int index)
-
length
public int length()
- Returns:
- The number of characters in this token
-
compareTo
public int compareTo(Token token2)
- Specified by:
compareToin interfaceComparable<Token>
-
-