T - type of the recognized valueabstract class BaseToken<T> extends Object implements Token
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
BaseToken.BooleanToken
Concrete implementation of boolean token.
|
(package private) static class |
BaseToken.FloatToken
Concrete implementation of boolean token.
|
(package private) static class |
BaseToken.IntegerToken
Concrete implementation of boolean token.
|
(package private) static class |
BaseToken.KeywordToken
Concrete implementation of boolean token.
|
(package private) static class |
BaseToken.LiteralToken
Concrete implementation of boolean token.
|
(package private) static class |
BaseToken.StringToken
Concrete implementation of boolean token.
|
| Modifier and Type | Field and Description |
|---|---|
private static String |
FORMAT
Format string for unsupported value methods.
|
private Position |
position
Start position of token.
|
private String |
raw
Raw scanned lexeme.
|
private TokenType |
type
Token class type.
|
private T |
value
Recognized typed token value.
|
| Constructor and Description |
|---|
BaseToken(TokenType type,
Position position,
String raw,
T value)
Dedicated constructor .
|
| Modifier and Type | Method and Description |
|---|---|
String |
asString()
Get the string typed value.
|
boolean |
equals(Object obj) |
Position |
getPosition()
Start position of the token.
|
String |
getRaw()
The raw string recognized by the scanner.
|
TokenType |
getType()
Get the token type class.
|
(package private) T |
getValue()
Get the typed value.
|
int |
hashCode() |
protected void |
raiseUnsupportedValueOperationError(TokenType unsupported)
Throws always an exception.
|
String |
toString() |
private static final String FORMAT
private final TokenType type
private final Position position
private final String raw
private final T value
public TokenType getType()
Tokenpublic Position getPosition()
TokengetPosition in interface Tokennullpublic String getRaw()
Token
For example a string token "foo" has the raw value "foo" in contrast
it's typed string value will be foo.
T getValue()
nullpublic String asString()
Token
This method never throws UnsupportedOperationException.
It always calls Object.toString() on the recognized typed value.
protected void raiseUnsupportedValueOperationError(TokenType unsupported)
Used to signal that one of the as...() methods was called, but the value type does not match.
This method always throws UnsupportedOperationException.
unsupported - the unsupported typeCopyright © 2014 Sven Strittmatter. All Rights Reserved.