Package org.h2.bnf
Class Sentence
java.lang.Object
org.h2.bnf.Sentence
A query context object. It contains the list of table and alias objects.
Used for autocomplete.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate HashMap
<String, DbTableOrView> static final int
This token type means the possible choices of the item depend on the context.static final int
The token type for a function name.static final int
The token type for a keyword.private DbSchema
private DbTableOrView
private DbTableOrView
private static final int
The map of next tokens in the form type#tokenName token.private String
The complete query string.private String
The uppercase version of the query string.private long
private HashSet
<DbTableOrView> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a word to the set of next tokens.void
addAlias
(String alias, DbTableOrView table) Add an alias name and objectvoid
addTable
(DbTableOrView table) Add a table.Get the alias map.Get the last matched schema if the last match was a schema.Get the last matched table if the last match was a table.Get the last added table.getNext()
Get the map of next tokens.getQuery()
Get the query string.Get the uppercase version of the query string.Get the set of tables.void
setLastMatchedSchema
(DbSchema schema) Set the last matched schema if the last match was a schema, or null if it was not.void
setLastMatchedTable
(DbTableOrView table) Set the last matched table if the last match was a table.void
Set the query string.void
start()
Start the timer to make sure processing doesn't take too long.void
Check if it's time to stop processing.
-
Field Details
-
CONTEXT
public static final int CONTEXTThis token type means the possible choices of the item depend on the context. For example the item represents a table name of the current database.- See Also:
-
KEYWORD
public static final int KEYWORDThe token type for a keyword.- See Also:
-
FUNCTION
public static final int FUNCTIONThe token type for a function name.- See Also:
-
MAX_PROCESSING_TIME
private static final int MAX_PROCESSING_TIME- See Also:
-
next
The map of next tokens in the form type#tokenName token. -
query
The complete query string. -
queryUpper
The uppercase version of the query string. -
stopAtNs
private long stopAtNs -
lastMatchedSchema
-
lastMatchedTable
-
lastTable
-
tables
-
aliases
-
-
Constructor Details
-
Sentence
public Sentence()
-
-
Method Details
-
start
public void start()Start the timer to make sure processing doesn't take too long. -
stopIfRequired
public void stopIfRequired()Check if it's time to stop processing. Processing auto-complete shouldn't take more than a few milliseconds. If processing is stopped, this methods throws an IllegalStateException -
add
Add a word to the set of next tokens.- Parameters:
n
- the token namestring
- an example texttype
- the token type
-
addAlias
Add an alias name and object- Parameters:
alias
- the alias nametable
- the alias table
-
addTable
Add a table.- Parameters:
table
- the table
-
getTables
Get the set of tables.- Returns:
- the set of tables
-
getAliases
Get the alias map.- Returns:
- the alias map
-
getLastTable
Get the last added table.- Returns:
- the last table
-
getLastMatchedSchema
Get the last matched schema if the last match was a schema.- Returns:
- the last schema or null
-
setLastMatchedSchema
Set the last matched schema if the last match was a schema, or null if it was not.- Parameters:
schema
- the last matched schema or null
-
setLastMatchedTable
Set the last matched table if the last match was a table.- Parameters:
table
- the last matched table or null
-
getLastMatchedTable
Get the last matched table if the last match was a table.- Returns:
- the last table or null
-
setQuery
Set the query string.- Parameters:
query
- the query string
-
getQuery
Get the query string.- Returns:
- the query
-
getQueryUpper
Get the uppercase version of the query string.- Returns:
- the uppercase query
-
getNext
Get the map of next tokens.- Returns:
- the next token map
-