Package org.apache.cayenne.access.translator.select

## Class QualifierTranslator

- java.lang.Object
- - org.apache.cayenne.access.translator.select.QueryAssemblerHelper
  - - org.apache.cayenne.access.translator.select.QualifierTranslator

- All Implemented Interfaces:
    `TraversalHandler`
  Direct Known Subclasses:
    `FirebirdQualifierTranslator`, `FrontBaseQualifierTranslator`, `OpenBaseQualifierTranslator`, `SQLiteQualifierTranslator`, `SybaseQualifierTranslator`, `TrimmingQualifierTranslator`

      public class QualifierTranslator
      extends QueryAssemblerHelper
      implements TraversalHandler

  Translates query qualifier to SQL. Used as a helper class by query translators.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected boolean` | `caseInsensitive` |
    `protected boolean` | `matchingObject` |
    `protected DataObjectMatchTranslator` | `objectMatchTranslator` |
    `protected Expression` | `qualifier` |
    `protected boolean` | `useAliasForExpressions` |
    `protected Expression` | `waitingForEndNode` |

    - ### Fields inherited from class org.apache.cayenne.access.translator.select.QueryAssemblerHelper

      `out, queryAssembler, strategy`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `QualifierTranslator​(QueryAssembler queryAssembler)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `appendExtractFunction​(ASTExtract functionExpression)` | Special case for extract date/time parts functions as they have many variants
    `protected void` | `appendFunction​(ASTFunctionCall functionExpression)` | Append function name to result SQL Override this method to rename or skip function if generic name isn't supported on target DB.
    `protected void` | `appendFunctionArg​(Object value, ASTFunctionCall functionExpression)` | Append scalar argument of a function call Used only for values stored in ASTScalar other expressions appended in objectNode() method
    `protected void` | `appendFunctionArgDivider​(ASTFunctionCall functionExpression)` | Append divider between function arguments.
    `protected void` | `appendLiteral​(Object val, DbAttribute attr, Expression parentExpression)` | Appends SQL code to the query buffer to handle `val` as a parameter to the PreparedStatement being built.
    `protected void` | `appendObjectMatch()` |
    `protected void` | `clearLastFunctionArgDivider​(ASTFunctionCall functionExpression)` | Clear last divider as we currently don't now position of argument until parent element is ended.
    `protected void` | `detectObjectMatch​(Expression exp)` | Called before processing an expression to initialize objectMatchTranslator if needed.
    `protected void` | `doAppendPart()` | Translates query qualifier to SQL WHERE clause.
    `protected void` | `doAppendPart​(Expression rootNode)` | Translates query qualifier to SQL WHERE clause.
    `void` | `endNode​(Expression node, Expression parentNode)` | Called during the traversal after an expression node children processing is finished.
    `protected Expression` | `extractQualifier()` |
    `void` | `finishedChild​(Expression node, int childIndex, boolean hasMoreChildren)` | Called during traversal after a child of expression has been visited.
    `void` | `objectNode​(Object leaf, Expression parentNode)` | Called during the traversal when a leaf non-expression node is encountered.
    `protected String` | `operandForBitwiseAnd()` |
    `protected String` | `operandForBitwiseLeftShift()` |
    `protected String` | `operandForBitwiseNot()` |
    `protected String` | `operandForBitwiseOr()` |
    `protected String` | `operandForBitwiseRightShift()` |
    `protected String` | `operandForBitwiseXor()` |
    `protected boolean` | `parenthesisNeeded​(Expression node, Expression parentNode)` |
    `protected void` | `processRelTermination​(DbRelationship rel, JoinType joinType, String joinSplitAlias)` | Handles case when a DB_NAME expression ends with relationship.
    `void` | `setCaseInsensitive​(boolean caseInsensitive)` |
    `void` | `setQualifier​(Expression qualifier)` | Explicitly set qualifier.
    `void` | `setUseAliasForExpressions​(boolean useAliasForExpressions)` |
    `void` | `startNode​(Expression node, Expression parentNode)` | Called during the traversal before an expression node children processing is started.

    - ### Methods inherited from class org.apache.cayenne.access.translator.select.QueryAssemblerHelper

      `appendDbPath, appendLikeEscapeCharacter, appendLiteralDirect, appendObjPath, appendPart, getDbEntity, getObjEntity, paramsDbType, processColumn, processColumnWithQuoteSqlIdentifiers, processRelTermination, setForceJoinForRelations`

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

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

