net.sf.jasperreports.engine.query

## Class JRAbstractQueryExecuter

- java.lang.Object
- - net.sf.jasperreports.engine.query.JRAbstractQueryExecuter

- All Implemented Interfaces:
    JRQueryExecuter
  Direct Known Subclasses:
    AbstractXlsQueryExecuter, JaxenXPathQueryExecuter, JRCsvQueryExecuter, JRHibernateQueryExecuter, JRJdbcQueryExecuter, JRJpaQueryExecuter, JRMondrianQueryExecuter, JRXmlaQueryExecuter, JRXPathQueryExecuter, JsonQueryExecuter, Olap4jMondrianQueryExecuter, Olap4jXmlaQueryExecuter, XalanXPathQueryExecuter

      public abstract class JRAbstractQueryExecuter
      extends java.lang.Object
      implements JRQueryExecuter

  Base abstract query executer.
  Version:
    $Id: JRAbstractQueryExecuter.java 6986 2014-03-26 09:50:48Z teodord $
  Author:
    Lucian Chirita (lucianc@users.sourceforge.net)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `JRAbstractQueryExecuter.QueryParameter` A parameter present in the query.
    `protected static interface` | `JRAbstractQueryExecuter.QueryParameterEntry`
    `protected static interface` | `JRAbstractQueryExecuter.QueryParameterVisitor`
    `protected static class` | `JRAbstractQueryExecuter.ValuedQueryParameter`
    `protected class` | `JRAbstractQueryExecuter.VisitExceptionWrapper`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `CLAUSE_POSITION_ID` Deprecated. use `JRClauseTokens.CLAUSE_ID_POSITION` or `JRClauseTokens.getClauseId()` instead.
    `protected java.util.Map<java.lang.String,JRClauseFunction>` | `clauseFunctions` Clause function registry.
    `protected JRDataset` | `dataset`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `JRAbstractQueryExecuter(JasperReportsContext jasperReportsContext, JRDataset dataset, java.util.Map<java.lang.String,? extends JRValueParameter> parametersMap)`
    `protected` | `JRAbstractQueryExecuter(JRDataset dataset, java.util.Map<java.lang.String,? extends JRValueParameter> parametersMap)` Deprecated. Replaced by `JRAbstractQueryExecuter(JasperReportsContext, JRDataset, Map)`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addQueryMultiParameters(java.lang.String parameterName, int count)` Records a multi-valued query parameter.
    `protected void` | `addQueryMultiParameters(java.lang.String parameterName, int count, boolean ignoreNulls)` Records a multi-valued query parameter which ignore null values.
    `protected void` | `addQueryParameter(java.lang.Class<?> type, java.lang.Object value)`
    `protected void` | `addQueryParameter(java.lang.String parameterName)` Records a query parameter.
    `protected void` | `appendClauseChunk(java.lang.StringBuffer sbuffer, java.lang.String[] clauseTokens)` Handles a `clause query chunk`.
    `protected void` | `appendParameterChunk(java.lang.StringBuffer sbuffer, java.lang.String chunkText)`
    `protected void` | `appendParameterClauseChunk(java.lang.StringBuffer sbuffer, java.lang.String chunkText)`
    `protected void` | `appendQueryChunk(java.lang.StringBuffer sbuffer, JRQueryChunk chunk)`
    `protected void` | `appendTextChunk(java.lang.StringBuffer sbuffer, java.lang.String text)`
    `protected void` | `applyClause(JRClauseFunction function, JRClauseTokens tokens, java.lang.StringBuffer sbuffer)`
    `protected void` | `checkParameter(java.lang.String parameterName)`
    `protected JRClauseFunction` | `findExtensionQueryFunction(java.lang.String id)`
    `protected java.lang.Boolean` | `getBooleanParameter(java.lang.String parameter, java.lang.String property)`
    `protected boolean` | `getBooleanParameter(java.lang.String parameter, java.lang.String property, boolean defaultValue)`
    `protected java.lang.Boolean` | `getBooleanParameterOrProperty(java.lang.String name)`
    `protected boolean` | `getBooleanParameterOrProperty(java.lang.String name, boolean defaultValue)`
    `protected java.lang.String` | `getCanonicalQueryLanguage()` Returns a canonical query language for this query executer implementation.
    `protected java.util.List<java.lang.String>` | `getCollectedParameterNames()` Returns the list of parameter names in the order in which they appear in the query.
    `protected java.util.List<JRAbstractQueryExecuter.QueryParameter>` | `getCollectedParameters()` Returns the list of `query parameters` in the order in which they appear in the query.
    `protected JasperReportsContext` | `getJasperReportsContext()`
    `protected JRFillParameter` | `getParameter(java.lang.String parameterName)` Deprecated. `getValueParameter(String)` should be used instead
    `protected abstract java.lang.String` | `getParameterReplacement(java.lang.String parameterName)` Returns the replacement text for a query parameter.
    `protected java.lang.Object` | `getParameterValue(java.lang.String parameterName)` Returns the value of a fill parameter.
    `protected java.lang.Object` | `getParameterValue(java.lang.String parameterName, boolean ignoreMissing)` Returns the value of a fill parameter.
    `protected JRPropertiesUtil` | `getPropertiesUtil()`
    `protected java.lang.String` | `getQueryString()` Returns the parsed query string with the parameter clauses replaced by the parameter values and the parameters replaced by `getParameterReplacement`.
    `protected java.lang.String` | `getStringParameter(java.lang.String parameter, java.lang.String property)`
    `protected java.lang.String` | `getStringParameterOrProperty(java.lang.String name)`
    `protected JRValueParameter` | `getValueParameter(java.lang.String parameterName)` Return a value parameter from the parameters map.
    `protected JRValueParameter` | `getValueParameter(java.lang.String parameterName, boolean ignoreMissing)` Return a value parameter from the parameters map.
    `protected boolean` | `parameterHasValue(java.lang.String parameter)`
    `protected void` | `parseQuery()` Parses the query and replaces the parameter clauses by the parameter values and the parameters by the return value of `getParameterReplacement`.
    `protected void` | `registerClauseFunction(java.lang.String id, JRClauseFunction function)` Registers a clause function.
    `protected JRClauseFunction` | `resolveFunction(java.lang.String id)` Resolves a clause function ID to a function instance.
    `protected void` | `unregisterClauseFunction(java.lang.String id)` Unregisters a clause function.
    `protected void` | `visitQueryParameters(JRAbstractQueryExecuter.QueryParameterVisitor visitor)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface net.sf.jasperreports.engine.query.JRQueryExecuter

      `cancelQuery, close, createDatasource`

