@InternalApi public interface Token
The available implementations of Token
are primarily guided by the implementation of the tokenization
and the needs of the parser and included visitors. It does not distinguish all types of tokens. For example there is
QuotedIdentifierToken
because the tokenization needs handling for
quoted identifiers, while a normal identifier is a GenericToken
, because that is handled by the fallback
tokenization after checking for all other types. On the other hand, open and close curly braces, square brackets and
parentheses each have their own type, as the parser may need this to find nested contexts.
Modifier and Type | Method and Description |
---|---|
void |
appendTo(java.lang.StringBuilder sb)
Appends the current token to the supplied String builder.
|
boolean |
equalsIgnoreCase(java.lang.String tokenText)
Case-insensitive equality of this tokens text using an equivalent of
String.equalsIgnoreCase(String) . |
boolean |
isValidIdentifier()
Detects if the token is valid as an identifier (ignoring length constraints).
|
boolean |
isWhitespaceOrComment() |
int |
length()
Token text length.
|
int |
position()
Token position.
|
java.lang.String |
text()
Token text.
|
java.lang.CharSequence |
textAsCharSequence()
Token text as
CharSequence . |
java.lang.String text()
textAsCharSequence()
java.lang.CharSequence textAsCharSequence()
CharSequence
.
An basic implementation should return text()
. As an optimization, implementations may return their
contained CharSequence
to avoid unnecessary conversion to string.
text()
void appendTo(java.lang.StringBuilder sb)
A basic implementation should do sb.append(text())
or sb.append(textAsCharSequence())
.
sb
- String builder to append toint position()
int length()
boolean isWhitespaceOrComment()
true
if this token is whitespace or a comment, false
for all other tokensboolean equalsIgnoreCase(java.lang.String tokenText)
String.equalsIgnoreCase(String)
.
A basic implementation should do text().equalsIgnoreCase(tokenText)
.
tokenText
- Token text to comparetrue
if tokenText
is equal - ignoring case - to the text of this token,
false
otherwiseboolean isValidIdentifier()
This will always return false
for ReservedToken
or other
specialised tokens (e.g. OperatorToken
with IS
or LIKE
)
that can't occur as an identifier.
true
if the token is valid as an identifier, false
otherwiseCopyright © 2001-2022 Jaybird (Firebird JDBC/JCA) team. All rights reserved.