Package com.tangosol.coherence.dslquery
Class QueryPlus
- java.lang.Object
-
- com.tangosol.coherence.dslquery.QueryPlus
-
public class QueryPlus extends Object
QueryPlus implements a simple command line processor for a sql like language.- Author:
- djl 2009.08.31, jk 2014.01.02
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQueryPlus.DefaultDependenciesA default implementation ofQueryPlus.Dependencies.static interfaceQueryPlus.DependenciesThe Dependencies for QueryPlus.static classQueryPlus.DependenciesHelperThe DependenciesHelper provides helper method for constructingQueryPlus.Dependenciesimplementations forQueryPlus.
-
Field Summary
Fields Modifier and Type Field Description protected ExecutionContextf_contextTheExecutionContextthat will be passed toStatements.protected QueryPlus.Dependenciesf_dependenciesTheQueryPlus.Dependenciesconfiguring this query session.protected StatementExecutorf_executorTheStatementExecutorto use to execute statements.
-
Constructor Summary
Constructors Constructor Description QueryPlus(QueryPlus.Dependencies dependencies)Create a QueryPlus instance that uses the specifiedQueryPlus.Dependencies.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAlterSessionStatement()Add the QueryPlus ALTER SESSION statementsprotected voidaddStatement(AbstractQueryPlusStatementBuilder builder)Add a new QueryPlus statement.protected booleanevalLine(String sLine)Evaluate the given CohQL statement.ExecutionContextgetExecutionContext()Return the currentExecutionContextpassed toStatements.static BufferedReadergetJlineReader(OutputStream output, InputStream input, boolean fSilent)Return an instance of BufferedReader if JLine is present.protected voidinitializeLanguage()Initialize theCoherenceQueryLanguagewith any QueryPlusStatementextensions.static voidmain(String[] asArgs)The main application for CohQL statement processing.protected booleanprocessFile(String sFileName)Process the given file of CohQL statements.protected Objectquery(String sQuery)Process the specified query.voidrepl()Start a statement processing loop.voidrun()Run this instance of QueryPlus.
-
-
-
Field Detail
-
f_dependencies
protected final QueryPlus.Dependencies f_dependencies
TheQueryPlus.Dependenciesconfiguring this query session.
-
f_context
protected final ExecutionContext f_context
TheExecutionContextthat will be passed toStatements.
-
f_executor
protected final StatementExecutor f_executor
TheStatementExecutorto use to execute statements.
-
-
Constructor Detail
-
QueryPlus
public QueryPlus(QueryPlus.Dependencies dependencies)
Create a QueryPlus instance that uses the specifiedQueryPlus.Dependencies.- Parameters:
dependencies- the Dependencies that will control the QueryPlus session
-
-
Method Detail
-
run
public void run()
Run this instance of QueryPlus.
-
repl
public void repl()
Start a statement processing loop.
-
getExecutionContext
public ExecutionContext getExecutionContext()
Return the currentExecutionContextpassed toStatements.- Returns:
- the current ExecutionContext passed to Statements
-
initializeLanguage
protected void initializeLanguage()
Initialize theCoherenceQueryLanguagewith any QueryPlusStatementextensions.
-
addStatement
protected void addStatement(AbstractQueryPlusStatementBuilder builder)
Add a new QueryPlus statement.- Parameters:
builder- the statement builder to add
-
addAlterSessionStatement
protected void addAlterSessionStatement()
Add the QueryPlus ALTER SESSION statements
-
query
protected Object query(String sQuery)
Process the specified query.- Parameters:
sQuery- a String that represents the query- Returns:
- the results of the query
-
processFile
protected boolean processFile(String sFileName)
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
protected boolean evalLine(String sLine)
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
public static void main(String[] asArgs)
The main application for CohQL statement processing.- Parameters:
asArgs- an array of Strings that represents arguments
-
-