- - ### Field Detail

    - #### objectMatchTranslator

          protected DataObjectMatchTranslator objectMatchTranslator

    - #### matchingObject

          protected boolean matchingObject

    - #### caseInsensitive

          protected boolean caseInsensitive

    - #### useAliasForExpressions

          protected boolean useAliasForExpressions

      Since:
        4.0

    - #### waitingForEndNode

          protected Expression waitingForEndNode

      Since:
        4.0

    - #### qualifier

          protected Expression qualifier

      Since:
        4.0

  - ### Constructor Detail

    - #### QualifierTranslator

          public QualifierTranslator​(QueryAssembler queryAssembler)

  - ### Method Detail

    - #### doAppendPart

          protected void doAppendPart()

      Translates query qualifier to SQL WHERE clause. Qualifier is obtained from the parent queryAssembler.
      Specified by:
        `doAppendPart` in class `QueryAssemblerHelper`
      Since:
        3.0

    - #### setCaseInsensitive

          public void setCaseInsensitive​(boolean caseInsensitive)

    - #### setQualifier

          public void setQualifier​(Expression qualifier)

      Explicitly set qualifier. It will be used instead of extracting qualifier from the query itself.
      Since:
        4.0

    - #### setUseAliasForExpressions

          public void setUseAliasForExpressions​(boolean useAliasForExpressions)

      Since:
        4.0

    - #### doAppendPart

          protected void doAppendPart​(Expression rootNode)

      Translates query qualifier to SQL WHERE clause. Qualifier is a method parameter.
      Since:
        3.0

    - #### extractQualifier

          protected Expression extractQualifier()

    - #### detectObjectMatch

          protected void detectObjectMatch​(Expression exp)

      Called before processing an expression to initialize objectMatchTranslator if needed.

    - #### appendObjectMatch

          protected void appendObjectMatch()
                                    throws IOException

      Throws:
        `IOException`

    - #### finishedChild

          public void finishedChild​(Expression node,
                                    int childIndex,
                                    boolean hasMoreChildren)

      Description copied from interface: `TraversalHandler`
      Called during traversal after a child of expression has been visited.
      Specified by:
        `finishedChild` in interface `TraversalHandler`

    - #### operandForBitwiseNot

          protected String operandForBitwiseNot()

      Since:
        3.1

    - #### operandForBitwiseOr

          protected String operandForBitwiseOr()

      Since:
        3.1

    - #### operandForBitwiseAnd

          protected String operandForBitwiseAnd()

      Since:
        3.1

    - #### operandForBitwiseXor

          protected String operandForBitwiseXor()

      Since:
        3.1

    - #### operandForBitwiseLeftShift

          protected String operandForBitwiseLeftShift()

      Since:
        4.0

    - #### operandForBitwiseRightShift

          protected String operandForBitwiseRightShift()

      Since:
        4.0

    - #### startNode

          public void startNode​(Expression node,
                                Expression parentNode)

      Description copied from interface: `TraversalHandler`
      Called during the traversal before an expression node children processing is started.
      Specified by:
        `startNode` in interface `TraversalHandler`

    - #### endNode

          public void endNode​(Expression node,
                              Expression parentNode)

      Description copied from interface: `TraversalHandler`
      Called during the traversal after an expression node children processing is finished.
      Specified by:
        `endNode` in interface `TraversalHandler`
      Since:
        1.1

    - #### objectNode

          public void objectNode​(Object leaf,
                                 Expression parentNode)

      Description copied from interface: `TraversalHandler`
      Called during the traversal when a leaf non-expression node is encountered.
      Specified by:
        `objectNode` in interface `TraversalHandler`

    - #### parenthesisNeeded

          protected boolean parenthesisNeeded​(Expression node,
                                              Expression parentNode)

    - #### appendLiteral

          protected void appendLiteral​(Object val,
                                       DbAttribute attr,
                                       Expression parentExpression)
                                throws IOException

      Description copied from class: `QueryAssemblerHelper`
      Appends SQL code to the query buffer to handle `val` as a parameter to the PreparedStatement being built. Adds `val` into QueryAssembler parameter list.

      If `val` is null, "NULL" is appended to the query.

      If `val` is a DataObject, its primary key value is used as a parameter. Only objects with a single column primary key can be used.

      Overrides:
        `appendLiteral` in class `QueryAssemblerHelper`
      Parameters:
        `val` - object that should be appended as a literal to the query. Must be of one of "standard JDBC" types, null or a DataObject.
        `attr` - DbAttribute that has information on what type of parameter is being appended.
      Throws:
        `IOException`

    - #### processRelTermination

          protected void processRelTermination​(DbRelationship rel,
                                               JoinType joinType,
                                               String joinSplitAlias)

      Description copied from class: `QueryAssemblerHelper`
      Handles case when a DB_NAME expression ends with relationship. If this is a "to many" relationship, a join is added and a column expression for the target entity primary key. If this is a "to one" relationship, column expression for the source foreign key is added.
      Overrides:
        `processRelTermination` in class `QueryAssemblerHelper`

    - #### appendFunction

          protected void appendFunction​(ASTFunctionCall functionExpression)

      Append function name to result SQL Override this method to rename or skip function if generic name isn't supported on target DB.
      Since:
        4.0

    - #### appendExtractFunction

          protected void appendExtractFunction​(ASTExtract functionExpression)

      Special case for extract date/time parts functions as they have many variants
      Since:
        4.0

    - #### appendFunctionArg

          protected void appendFunctionArg​(Object value,
                                           ASTFunctionCall functionExpression)
                                    throws IOException

      Append scalar argument of a function call Used only for values stored in ASTScalar other expressions appended in objectNode() method
      Throws:
        `IOException`
      Since:
        4.0

    - #### appendFunctionArgDivider

          protected void appendFunctionArgDivider​(ASTFunctionCall functionExpression)

      Append divider between function arguments. In overriding methods can be replaced e.g. for " || " for CONCAT operation
      Since:
        4.0

    - #### clearLastFunctionArgDivider

          protected void clearLastFunctionArgDivider​(ASTFunctionCall functionExpression)

      Clear last divider as we currently don't now position of argument until parent element is ended.
      Since:
        4.0