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 class
A default implementation ofQueryPlus.Dependencies
.static interface
The Dependencies for QueryPlus.static class
The DependenciesHelper provides helper method for constructingQueryPlus.Dependencies
implementations forQueryPlus
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutionContext
TheExecutionContext
that will be passed toStatement
s.protected final QueryPlus.Dependencies
TheQueryPlus.Dependencies
configuring this query session.protected final StatementExecutor
TheStatementExecutor
to use to execute statements.protected final boolean
true
iff input statement should be echoed to output as it is read.protected static boolean
Set totrue
when using JLine console. -
Constructor Summary
ConstructorsConstructorDescriptionQueryPlus
(QueryPlus.Dependencies dependencies) Create a QueryPlus instance that uses the specifiedQueryPlus.Dependencies
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Add the QueryPlus ALTER SESSION statementsprotected void
Add a new QueryPlus statement.protected boolean
Evaluate the given CohQL statement.Return the currentExecutionContext
passed toStatement
s.static BufferedReader
getJlineReader
(OutputStream output, InputStream input, boolean fSilent) Return an instance of BufferedReader if JLine is present.protected void
Initialize theCoherenceQueryLanguage
with any QueryPlusStatement
extensions.static void
The main application for CohQL statement processing.protected boolean
processFile
(String sFileName) Process the given file of CohQL statements.protected Object
Process the specified query.void
repl()
Start a statement processing loop.void
run()
Run this instance of QueryPlus.
-
Field Details
-
f_dependencies
TheQueryPlus.Dependencies
configuring this query session. -
f_context
TheExecutionContext
that will be passed toStatement
s. -
f_executor
TheStatementExecutor
to use to execute statements. -
f_fEcho
protected final boolean f_fEchotrue
iff input statement should be echoed to output as it is read. Equivalent toecho on
when running an OS shell script. Defaults tofalse
.- Since:
- 24.09
-
s_fUsingJline
protected static boolean s_fUsingJlineSet totrue
when using JLine console.- Since:
- 24.09
-
-
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 currentExecutionContext
passed toStatement
s.- Returns:
- the current ExecutionContext passed to Statements
-
initializeLanguage
protected void initializeLanguage()Initialize theCoherenceQueryLanguage
with any QueryPlusStatement
extensions. -
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
- theOutputStream
that will provide outputinput
- theInputStream
that 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
-