public class InMemoryToken extends java.lang.Object implements Token
Token
interface.
The provided implementation is immutable and, therefore, instances can be freely shared. Moreover, the class keeps track of all the instances created so far that are still alive, reusing them when it is possible or, in other words, avoiding the creation of new instances unless it is strictly necessary.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
boolean |
equalsIgnoreCase(Token anotherToken)
Compares this token to another token ignoring case considerations.
|
static InMemoryToken |
getInstance(java.lang.String text)
Returns an
InMemoryToken with the given text. |
java.lang.String |
getText()
Returns the text that forms this element.
|
int |
hashCode() |
InMemoryToken |
toLowerCase()
Returns the lower case representation of this token.
|
java.lang.String |
toString() |
public static InMemoryToken getInstance(java.lang.String text)
InMemoryToken
with the given text.text
- the text that the space to create should consist of.InMemoryToken
with the given text.public java.lang.String getText()
LeafElement
getText
in interface LeafElement
public InMemoryToken toLowerCase()
Token
toLowerCase
in interface Token
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public boolean equalsIgnoreCase(Token anotherToken)
Token
equalsIgnoreCase
in interface Token
anotherToken
- The token to compare this token against.true
if the argument is not null
and the tokens are equal; false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object