Package com.tangosol.coherence.dslquery
Class CoherenceQueryLanguage
java.lang.Object
com.tangosol.coherence.dslquery.CoherenceQueryLanguage
CoherenceQueryLanguage is a simple language for building
 Filters and doing simple queries that are similar in style to SQL.
 This class configures CohQL and contains various attributes
 that control CohQL execution.
- Author:
 - djl 2009.08.31, jk 2013.12.02
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExtractorBuilderTheExtractorBuilderthat will be used to realizeValueExtractors to be used by CohQL.protected Map<String, ParameterizedBuilder<?>> The map of CohQL functions.protected Map<CharSequence, BaseOperator> The map of CohQL operators.protected Map<String, StatementBuilder<?>> The map of CohQL query builders.protected TokenTableThe extended TokenTable for the full language that resembles SQL.protected TokenTableThe TokenTable for Filters.protected TokenTableThe TokenTable for the full language that resembles SQL. - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddFunction(String sName, ParameterizedBuilder bldrFunction) Map the specified CohQLParameterizedBuilderto the specified function name.voidaddOperator(BaseOperator operator) Add the custom operator to the CohQL language.voidaddStatement(String sFunctor, StatementBuilder<?> builder) Register the givenStatementBuilderto the specified functor name.voidRemove all custom function mappings that have been registered.voidRemove all customisations that have been added to the CohQL language.protected Map<String, StatementBuilder<?>> Create the CohQLStatementBuildermap and initialise it with the standard CohQL statements.Return an initialized TokenTable for the full CoherenceQueryLanguage.Return an initialized standardTokenTableknown by this CoherenceQueryLanguage.Return theExtractorBuilderto use to buildValueExtractors.getFunction(String sName) Return the function mapped to the given function name or null if no function mapping exists.protected StringgetFunctionKey(String sFunctionName) Returns a key value based on case-insensitivity of the token table.getOperator(String sSymbol) Return theBaseOperatormapped to the given symbol.Return the set of CohQL Operators characters.protected TokenTablegetSqlTokenTable(boolean fExtended) Return an initialized TokenTable for the full CoherenceQueryLanguage.getStatementBuilder(String sFunctor) Return theStatementBuilderfor a given CohQL AST functor.Return the map ofStatementBuilderinstances.protected Map<String, ParameterizedBuilder<?>> Creates the Map holding CohQL functions and populates it with the default functions available in CohQL.protected Map<CharSequence, BaseOperator> Initialize the CohQL operators Map with all of the built-in CohQL operators and return the Map.prepareStatement(NodeTerm term, ExecutionContext context, List listBindVars, ParameterResolver namedBindVars) Realize an instance of theStatementthat will execute the CohQL statement represented by the AST node.removeFunction(String sName) Remove the CohQL function mapping for the specified function name.removeStatementBuilder(String sFunctor) Remove theStatementBuilderassociated with the given functor.voidsetExtractorBuilder(ExtractorBuilder builder) Set theExtractorBuilderthat will be used by CohQL queries to buildValueExtractors.Return an initialized extendedTokenTableknown by this CoherenceQueryLanguage. 
- 
Field Details
- 
m_tokenTableForFilter
The TokenTable for Filters. - 
m_tokenTableSQL
The TokenTable for the full language that resembles SQL. - 
m_tokenTableExtendedSQL
The extended TokenTable for the full language that resembles SQL. - 
m_mapFunctions
The map of CohQL functions. The key is the function name and the value is the function implementation. - 
m_mapOperators
The map of CohQL operators. The key is the operator name and the value is theBaseOperatorimplementation. - 
m_mapStatementBuilders
The map of CohQL query builders. The key is the CohQL token name that the parser produces to represent a particular query. - 
m_bldrExtractor
TheExtractorBuilderthat will be used to realizeValueExtractors to be used by CohQL. 
 - 
 - 
Constructor Details
- 
CoherenceQueryLanguage
public CoherenceQueryLanguage()Construct a CoherenceQueryLanguage instance. 
 - 
 - 
Method Details
- 
filtersTokenTable
Return an initialized standardTokenTableknown by this CoherenceQueryLanguage.- Returns:
 - an initialized standard TokenTable known by this CoherenceQueryLanguage
 
 - 
sqlTokenTable
Return an initialized extendedTokenTableknown by this CoherenceQueryLanguage.- Returns:
 - an initialized extended TokenTable known by this CoherenceQueryLanguage
 
 - 
