public class CoherenceQueryLanguage extends Object
Modifier and Type | Field and Description |
---|---|
protected ExtractorBuilder |
m_bldrExtractor
The
ExtractorBuilder that will be used to realize
ValueExtractor s to be used by CohQL. |
protected Map<String,ParameterizedBuilder<?>> |
m_mapFunctions
The map of CohQL functions.
|
protected Map<CharSequence,BaseOperator> |
m_mapOperators
The map of CohQL operators.
|
protected Map<String,StatementBuilder<?>> |
m_mapStatementBuilders
The map of CohQL query builders.
|
protected TokenTable |
m_tokenTableExtendedSQL
The extended TokenTable for the full language that resembles SQL.
|
protected TokenTable |
m_tokenTableForFilter
The TokenTable for Filters.
|
protected TokenTable |
m_tokenTableSQL
The TokenTable for the full language that resembles SQL.
|
Constructor and Description |
---|
CoherenceQueryLanguage()
Construct a CoherenceQueryLanguage instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addFunction(String sName,
ParameterizedBuilder bldrFunction)
Map the specified CohQL
ParameterizedBuilder to
the specified function name. |
void |
addOperator(BaseOperator operator)
Add the custom operator to the CohQL language.
|
void |
addStatement(String sFunctor,
StatementBuilder<?> builder)
Register the given
StatementBuilder to the specified functor name. |
void |
clearCustomFunctions()
Remove all custom function mappings that have been registered.
|
void |
clearCustomOperators()
Remove all customisations that have been added to the CohQL language.
|
protected Map<String,StatementBuilder<?>> |
createStatements()
Create the CohQL
StatementBuilder map and initialise
it with the standard CohQL statements. |
TokenTable |
extendedSqlTokenTable()
Return an initialized TokenTable for the full CoherenceQueryLanguage.
|
TokenTable |
filtersTokenTable()
Return an initialized standard
TokenTable known by this
CoherenceQueryLanguage. |
ExtractorBuilder |
getExtractorBuilder()
Return the
ExtractorBuilder to use to build
ValueExtractor s. |
ParameterizedBuilder |
getFunction(String sName)
Return the function mapped to the given function name or
null if no function mapping exists.
|
BaseOperator |
getOperator(String sSymbol)
Return the
BaseOperator mapped to the given symbol. |
Set<CharSequence> |
getOperators()
Return the set of CohQL Operators characters.
|
protected TokenTable |
getSqlTokenTable(boolean fExtended)
Return an initialized TokenTable for the full CoherenceQueryLanguage.
|
StatementBuilder<?> |
getStatementBuilder(String sFunctor)
Return the
StatementBuilder for a given CohQL AST functor. |
Map<String,StatementBuilder<?>> |
getStatementBuilders()
Return the map of
StatementBuilder instances. |
protected Map<String,ParameterizedBuilder<?>> |
initializeFunctionMap()
Creates the Map holding CohQL functions and populates it
with the default functions available in CohQL.
|
protected Map<CharSequence,BaseOperator> |
initializeOperatorMap()
Initialize the CohQL operators Map with all of the built-in CohQL
operators and return the Map.
|
Statement |
prepareStatement(NodeTerm term,
ExecutionContext context,
List listBindVars,
com.tangosol.config.expression.ParameterResolver namedBindVars)
Realize an instance of the
Statement that will execute the CohQL statement
represented by the AST node. |
ParameterizedBuilder<?> |
removeFunction(String sName)
Remove the CohQL function mapping for the specified function name.
|
StatementBuilder<?> |
removeStatementBuilder(String sFunctor)
Remove the
StatementBuilder associated with the given functor. |
void |
setExtractorBuilder(ExtractorBuilder builder)
Set the
ExtractorBuilder that will be used by CohQL queries to
build ValueExtractor s. |
TokenTable |
sqlTokenTable()
Return an initialized extended
TokenTable known by this
CoherenceQueryLanguage. |
protected TokenTable m_tokenTableForFilter
protected TokenTable m_tokenTableSQL
protected TokenTable m_tokenTableExtendedSQL
protected Map<String,ParameterizedBuilder<?>> m_mapFunctions
protected Map<CharSequence,BaseOperator> m_mapOperators
BaseOperator
implementation.protected Map<String,StatementBuilder<?>> m_mapStatementBuilders
protected ExtractorBuilder m_bldrExtractor
ExtractorBuilder
that will be used to realize
ValueExtractor
s to be used by CohQL.public CoherenceQueryLanguage()
public TokenTable filtersTokenTable()
TokenTable
known by this
CoherenceQueryLanguage.public TokenTable sqlTokenTable()
TokenTable
known by this
CoherenceQueryLanguage.public TokenTable extendedSqlTokenTable()
protected TokenTable getSqlTokenTable(boolean fExtended)
fExtended
- flag that enables extended and experimental featuresprotected Map<String,ParameterizedBuilder<?>> initializeFunctionMap()
public ParameterizedBuilder getFunction(String sName)
sName
- the name of the function to returnpublic void addFunction(String sName, ParameterizedBuilder bldrFunction)
ParameterizedBuilder
to
the specified function name. If either the name of the implementation
is null then no mapping will occur.sName
- the name of the functionbldrFunction
- the implementation of the functionpublic ParameterizedBuilder<?> removeFunction(String sName)
ParameterizedBuilder
will be returned, or null if there
was no mapping for the specified name.sName
- the name of the function to removepublic void clearCustomFunctions()
protected Map<CharSequence,BaseOperator> initializeOperatorMap()
public void addOperator(BaseOperator operator)
operator
- the operator to addpublic Set<CharSequence> getOperators()
public BaseOperator getOperator(String sSymbol)
BaseOperator
mapped to the given symbol.sSymbol
- the symbol of the BaseOperator to getpublic Map<String,StatementBuilder<?>> getStatementBuilders()
StatementBuilder
instances.
The map is keyed on the functor used to represent a particular
query type in a CohQL AST.protected Map<String,StatementBuilder<?>> createStatements()
StatementBuilder
map and initialise
it with the standard CohQL statements.public StatementBuilder<?> getStatementBuilder(String sFunctor)
StatementBuilder
for a given CohQL AST functor.
The returned value may be null if no builder has been registered
for a given functor.sFunctor
- the functor representing the statement who's builder
should be returnedpublic Statement prepareStatement(NodeTerm term, ExecutionContext context, List listBindVars, com.tangosol.config.expression.ParameterResolver namedBindVars)
Statement
that will execute the CohQL statement
represented by the AST node.term
- the parsed AST node representing the CohQL statementcontext
- the ExecutionContext
to use to realize the commandlistBindVars
- the indexed bind variables to use for the querynamedBindVars
- the named bind variables to use for the queryCohQLException
- if there is an error building the statement
or there are no registered builders for the statementpublic void addStatement(String sFunctor, StatementBuilder<?> builder)
StatementBuilder
to the specified functor name.
The specified StatementBuilder will then be used to build any
Statement
instances when the given functor is present in
a query AST.sFunctor
- the functor to map the StatementBuilder tobuilder
- the StatementBuilder to be mappedpublic StatementBuilder<?> removeStatementBuilder(String sFunctor)
StatementBuilder
associated with the given functor.
Note: removal of a functor may cause errors if subsequent queries refer to the functor.
sFunctor
- the functor mapping to removepublic void clearCustomOperators()
public void setExtractorBuilder(ExtractorBuilder builder)
ExtractorBuilder
that will be used by CohQL queries to
build ValueExtractor
s.builder
- the ExtractorBuilder to usepublic ExtractorBuilder getExtractorBuilder()
ExtractorBuilder
to use to build
ValueExtractor
s.