Class JRAbstractQueryExecuter
java.lang.Object
net.sf.jasperreports.engine.query.JRAbstractQueryExecuter
- All Implemented Interfaces:
JRQueryExecuter
- Direct Known Subclasses:
AbstractJsonQueryExecuter,AbstractXlsQueryExecuter,JaxenXPathQueryExecuter,JRCsvQueryExecuter,JRHibernateQueryExecuter,JRHibernateQueryExecuter,JRJdbcQueryExecuter,JRJpaQueryExecuter,JRJpaQueryExecuter,JRMondrianQueryExecuter,JRXmlaQueryExecuter,JRXPathQueryExecuter,Olap4jMondrianQueryExecuter,Olap4jXmlaQueryExecuter,XalanXPathQueryExecuter
Base abstract query executer.
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA parameter present in the query.protected static interfaceprotected static interfaceprotected static classprotected class -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJRAbstractQueryExecuter(JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String, ? extends JRValueParameter> parametersMap) protectedJRAbstractQueryExecuter(QueryExecutionContext context, JRDataset dataset, Map<String, ? extends JRValueParameter> parametersMap) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddQueryMultiParameters(String parameterName, int count) Records a multi-valued query parameter.protected voidaddQueryMultiParameters(String parameterName, int count, boolean ignoreNulls) Records a multi-valued query parameter which ignore null values.protected voidaddQueryParameter(Class<?> type, Object value) protected voidaddQueryParameter(String parameterName) Records a query parameter.protected voidappendClauseChunk(StringBuffer sbuffer, String[] clauseTokens) Handles aclause query chunk.protected voidappendParameterChunk(StringBuffer sbuffer, String chunkText) protected voidappendParameterClauseChunk(StringBuffer sbuffer, String chunkText) protected voidappendQueryChunk(StringBuffer sbuffer, JRQueryChunk chunk) protected voidappendTextChunk(StringBuffer sbuffer, String text) protected voidapplyClause(JRClauseFunction function, JRClauseTokens tokens, StringBuffer sbuffer) protected voidcheckParameter(String parameterName) protected JRClauseFunctionprotected BooleangetBooleanParameter(String parameter, String property) protected booleangetBooleanParameter(String parameter, String property, boolean defaultValue) protected Booleanprotected booleangetBooleanParameterOrProperty(String name, boolean defaultValue) protected StringReturns a canonical query language for this query executer implementation.Returns the list of parameter names in the order in which they appear in the query.protected List<JRAbstractQueryExecuter.QueryParameter> Returns the list ofquery parametersin the order in which they appear in the query.protected IntegergetIntegerParameter(String parameter, String property) protected intgetIntegerParameter(String parameter, String property, int defaultValue) protected Integerprotected intgetIntegerParameterOrProperty(String name, int defaultValue) protected JasperReportsContextprotected abstract StringgetParameterReplacement(String parameterName) Returns the replacement text for a query parameter.protected ObjectgetParameterValue(String parameterName) Returns the value of a fill parameter.protected ObjectgetParameterValue(String parameterName, boolean ignoreMissing) Returns the value of a fill parameter.protected JRPropertiesUtilprotected QueryExecutionContextprotected StringReturns the parsed query string with the parameter clauses replaced by the parameter values and the parameters replaced bygetParameterReplacement.protected RepositoryContextprotected StringgetStringParameter(String parameter, String property) protected Stringprotected JRValueParametergetValueParameter(String parameterName) Return a value parameter from the parameters map.protected JRValueParametergetValueParameter(String parameterName, boolean ignoreMissing) Return a value parameter from the parameters map.protected booleanparameterHasValue(String parameter) protected voidParses the query and replaces the parameter clauses by the parameter values and the parameters by the return value ofgetParameterReplacement.protected voidregisterClauseFunction(String id, JRClauseFunction function) Registers a clause function.protected JRClauseFunctionResolves a clause function ID to a function instance.protected voidUnregisters a clause function.protected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.jasperreports.engine.query.JRQueryExecuter
cancelQuery, close, createDatasource
-
Field Details
-
EXCEPTION_MESSAGE_KEY_NUMERIC_TYPE_REQUIRED
- See Also:
-
EXCEPTION_MESSAGE_KEY_PARAMETER_NOT_FOUND
- See Also:
-
EXCEPTION_MESSAGE_KEY_QUERY_CLAUSE_CIRCULARLY_NESTED_PARAMETER
- See Also:
-
EXCEPTION_MESSAGE_KEY_QUERY_CLAUSE_ID_FIRST_TOKEN_MISSING
- See Also:
-
EXCEPTION_MESSAGE_KEY_QUERY_CLAUSE_NOT_FOUND
- See Also:
-
EXCEPTION_MESSAGE_KEY_UNSUPPORTED_PARAMETER_TYPE
- See Also:
-
GET_COLLECTED
- See Also:
-
clauseFunctions
Clause function registry. -
dataset
-
-
Constructor Details
-
JRAbstractQueryExecuter
protected JRAbstractQueryExecuter(JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String, ? extends JRValueParameter> parametersMap) -
JRAbstractQueryExecuter
protected JRAbstractQueryExecuter(QueryExecutionContext context, JRDataset dataset, Map<String, ? extends JRValueParameter> parametersMap)
-
-
Method Details
-
getJasperReportsContext
-
getQueryExecutionContext
-
getRepositoryContext
-
getPropertiesUtil
-
registerClauseFunction
Registers a clause function.- Parameters:
id- the function IDfunction- the function
-
unregisterClauseFunction
Unregisters a clause function.- Parameters:
id- the function ID
-
resolveFunction
Resolves a clause function ID to a function instance.- Parameters:
id- the function ID- Returns:
- the clause function registered for the ID
- Throws:
JRRuntimeException- if no function for the ID is found
-
findExtensionQueryFunction
-
getCanonicalQueryLanguage
Returns a canonical query language for this query executer implementation.The canonical language is used to retrieve extensions for the query executer.
The default implementation returns the runtime query language used in the dataset, but query executer implementations should override this method and return a fixed language.
- Returns:
- a canonical query language
-
parseQuery
protected void parseQuery()Parses the query and replaces the parameter clauses by the parameter values and the parameters by the return value ofgetParameterReplacement. -
appendQueryChunk
-
appendTextChunk
-
appendParameterChunk
-
addQueryParameter
Records a query parameter.- Parameters:
parameterName- the parameter name- See Also:
-
addQueryMultiParameters
Records a multi-valued query parameter.- Parameters:
parameterName- the parameter namecount- the value count- See Also:
-
addQueryMultiParameters
Records a multi-valued query parameter which ignore null values.- Parameters:
parameterName- the parameter namecount- the value count- See Also:
-
addQueryParameter
-
appendParameterClauseChunk
-
appendClauseChunk
Handles aclause query chunk.The default implementation considers the first token as a
clause functionID and delegates the call to the function.Extending query executers can override this to implement custom query clause handling.
- Parameters:
sbuffer- the query text bufferclauseTokens- clause tokens- Throws:
JRRuntimeException- if there is no first token or no clause function is found for the ID- See Also:
-
applyClause
-
getQueryString
Returns the parsed query string with the parameter clauses replaced by the parameter values and the parameters replaced bygetParameterReplacement.- Returns:
- the parsed query string
-
getCollectedParameterNames
Returns the list of parameter names in the order in which they appear in the query.- Returns:
- the list of parameter names
-
getCollectedParameters
Returns the list ofquery parametersin the order in which they appear in the query.- Returns:
- the list of query parameters
-
visitQueryParameters
protected void visitQueryParameters(JRAbstractQueryExecuter.QueryParameterVisitor visitor) throws JRAbstractQueryExecuter.VisitExceptionWrapper -
getParameterValue
Returns the value of a fill parameter.- Parameters:
parameterName- the parameter nameignoreMissing- iftrue, the method will return null for non existing parameters; otherwise, an exception will be thrown if the parameter does not exist- Returns:
- the parameter value
-
getParameterValue
Returns the value of a fill parameter.- Parameters:
parameterName- the parameter name- Returns:
- the parameter value
-
parameterHasValue
-
getStringParameter
-
getStringParameterOrProperty
-
getBooleanParameter
-
getBooleanParameterOrProperty
-
getBooleanParameter
-
getBooleanParameterOrProperty
-
getIntegerParameter
-
getIntegerParameterOrProperty
-
getIntegerParameter
-
getIntegerParameterOrProperty
-
checkParameter
-
getValueParameter
Return a value parameter from the parameters map.- Parameters:
parameterName- the parameter nameignoreMissing- iftrue, the method will return null for non existing parameters; otherwise, an exception will be thrown if the parameter does not exist- Returns:
- the parameter
-
getValueParameter
Return a value parameter from the parameters map.- Parameters:
parameterName- the parameter name- Returns:
- the parameter
-
getParameterReplacement
Returns the replacement text for a query parameter.- Parameters:
parameterName- the parameter name- Returns:
- the replacement text
- See Also:
-