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.
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SimpleToken
Creates a new instance.Note that
nullvalues for token text and location are generally meaningful. Whethernulltoken types are also valid depends on the application. IfTis anenumtype, it does not. However, in order to accomodate the general case, this constructor does not check the parametertypefornullvalues either.- Parameters:
type- the token typetext- the token text, ornullif not availablelocation- the token location, ornullif not available
-
-
Method Details
-
getLocation
Returns the source location of this token.The default implementation returns
null.- Specified by:
getLocationin interfaceToken<D,T> - Returns:
- the source location of this token, or
nullif 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
-