Class SQLToken
java.lang.Object
com.jsql.view.swing.sql.lexer.syntax.Token
com.jsql.view.swing.sql.lexer.syntax.SQLToken
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.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
a -- to end of line comment.static final int
C style comment, (except possibly nested)static final int
An errorstatic final int
An comment start embedded in an operatorstatic final int
An comment start embedded in an operatorstatic final int
An comment start embedded in an operatorstatic final int
An comment start embedded in an operatorstatic final int
A variable, name, or other identifierstatic final int
A bit-stringstatic final int
A floating pointstatic final int
An integerstatic final int
A string literalstatic final int
An operatorstatic final int
A reserved word (keyword)static final int
A separatorstatic final int
White spaceFields inherited from class com.jsql.view.swing.sql.lexer.syntax.Token
INITIAL_STATE, UNDEFINED_STATE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionget a String that explains the error, if this token is an error.int
get the offset into the input in characters at which this token startedint
get the offset into the input in characters at which this token endedget the contents of this tokenA description of this token.int
getID()
get the ID number of this tokenint
get the line number of the input on which this token startedint
getState()
Get an integer representing the state the tokenizer is in after returning this token.boolean
Checks this token to see if it is a comment.boolean
isError()
Checks this token to see if it is an Error.boolean
Checks this token to see if it is an identifier.boolean
Checks this token to see if it is a literal.boolean
Checks this token to see if it is a Operator.boolean
Checks this token to see if it is a reserved word.boolean
Checks this token to see if it is a Separator.boolean
Checks this token to see if it is White Space.toString()
get a representation of this token as a human-readable string.
-
Field Details
-
RESERVED_WORD
public static final int RESERVED_WORDA reserved word (keyword)- See Also:
-
IDENTIFIER
public static final int IDENTIFIERA variable, name, or other identifier- See Also:
-
LITERAL_STRING
public static final int LITERAL_STRINGA string literal- See Also:
-
LITERAL_BIT_STRING
public static final int LITERAL_BIT_STRINGA bit-string- See Also:
-
LITERAL_INTEGER
public static final int LITERAL_INTEGERAn integer- See Also:
-
LITERAL_FLOAT
public static final int LITERAL_FLOATA floating point- See Also:
-
SEPARATOR
public static final int SEPARATORA separator- See Also:
-
OPERATOR
public static final int OPERATORAn operator- See Also:
-
COMMENT_TRADITIONAL
public static final int COMMENT_TRADITIONALC style comment, (except possibly nested)- See Also:
-
COMMENT_END_OF_LINE
public static final int COMMENT_END_OF_LINEa -- to end of line comment.- See Also:
-
WHITE_SPACE
public static final int WHITE_SPACEWhite space- See Also:
-
ERROR
public static final int ERRORAn error- See Also:
-
ERROR_UNCLOSED_COMMENT
public static final int ERROR_UNCLOSED_COMMENTAn comment start embedded in an operator- See Also:
-
ERROR_UNCLOSED_STRING
public static final int ERROR_UNCLOSED_STRINGAn comment start embedded in an operator- See Also:
-
ERROR_UNCLOSED_BIT_STRING
public static final int ERROR_UNCLOSED_BIT_STRINGAn comment start embedded in an operator- See Also:
-
ERROR_BAD_BIT_STRING
public static final int ERROR_BAD_BIT_STRINGAn comment start embedded in an operator- See Also:
-
-
Constructor Details
-
SQLToken
Create a new token. The constructor is typically called by the lexer- Parameters:
id
- the id number of the tokencontents
- A string representing the text of the tokenlineNumber
- the line number of the input on which this token startedcharBegin
- the offset into the input in characters at which this token startedcharEnd
- the offset into the input in characters at which this token ended
-
SQLToken
Create a new token. The constructor is typically called by the lexer- Parameters:
id
- the id number of the tokencontents
- A string representing the text of the tokenlineNumber
- the line number of the input on which this token startedcharBegin
- the offset into the input in characters at which this token startedcharEnd
- the offset into the input in characters at which this token endedstate
- the state the tokenizer is in after returning this token.
-
-
Method Details
-
getState
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. 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. -
getID
public int getID()get the ID number of this token -
getContents
get the contents of this token- Specified by:
getContents
in classToken
- Returns:
- A string representing the text of the token
-
getLineNumber
public int getLineNumber()get the line number of the input on which this token started- Specified by:
getLineNumber
in classToken
- Returns:
- the line number of the input on which this token started
-
getCharBegin
public int getCharBegin()get the offset into the input in characters at which this token started- Specified by:
getCharBegin
in classToken
- Returns:
- the offset into the input in characters at which this token started
-
getCharEnd
public int getCharEnd()get the offset into the input in characters at which this token ended- Specified by:
getCharEnd
in classToken
- Returns:
- the offset into the input in characters at which this token ended
-
isReservedWord
public boolean isReservedWord()Checks this token to see if it is a reserved word. Reserved words are explained in Java Language Specification.- Returns:
- true if this token is a reserved word, false otherwise
-
isIdentifier
public boolean isIdentifier()Checks this token to see if it is an identifier. Identifiers are explained in Java Language Specification.- Returns:
- true if this token is an identifier, false otherwise
-
isLiteral
public boolean isLiteral()Checks this token to see if it is a literal. Literals are explained in Java Language Specification.- Returns:
- true if this token is a literal, false otherwise
-
isSeparator
public boolean isSeparator()Checks this token to see if it is a Separator. Separators are explained in Java Language Specification.- Returns:
- true if this token is a Separator, false otherwise
-
isOperator
public boolean isOperator()Checks this token to see if it is a Operator. Operators are explained in Java Language Specification.- Returns:
- true if this token is a Operator, false otherwise
-
isComment
public boolean isComment()Checks this token to see if it is a comment. -
isWhiteSpace
public boolean isWhiteSpace()Checks this token to see if it is White Space. Usually tabs, line breaks, form feed, spaces, etc.- Specified by:
isWhiteSpace
in classToken
- Returns:
- true if this token is White Space, false otherwise
-
isError
public boolean isError()Checks this token to see if it is an Error. Unfinished comments, numbers that are too big, unclosed strings, etc. -
getDescription
A description of this token. The description should be appropriate for syntax highlighting. For example "comment" is returned for a comment.- Specified by:
getDescription
in classToken
- Returns:
- a description of this token.
-
errorString
get a String that explains the error, if this token is an error.- Specified by:
errorString
in classToken
- Returns:
- a String that explains the error, if this token is an error, null otherwise.
-
toString
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.
-