extendedSqlTokenTable
Return an initialized TokenTable for the full CoherenceQueryLanguage.- Returns:
 - a TokenTable for the CoherenceQueryLanguage
 
 - 
getSqlTokenTable
Return an initialized TokenTable for the full CoherenceQueryLanguage.- Parameters:
 fExtended- flag that enables extended and experimental features- Returns:
 - a TokenTable for the CoherenceQueryLanguage
 
 - 
initializeFunctionMap
Creates the Map holding CohQL functions and populates it with the default functions available in CohQL. CohQL functions are elements such as sum(), avg(), max() etc.- Returns:
 - the function Map populated with the default functions
 
 - 
getFunction
Return the function mapped to the given function name or null if no function mapping exists.- Parameters:
 sName- the name of the function to return- Returns:
 - the function mapped to the given function name or null if no function mapping exists
 
 - 
addFunction
Map the specified CohQLParameterizedBuilderto the specified function name. If either the name of the implementation is null then no mapping will occur.- Parameters:
 sName- the name of the functionbldrFunction- the implementation of the function
 - 
removeFunction
Remove the CohQL function mapping for the specified function name. The removedParameterizedBuilderwill be returned, or null if there was no mapping for the specified name.- Parameters:
 sName- the name of the function to remove- Returns:
 - the removed ParameterizedBuilder will be returned, or null if there was no mapping for the specified name.
 
 - 
clearCustomFunctions
public void clearCustomFunctions()Remove all custom function mappings that have been registered. - 
initializeOperatorMap
Initialize the CohQL operators Map with all of the built-in CohQL operators and return the Map.- Returns:
 - the Map of CohQL operators
 
 - 
addOperator
Add the custom operator to the CohQL language.- Parameters:
 operator- the operator to add
 - 
getOperators
Return the set of CohQL Operators characters.- Returns:
 - the set of CohQL operators characters
 
 - 
getOperator
Return theBaseOperatormapped to the given symbol.- Parameters:
 sSymbol- the symbol of the BaseOperator to get- Returns:
 - the BaseOperator mapped to the specified symbol or null if there i sno mapping for that symbol
 
 - 
getStatementBuilders
Return the map ofStatementBuilderinstances. The map is keyed on the functor used to represent a particular query type in a CohQL AST.- Returns:
 - the map of StatementBuilder instances
 
 - 
createStatements
Create the CohQLStatementBuildermap and initialise it with the standard CohQL statements.- Returns:
 - the standard CohQL statement map
 
 - 
getStatementBuilder
Return theStatementBuilderfor a given CohQL AST functor. The returned value may be null if no builder has been registered for a given functor.- Parameters:
 sFunctor- the functor representing the statement who's builder should be returned- Returns:
 - the StatementBuilder for a given CohQL AST functor
 
 - 
prepareStatement
public Statement prepareStatement(NodeTerm term, ExecutionContext context, List listBindVars, ParameterResolver namedBindVars) Realize an instance of theStatementthat will execute the CohQL statement represented by the AST node.- Parameters:
 term- the parsed AST node representing the CohQL statementcontext- theExecutionContextto use to realize the commandlistBindVars- the indexed bind variables to use for the querynamedBindVars- the named bind variables to use for the query- Returns:
 - the Statement to execute the CohQL statement
 - Throws:
 CohQLException- if there is an error building the statement or there are no registered builders for the statement
 - 
addStatement
Register the givenStatementBuilderto the specified functor name. The specified StatementBuilder will then be used to build anyStatementinstances when the given functor is present in a query AST.- Parameters:
 sFunctor- the functor to map the StatementBuilder tobuilder- the StatementBuilder to be mapped
 - 
removeStatementBuilder
Remove theStatementBuilderassociated with the given functor.Note: removal of a functor may cause errors if subsequent queries refer to the functor.
- Parameters:
 sFunctor- the functor mapping to remove- Returns:
 - the removed StatementBuilder or null
 
 - 
clearCustomOperators
public void clearCustomOperators()Remove all customisations that have been added to the CohQL language. - 
setExtractorBuilder
Set theExtractorBuilderthat will be used by CohQL queries to buildValueExtractors.- Parameters:
 builder- the ExtractorBuilder to use
 - 
getExtractorBuilder
Return theExtractorBuilderto use to buildValueExtractors.- Returns:
 - the ExtractorBuilder to use to build ValueExtractors
 
 - 
getFunctionKey
Returns a key value based on case-insensitivity of the token table.- Parameters:
 sFunctionName- the function name to create a key for- Returns:
 - a key value based on case-insensitivity of the token table
 - Since:
 - 21.06
 
 
 -