Package eu.bandm.tools.lexic
Class SimpleToken<D,T>
java.lang.Object
eu.bandm.tools.lexic.SimpleToken<D,T>
- Type Parameters:
D
- the type of source document identifiersT
- the type of token types; typically an enum type
- All Implemented Interfaces:
Token<D,
T>
Simple immutable token implementation.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
SimpleToken
Creates a new instance.Note that
null
values for token text and location are generally meaningful. Whethernull
token types are also valid depends on the application. IfT
is anenum
type, it does not. However, in order to accomodate the general case, this constructor does not check the parametertype
fornull
values either.- Parameters:
type
- the token typetext
- the token text, ornull
if not availablelocation
- the token location, ornull
if not available
-
-
Method Details
-
getLocation
Returns the source location of this token.The default implementation returns
null
.- Specified by:
getLocation
in interfaceToken<D,
T> - Returns:
- the source location of this token, or
null
if not available.
-
getType
Returns the type of this token. -
getText
Returns the text content of this token.The default implementation returns
null
. -
withType
Returns a token that differs from this token only by a change of token type.The default implementation only throws
UnsupportedOperationException
. Implementing classes may override this method in order to enable the feature. -
toString
Evident
-