- - ### Field Detail

    - #### CLAUSE_POSITION_ID

          protected static final int CLAUSE_POSITION_ID

      Deprecated. use `JRClauseTokens.CLAUSE_ID_POSITION` or `JRClauseTokens.getClauseId()` instead.
      See Also:
        Constant Field Values

    - #### clauseFunctions

          protected final java.util.Map<java.lang.String,JRClauseFunction> clauseFunctions

      Clause function registry.

    - #### dataset

          protected final JRDataset dataset

  - ### Constructor Detail

    - #### JRAbstractQueryExecuter

          protected JRAbstractQueryExecuter(JasperReportsContext jasperReportsContext,
                                 JRDataset dataset,
                                 java.util.Map<java.lang.String,? extends JRValueParameter> parametersMap)

    - #### JRAbstractQueryExecuter

          protected JRAbstractQueryExecuter(JRDataset dataset,
                                 java.util.Map<java.lang.String,? extends JRValueParameter> parametersMap)

      Deprecated. Replaced by `JRAbstractQueryExecuter(JasperReportsContext, JRDataset, Map)`.

  - ### Method Detail

    - #### getJasperReportsContext

          protected JasperReportsContext getJasperReportsContext()

    - #### getPropertiesUtil

          protected JRPropertiesUtil getPropertiesUtil()

    - #### registerClauseFunction

          protected void registerClauseFunction(java.lang.String id,
                                    JRClauseFunction function)

      Registers a clause function.
      Parameters:
        `id` - the function ID
        `function` - the function

    - #### unregisterClauseFunction

          protected void unregisterClauseFunction(java.lang.String id)

      Unregisters a clause function.
      Parameters:
        `id` - the function ID

    - #### resolveFunction

          protected JRClauseFunction resolveFunction(java.lang.String id)

      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

          protected JRClauseFunction findExtensionQueryFunction(java.lang.String id)

    - #### getCanonicalQueryLanguage

          protected java.lang.String 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 of `getParameterReplacement`.

    - #### appendQueryChunk

          protected void appendQueryChunk(java.lang.StringBuffer sbuffer,
                              JRQueryChunk chunk)

    - #### appendTextChunk

          protected void appendTextChunk(java.lang.StringBuffer sbuffer,
                             java.lang.String text)

    - #### appendParameterChunk

          protected void appendParameterChunk(java.lang.StringBuffer sbuffer,
                                  java.lang.String chunkText)

    - #### addQueryParameter

          protected void addQueryParameter(java.lang.String parameterName)

      Records a query parameter.
      Parameters:
        `parameterName` - the parameter name
      See Also:
        `getCollectedParameters()`

    - #### addQueryMultiParameters

          protected void addQueryMultiParameters(java.lang.String parameterName,
                                     int count)

      Records a multi-valued query parameter.
      Parameters:
        `parameterName` - the parameter name
        `count` - the value count
      See Also:
        `getCollectedParameters()`, `JRAbstractQueryExecuter.QueryParameter.isMulti()`

    - #### addQueryMultiParameters

          protected void addQueryMultiParameters(java.lang.String parameterName,
                                     int count,
                                     boolean ignoreNulls)

      Records a multi-valued query parameter which ignore null values.
      Parameters:
        `parameterName` - the parameter name
        `count` - the value count
      See Also:
        `getCollectedParameters()`, `JRAbstractQueryExecuter.QueryParameter.isMulti()`

    - #### addQueryParameter

          protected void addQueryParameter(java.lang.Class<?> type,
                               java.lang.Object value)

    - #### appendParameterClauseChunk

          protected void appendParameterClauseChunk(java.lang.StringBuffer sbuffer,
                                        java.lang.String chunkText)

    - #### appendClauseChunk

          protected void appendClauseChunk(java.lang.StringBuffer sbuffer,
                               java.lang.String[] clauseTokens)

      Handles a `clause query chunk`.

      The default implementation considers the first token as a `clause function` ID and delegates the call to the function.

      Extending query executers can override this to implement custom query clause handling.

      Parameters:
        `sbuffer` - the query text buffer
        `clauseTokens` - clause tokens
      Throws:
        `JRRuntimeException` - if there is no first token or no clause function is found for the ID
      See Also:
        `registerClauseFunction(String, JRClauseFunction)`

    - #### applyClause

          protected void applyClause(JRClauseFunction function,
                         JRClauseTokens tokens,
                         java.lang.StringBuffer sbuffer)

    - #### getQueryString

          protected java.lang.String getQueryString()

      Returns the parsed query string with the parameter clauses replaced by the parameter values and the parameters replaced by `getParameterReplacement`.
      Returns:
        the parsed query string

    - #### getCollectedParameterNames

          protected java.util.List<java.lang.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

          protected java.util.List<JRAbstractQueryExecuter.QueryParameter> getCollectedParameters()

      Returns the list of `query parameters` in 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

      Throws:
        `JRAbstractQueryExecuter.VisitExceptionWrapper`

    - #### getParameterValue

          protected java.lang.Object getParameterValue(java.lang.String parameterName,
                                           boolean ignoreMissing)

      Returns the value of a fill parameter.
      Parameters:
        `parameterName` - the parameter name
        `ignoreMissing` - if `true`, 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

          protected java.lang.Object getParameterValue(java.lang.String parameterName)

      Returns the value of a fill parameter.
      Parameters:
        `parameterName` - the parameter name
      Returns:
        the parameter value

    - #### parameterHasValue

          protected boolean parameterHasValue(java.lang.String parameter)

    - #### getStringParameter

          protected java.lang.String getStringParameter(java.lang.String parameter,
                                            java.lang.String property)

    - #### getStringParameterOrProperty

          protected java.lang.String getStringParameterOrProperty(java.lang.String name)

    - #### getBooleanParameter

          protected boolean getBooleanParameter(java.lang.String parameter,
                                    java.lang.String property,
                                    boolean defaultValue)

    - #### getBooleanParameterOrProperty

          protected boolean getBooleanParameterOrProperty(java.lang.String name,
                                              boolean defaultValue)

    - #### getBooleanParameter

          protected java.lang.Boolean getBooleanParameter(java.lang.String parameter,
                                              java.lang.String property)

    - #### getBooleanParameterOrProperty

          protected java.lang.Boolean getBooleanParameterOrProperty(java.lang.String name)

    - #### getParameter

          protected JRFillParameter getParameter(java.lang.String parameterName)

      Deprecated. `getValueParameter(String)` should be used instead
      Return a fill parameter from the parameter map.
      Parameters:
        `parameterName` - the parameter name
      Returns:
        the parameter

    - #### checkParameter

          protected void checkParameter(java.lang.String parameterName)

    - #### getValueParameter

          protected JRValueParameter getValueParameter(java.lang.String parameterName,
                                           boolean ignoreMissing)

      Return a value parameter from the parameters map.
      Parameters:
        `parameterName` - the parameter name
        `ignoreMissing` - if `true`, 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

          protected JRValueParameter getValueParameter(java.lang.String parameterName)

      Return a value parameter from the parameters map.
      Parameters:
        `parameterName` - the parameter name
      Returns:
        the parameter

    - #### getParameterReplacement

          protected abstract java.lang.String getParameterReplacement(java.lang.String parameterName)

      Returns the replacement text for a query parameter.
      Parameters:
        `parameterName` - the parameter name
      Returns:
        the replacement text
      See Also:
        `JRQueryChunk.TYPE_PARAMETER`

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com