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 SummaryFields Modifier and Type Field Description protected booleancaseInsensitiveprotected booleanmatchingObjectprotected DataObjectMatchTranslatorobjectMatchTranslatorprotected Expressionqualifierprotected booleanuseAliasForExpressionsprotected ExpressionwaitingForEndNodeFields inherited from class org.apache.cayenne.access.translator.select.QueryAssemblerHelperout, queryAssembler, strategy
- 
Constructor SummaryConstructors Constructor Description QualifierTranslator(QueryAssembler queryAssembler)
- 
Method SummaryModifier and Type Method Description protected voidappendExtractFunction(ASTExtract functionExpression)Special case for extract date/time parts functions as they have many variantsprotected voidappendFunction(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 voidappendFunctionArg(Object value, ASTFunctionCall functionExpression)Append scalar argument of a function call Used only for values stored in ASTScalar other expressions appended in objectNode() methodprotected voidappendFunctionArgDivider(ASTFunctionCall functionExpression)Append divider between function arguments.protected voidappendLiteral(Object val, DbAttribute attr, Expression parentExpression)Appends SQL code to the query buffer to handlevalas a parameter to the PreparedStatement being built.protected voidappendObjectMatch()protected voidclearLastFunctionArgDivider(ASTFunctionCall functionExpression)Clear last divider as we currently don't now position of argument until parent element is ended.protected voiddetectObjectMatch(Expression exp)Called before processing an expression to initialize objectMatchTranslator if needed.protected voiddoAppendPart()Translates query qualifier to SQL WHERE clause.protected voiddoAppendPart(Expression rootNode)Translates query qualifier to SQL WHERE clause.voidendNode(Expression node, Expression parentNode)Called during the traversal after an expression node children processing is finished.protected ExpressionextractQualifier()voidfinishedChild(Expression node, int childIndex, boolean hasMoreChildren)Called during traversal after a child of expression has been visited.voidobjectNode(Object leaf, Expression parentNode)Called during the traversal when a leaf non-expression node is encountered.protected StringoperandForBitwiseAnd()protected StringoperandForBitwiseLeftShift()protected StringoperandForBitwiseNot()protected StringoperandForBitwiseOr()protected StringoperandForBitwiseRightShift()protected StringoperandForBitwiseXor()protected booleanparenthesisNeeded(Expression node, Expression parentNode)protected voidprocessRelTermination(DbRelationship rel, JoinType joinType, String joinSplitAlias)Handles case when a DB_NAME expression ends with relationship.voidsetCaseInsensitive(boolean caseInsensitive)voidsetQualifier(Expression qualifier)Explicitly set qualifier.voidsetUseAliasForExpressions(boolean useAliasForExpressions)voidstartNode(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.QueryAssemblerHelperappendDbPath, appendLikeEscapeCharacter, appendLiteralDirect, appendObjPath, appendPart, getDbEntity, getObjEntity, paramsDbType, processColumn, processColumnWithQuoteSqlIdentifiers, processRelTermination, setForceJoinForRelations
- 
Field Details- 
objectMatchTranslator
- 
matchingObjectprotected boolean matchingObject
- 
caseInsensitiveprotected boolean caseInsensitive
- 
useAliasForExpressionsprotected boolean useAliasForExpressions- Since:
- 4.0
 
- 
waitingForEndNode- Since:
- 4.0
 
- 
qualifier- Since:
- 4.0
 
 
- 
- 
Constructor Details- 
QualifierTranslator
 
- 
- 
Method Details- 
doAppendPartprotected void doAppendPart()Translates query qualifier to SQL WHERE clause. Qualifier is obtained from the parent queryAssembler.- Specified by:
- doAppendPartin class- QueryAssemblerHelper
- Since:
- 3.0
 
- 
setCaseInsensitivepublic void setCaseInsensitive(boolean caseInsensitive)
- 
setQualifierExplicitly set qualifier. It will be used instead of extracting qualifier from the query itself.- Since:
- 4.0
 
- 
setUseAliasForExpressionspublic void setUseAliasForExpressions(boolean useAliasForExpressions)- Since:
- 4.0
 
- 
doAppendPartTranslates query qualifier to SQL WHERE clause. Qualifier is a method parameter.- Since:
- 3.0
 
- 
extractQualifier
- 
detectObjectMatchCalled before processing an expression to initialize objectMatchTranslator if needed.
- 
appendObjectMatch- Throws:
- IOException
 
- 
finishedChildDescription copied from interface:TraversalHandlerCalled during traversal after a child of expression has been visited.- Specified by:
- finishedChildin interface- TraversalHandler
 
- 
operandForBitwiseNot- Since:
- 3.1
 
- 
operandForBitwiseOr- Since:
- 3.1
 
- 
operandForBitwiseAnd- Since:
- 3.1
 
- 
operandForBitwiseXor- Since:
- 3.1
 
- 
operandForBitwiseLeftShift- Since:
- 4.0
 
- 
operandForBitwiseRightShift- Since:
- 4.0
 
- 
startNodeDescription copied from interface:TraversalHandlerCalled during the traversal before an expression node children processing is started.- Specified by:
- startNodein interface- TraversalHandler
 
- 
endNodeDescription copied from interface:TraversalHandlerCalled during the traversal after an expression node children processing is finished.- Specified by:
- endNodein interface- TraversalHandler
- Since:
- 1.1
 
- 
objectNodeDescription copied from interface:TraversalHandlerCalled during the traversal when a leaf non-expression node is encountered.- Specified by:
- objectNodein interface- TraversalHandler
 
- 
parenthesisNeeded
- 
appendLiteralprotected void appendLiteral(Object val, DbAttribute attr, Expression parentExpression) throws IOExceptionDescription copied from class:QueryAssemblerHelperAppends SQL code to the query buffer to handlevalas a parameter to the PreparedStatement being built. Addsvalinto QueryAssembler parameter list.If valis null, "NULL" is appended to the query.If valis a DataObject, its primary key value is used as a parameter. Only objects with a single column primary key can be used.- Overrides:
- appendLiteralin 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
 
- 
processRelTerminationDescription copied from class:QueryAssemblerHelperHandles 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:
- processRelTerminationin class- QueryAssemblerHelper
 
- 
appendFunctionAppend 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
 
- 
appendExtractFunctionSpecial case for extract date/time parts functions as they have many variants- Since:
- 4.0
 
- 
appendFunctionArgprotected void appendFunctionArg(Object value, ASTFunctionCall functionExpression) throws IOExceptionAppend scalar argument of a function call Used only for values stored in ASTScalar other expressions appended in objectNode() method- Throws:
- IOException
- Since:
- 4.0
 
- 
appendFunctionArgDividerAppend divider between function arguments. In overriding methods can be replaced e.g. for " || " for CONCAT operation- Since:
- 4.0
 
- 
clearLastFunctionArgDividerClear last divider as we currently don't now position of argument until parent element is ended.- Since:
- 4.0
 
 
-