Package com.tangosol.coherence.dslquery
Class QueryPlus
java.lang.Object
com.tangosol.coherence.dslquery.QueryPlus
QueryPlus implements a simple command line processor for a sql like
language.
QueryPlus can use JLine for enhanced command-line editing capabilities, such as having the up and down arrows move through the command history. However, JLine is not required. QueryPlus supports JLine when the JLine 3.x library is included in the QueryPlus JVM classpath. If JLine is not found, a message displays and QueryPlus starts without JLine capabilities.
- Author:
- djl 2009.08.31, jk 2014.01.02
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA default implementation ofQueryPlus.Dependencies.static interfaceThe Dependencies for QueryPlus.static classThe DependenciesHelper provides helper method for constructingQueryPlus.Dependenciesimplementations forQueryPlus. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutionContextTheExecutionContextthat will be passed toStatements.protected final QueryPlus.DependenciesTheQueryPlus.Dependenciesconfiguring this query session.protected final StatementExecutorTheStatementExecutorto use to execute statements. -
Constructor Summary
ConstructorsConstructorDescriptionQueryPlus(QueryPlus.Dependencies dependencies) Create a QueryPlus instance that uses the specifiedQueryPlus.Dependencies. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd the QueryPlus ALTER SESSION statementsprotected voidAdd a new QueryPlus statement.protected booleanEvaluate the given CohQL statement.Return the currentExecutionContextpassed toStatements.static BufferedReadergetJlineReader(OutputStream output, InputStream input, boolean fSilent) Return an instance of BufferedReader if JLine is present.protected voidInitialize theCoherenceQueryLanguagewith any QueryPlusStatementextensions.static voidThe main application for CohQL statement processing.protected booleanprocessFile(String sFileName) Process the given file of CohQL statements.protected ObjectProcess the specified query.voidrepl()Start a statement processing loop.voidrun()Run this instance of QueryPlus.
-
Field Details
-
f_dependencies
TheQueryPlus.Dependenciesconfiguring this query session. -
f_context
TheExecutionContextthat will be passed toStatements. -
f_executor
TheStatementExecutorto use to execute statements.
-
-
Constructor Details
-
QueryPlus
Create a QueryPlus instance that uses the specifiedQueryPlus.Dependencies.- Parameters:
dependencies- the Dependencies that will control the QueryPlus session
-
-
Method Details
-
run
public void run()Run this instance of QueryPlus. -
repl
public void repl()Start a statement processing loop. -
getExecutionContext
Return the currentExecutionContextpassed toStatements.- Returns:
- the current ExecutionContext passed to Statements
-
initializeLanguage
protected void initializeLanguage()Initialize theCoherenceQueryLanguagewith any QueryPlusStatementextensions. -
addStatement
Add a new QueryPlus statement.- Parameters:
builder- the statement builder to add
-
addAlterSessionStatement
protected void addAlterSessionStatement()Add the QueryPlus ALTER SESSION statements -
query
Process the specified query.- Parameters:
sQuery- a String that represents the query- Returns:
- the results of the query
-
processFile
Process the given file of CohQL statements.- Parameters:
sFileName- the name of the file CohQL containing the statements to execute- Returns:
- true if all statements in the file were processed or false if an error occurred
-
evalLine
Evaluate the given CohQL statement.- Parameters:
sLine- the CohQL statement String to be evaluated- Returns:
- a flag indicating whether to continue processing statements
-
getJlineReader
public static BufferedReader getJlineReader(OutputStream output, InputStream input, boolean fSilent) Return an instance of BufferedReader if JLine is present.- Parameters:
output- theOutputStreamthat will provide outputinput- theInputStreamthat will provide inputfSilent- if true no message will be displayed if JLine is unavailable.- Returns:
- an instance of BufferedReader or null
-
main
The main application for CohQL statement processing.- Parameters:
asArgs- an array of Strings that represents arguments
-