Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.objectstyle.cayenne.access.trans
Class QualifierTranslator

    java.lang.Object
      org.objectstyle.cayenne.access.trans.QueryAssemblerHelper
          org.objectstyle.cayenne.access.trans.QualifierTranslator

All Implemented Interfaces:
  TraversalHandler

Direct Known Subclasses:
  OpenBaseQualifierTranslator, TrimmingQualifierTranslator

    public class QualifierTranslator

extends QueryAssemblerHelper
implements TraversalHandler

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

Author:
  Andrei Adamchik

Field Summary
`protected boolean` | `matchingObject`
`protected DataObjectMatchTranslator` | `objectMatchTranslator`
`protected java.lang.StringBuffer` | `qualBuf`
`protected boolean` | `translateParentQual`

Fields inherited from class org.objectstyle.cayenne.access.trans.QueryAssemblerHelper
`queryAssembler`

Constructor Summary
`QualifierTranslator()`
`QualifierTranslator(QueryAssembler queryAssembler)`

Method Summary
`protected void` | `appendLiteral(java.lang.StringBuffer buf, java.lang.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` | `detectObjectMatch(Expression exp)` Called before processing an expression to initialize objectMatchTranslator if needed.
`java.lang.String` | `doTranslation()` 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)` Opportunity to insert an operation
`ObjEntity` | `getObjEntity()`
`boolean` | `isTranslateParentQual()` Returns `true` if this translator will translate parent qualifier on call to `doTranslation`.
`void` | `objectNode(java.lang.Object leaf, Expression parentNode)` Called during the traversal when a leaf non-expression node is encountered.
`protected boolean` | `parenthesisNeeded(Expression node, Expression parentNode)`
`protected void` | `processRelTermination(java.lang.StringBuffer buf, DbRelationship rel)` Handles case when a DB_NAME expression ends with relationship.
`void` | `setTranslateParentQual(boolean translateParentQual)` Configures translator to translate parent or main qualifier on call to `doTranslation`.
`void` | `startNode(Expression node, Expression parentNode)` Called during the traversal before an expression node children processing is started.

Methods inherited from class org.objectstyle.cayenne.access.trans.QueryAssemblerHelper
`appendDbPath, appendLiteralDirect, appendObjPath, getDbEntity, getQueryAssembler, paramsDbType, processColumn, processColumn, processColumn, processRelTermination, setQueryAssembler`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### qualBuf

    protected java.lang.StringBuffer qualBuf

### translateParentQual

    protected boolean translateParentQual

### objectMatchTranslator

    protected DataObjectMatchTranslator objectMatchTranslator

### matchingObject

    protected boolean matchingObject

Constructor Detail

### QualifierTranslator

    public QualifierTranslator()

### QualifierTranslator

    public QualifierTranslator(QueryAssembler queryAssembler)

Method Detail

### doTranslation

    public java.lang.String doTranslation()

  Translates query qualifier to SQL WHERE clause. Qualifier is obtained from `queryAssembler` object.

  Specified by:
    `doTranslation` in class `QueryAssemblerHelper`

### extractQualifier

    protected Expression extractQualifier()

### detectObjectMatch

    protected void detectObjectMatch(Expression exp)

  Called before processing an expression to initialize objectMatchTranslator if needed.

### appendObjectMatch

    protected void appendObjectMatch()

### finishedChild

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

  Opportunity to insert an operation

  Specified by:
    `finishedChild` in interface `TraversalHandler`

### 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(java.lang.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)

### isTranslateParentQual

    public boolean isTranslateParentQual()

  Returns `true` if this translator will translate parent qualifier on call to `doTranslation`.

  Returns:
    boolean

### setTranslateParentQual

    public void setTranslateParentQual(boolean translateParentQual)

  Configures translator to translate parent or main qualifier on call to `doTranslation`.

  Parameters:
    `translateParentQual` - The translateParentQual to set

### getObjEntity

    public ObjEntity getObjEntity()

  Overrides:
    `getObjEntity` in class `QueryAssemblerHelper`

### appendLiteral

    protected void appendLiteral(java.lang.StringBuffer buf,
                                 java.lang.Object val,
                                 DbAttribute attr,
                                 Expression parentExpression)

  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:
    `buf` - query buffer.
    `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.

### processRelTermination

    protected void processRelTermination(java.lang.StringBuffer buf,
                                         DbRelationship rel)

  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 expresion for the source foreign key is added.

  Overrides:
    `processRelTermination` in class `QueryAssemblerHelper`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.