| java.lang.Object workbench.sql.formatter.Token workbench.sql.formatter.SQLToken
SQLToken | public class SQLToken extends Token (Code) | | A SQLToken is a token that is returned by a lexer that is lexing an SQL
source file. It has several attributes describing the token:
The type of token, the text of the token, the line number on which it
occurred, the number of characters into the input at which it started, and
similarly, the number of characters into the input at which it ended.
|
Constructor Summary | |
public | SQLToken(int ID, String contents, int lineNumber, int charBegin, int charEnd) Create a new token. | public | SQLToken(int ID, String text, int lineNumber, int charBegin, int charEnd, int state) Create a new token. |
Method Summary | |
public String | errorString() get a String that explains the error, if this token is an error. | public int | getCharBegin() | public int | getCharEnd() | public String | getContents() Get the contents of this token. | public String | getDescription() A description of this token. | public int | getID() | public int | getLineNumber() | public int | getState() Get an integer representing the state the tokenizer is in after
returning this token.
Those who are interested in incremental tokenizing for performance
reasons will want to use this method to figure out where the tokenizer
may be restarted. | public String | getText() Returned an uparsed version of the contents of this
token. | public boolean | isComment() Checks this token to see if it is a comment. | public boolean | isError() Checks this token to see if it is an Error. | public boolean | isIdentifier() Checks this token to see if it is an identifier. | public boolean | isIntegerLiteral() | public boolean | isLiteral() Checks this token to see if it is a literal. | public boolean | isNumberLiteral() | public boolean | isOperator() Checks this token to see if it is a Operator. | public boolean | isReservedWord() Checks this token to see if it is a reserved word. | public boolean | isSeparator() Checks this token to see if it is a Separator. | public boolean | isWhiteSpace() Checks this token to see if it is White Space. | public String | toString() get a representation of this token as a human readable string. |
COMMENT_END_OF_LINE | final public static int COMMENT_END_OF_LINE(Code) | | a -- to end of line comment.
|
COMMENT_TRADITIONAL | final public static int COMMENT_TRADITIONAL(Code) | | C style comment, (except possibly nested)
|
ERROR | final public static int ERROR(Code) | | An error
|
ERROR_BAD_BIT_STRING | final public static int ERROR_BAD_BIT_STRING(Code) | | An comment start embedded in an operator
|
ERROR_UNCLOSED_BIT_STRING | final public static int ERROR_UNCLOSED_BIT_STRING(Code) | | An comment start embedded in an operator
|
ERROR_UNCLOSED_COMMENT | final public static int ERROR_UNCLOSED_COMMENT(Code) | | An comment start embedded in an operator
|
ERROR_UNCLOSED_STRING | final public static int ERROR_UNCLOSED_STRING(Code) | | An comment start embedded in an operator
|
IDENTIFIER | final public static int IDENTIFIER(Code) | | A variable, name, or other identifier
|
LITERAL_BIT_STRING | final public static int LITERAL_BIT_STRING(Code) | | A bit-string
|
LITERAL_FLOAT | final public static int LITERAL_FLOAT(Code) | | A floating point
|
LITERAL_INTEGER | final public static int LITERAL_INTEGER(Code) | | An integer
|
LITERAL_STRING | final public static int LITERAL_STRING(Code) | | A string literal
|
OPERATOR | final public static int OPERATOR(Code) | | An operator
|
RESERVED_WORD | final public static int RESERVED_WORD(Code) | | A reserved word (keyword)
|
SEPARATOR | final public static int SEPARATOR(Code) | | A separator
|
WHITE_SPACE | final public static int WHITE_SPACE(Code) | | White space
|
SQLToken | public SQLToken(int ID, String contents, int lineNumber, int charBegin, int charEnd)(Code) | | Create a new token.
The constructor is typically called by the lexer
Parameters: ID - the id number of the token Parameters: contents - A string representing the text of the token Parameters: lineNumber - the line number of the input on which this token started Parameters: charBegin - the offset into the input in characters at which this token started Parameters: charEnd - the offset into the input in characters at which this token ended |
SQLToken | public SQLToken(int ID, String text, int lineNumber, int charBegin, int charEnd, int state)(Code) | | Create a new token.
The constructor is typically called by the lexer
Parameters: ID - the id number of the token Parameters: text - A string representing the text of the token Parameters: lineNumber - the line number of the input on which this token started Parameters: charBegin - the offset into the input in characters at which this token started Parameters: charEnd - the offset into the input in characters at which this token ended Parameters: state - the state the tokenizer is in after returning this token. |
errorString | public String errorString()(Code) | | get a String that explains the error, if this token is an error.
a String that explains the error, if this token is an error, null otherwise. |
getCharBegin | public int getCharBegin()(Code) | | get the offset into the input in characters at which this token started
the offset into the input in characters at which this token started |
getCharEnd | public int getCharEnd()(Code) | | get the offset into the input in characters at which this token ended
the offset into the input in characters at which this token ended |
getContents | public String getContents()(Code) | | Get the contents of this token. Reserved words (keywords)
will be returned in upper case and with multiple whitespaces
replaced by a single whitespace to make comparisons easier.
"is Null" will be returned as "IS NULL".
To get the real text from the underlying SQL, use getText().
For all tokens where isReservedWord() == false getText and
getContents() will return exactly the same.
A string representing the text of the token See Also: SQLToken.getText() |
getDescription | public String getDescription()(Code) | | A description of this token. The description should
be appropriate for syntax highlighting. For example
"comment" is returned for a comment.
a description of this token. |
getID | public int getID()(Code) | | get the ID number of this token
the id number of the token |
getLineNumber | public int getLineNumber()(Code) | | get the line number of the input on which this token started
the line number of the input on which this token started |
getState | public int getState()(Code) | | Get an integer representing the state the tokenizer is in after
returning this token.
Those who are interested in incremental tokenizing for performance
reasons will want to use this method to figure out where the tokenizer
may be restarted. The tokenizer starts in Token.INITIAL_STATE, so
any time that it reports that it has returned to this state, the
tokenizer may be restarted from there.
|
getText | public String getText()(Code) | | Returned an uparsed version of the contents of this
token. To get a
|
isComment | public boolean isComment()(Code) | | Checks this token to see if it is a comment.
true if this token is a comment, false otherwise |
isError | public boolean isError()(Code) | | Checks this token to see if it is an Error.
Unfinished comments, numbers that are too big, unclosed strings, etc.
true if this token is an Error, false otherwise |
isIdentifier | public boolean isIdentifier()(Code) | | Checks this token to see if it is an identifier.
true if this token is an identifier, false otherwise |
isIntegerLiteral | public boolean isIntegerLiteral()(Code) | | |
isLiteral | public boolean isLiteral()(Code) | | Checks this token to see if it is a literal.
true if this token is a literal, false otherwise |
isNumberLiteral | public boolean isNumberLiteral()(Code) | | |
isOperator | public boolean isOperator()(Code) | | Checks this token to see if it is a Operator.
true if this token is a Operator, false otherwise |
isReservedWord | public boolean isReservedWord()(Code) | | Checks this token to see if it is a reserved word.
true if this token is a reserved word, false otherwise |
isSeparator | public boolean isSeparator()(Code) | | Checks this token to see if it is a Separator.
true if this token is a Separator, false otherwise |
isWhiteSpace | public boolean isWhiteSpace()(Code) | | Checks this token to see if it is White Space.
Usually tabs, line breaks, form feed, spaces, etc.
true if this token is White Space, false otherwise |
toString | public String toString()(Code) | | get a representation of this token as a human readable string.
The format of this string is subject to change and should only be used
for debugging purposes.
a string representation of this token |
|
|