Package org.h2.bnf
Class Sentence
- java.lang.Object
-
- org.h2.bnf.Sentence
-
public class Sentence extends java.lang.ObjectA query context object. It contains the list of table and alias objects. Used for autocomplete.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<java.lang.String,DbTableOrView>aliasesstatic intCONTEXTThis token type means the possible choices of the item depend on the context.static intFUNCTIONThe token type for a function name.static intKEYWORDThe token type for a keyword.private DbSchemalastMatchedSchemaprivate DbTableOrViewlastMatchedTableprivate DbTableOrViewlastTableprivate static intMAX_PROCESSING_TIMEprivate java.util.HashMap<java.lang.String,java.lang.String>nextThe map of next tokens in the form type#tokenName token.private java.lang.StringqueryThe complete query string.private java.lang.StringqueryUpperThe uppercase version of the query string.private longstopAtNsprivate java.util.HashSet<DbTableOrView>tables
-
Constructor Summary
Constructors Constructor Description Sentence()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String n, java.lang.String string, int type)Add a word to the set of next tokens.voidaddAlias(java.lang.String alias, DbTableOrView table)Add an alias name and objectvoidaddTable(DbTableOrView table)Add a table.java.util.HashMap<java.lang.String,DbTableOrView>getAliases()Get the alias map.DbSchemagetLastMatchedSchema()Get the last matched schema if the last match was a schema.DbTableOrViewgetLastMatchedTable()Get the last matched table if the last match was a table.DbTableOrViewgetLastTable()Get the last added table.java.util.HashMap<java.lang.String,java.lang.String>getNext()Get the map of next tokens.java.lang.StringgetQuery()Get the query string.java.lang.StringgetQueryUpper()Get the uppercase version of the query string.java.util.HashSet<DbTableOrView>getTables()Get the set of tables.voidsetLastMatchedSchema(DbSchema schema)Set the last matched schema if the last match was a schema, or null if it was not.voidsetLastMatchedTable(DbTableOrView table)Set the last matched table if the last match was a table.voidsetQuery(java.lang.String query)Set the query string.voidstart()Start the timer to make sure processing doesn't take too long.voidstopIfRequired()Check if it's time to stop processing.
-
-
-
Field Detail
-
CONTEXT
public static final int CONTEXT
This 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:
- Constant Field Values
-
KEYWORD
public static final int KEYWORD
The token type for a keyword.- See Also:
- Constant Field Values
-
FUNCTION
public static final int FUNCTION
The token type for a function name.- See Also:
- Constant Field Values
-
MAX_PROCESSING_TIME
private static final int MAX_PROCESSING_TIME
- See Also:
- Constant Field Values
-
next
private final java.util.HashMap<java.lang.String,java.lang.String> next
The map of next tokens in the form type#tokenName token.
-
query
private java.lang.String query
The complete query string.
-
queryUpper
private java.lang.String queryUpper
The uppercase version of the query string.
-
stopAtNs
private long stopAtNs
-
lastMatchedSchema
private DbSchema lastMatchedSchema
-
lastMatchedTable
private DbTableOrView lastMatchedTable
-
lastTable
private DbTableOrView lastTable
-
tables
private java.util.HashSet<DbTableOrView> tables
-
aliases
private java.util.HashMap<java.lang.String,DbTableOrView> aliases
-
-
Method Detail
-
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
public void add(java.lang.String n, java.lang.String string, int type)Add a word to the set of next tokens.- Parameters:
n- the token namestring- an example texttype- the token type
-
addAlias
public void addAlias(java.lang.String alias, DbTableOrView table)Add an alias name and object- Parameters:
alias- the alias nametable- the alias table
-
addTable
public void addTable(DbTableOrView table)
Add a table.- Parameters:
table- the table
-
getTables
public java.util.HashSet<DbTableOrView> getTables()
Get the set of tables.- Returns:
- the set of tables
-
getAliases
public java.util.HashMap<java.lang.String,DbTableOrView> getAliases()
Get the alias map.- Returns:
- the alias map
-
getLastTable
public DbTableOrView getLastTable()
Get the last added table.- Returns:
- the last table
-
getLastMatchedSchema
public DbSchema getLastMatchedSchema()
Get the last matched schema if the last match was a schema.- Returns:
- the last schema or null
-
setLastMatchedSchema
public void setLastMatchedSchema(DbSchema schema)
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
public void setLastMatchedTable(DbTableOrView table)
Set the last matched table if the last match was a table.- Parameters:
table- the last matched table or null
-
getLastMatchedTable
public DbTableOrView getLastMatchedTable()
Get the last matched table if the last match was a table.- Returns:
- the last table or null
-
setQuery
public void setQuery(java.lang.String query)
Set the query string.- Parameters:
query- the query string
-
getQuery
public java.lang.String getQuery()
Get the query string.- Returns:
- the query
-
getQueryUpper
public java.lang.String getQueryUpper()
Get the uppercase version of the query string.- Returns:
- the uppercase query
-
getNext
public java.util.HashMap<java.lang.String,java.lang.String> getNext()
Get the map of next tokens.- Returns:
- the next token map
-
-