Class ExpressionNormalizer
- java.lang.Object
-
- org.eclipse.persistence.internal.expressions.ExpressionNormalizer
-
public class ExpressionNormalizer extends java.lang.ObjectThis is used during the normalization process to allow for a single main expression traversal.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanaddAdditionalExpressionsWithinCurrrentExpressionContextUsed to trigger adding additional join operations etc to the expression being processed instead of at the end of the where clause.protected ExpressionadditionalExpressionA new root expression can be made from joins being added to the original expression.protected ExpressionadditionalLocalExpressionLocal expression from joins being added to the original expression.protected java.util.Map<Expression,Expression>clonedExpressionsUsed to maintain identity of cloned expressions.protected AbstractSessionsessionThe session being normalized in.protected SQLSelectStatementstatementThe statement being normalized.protected java.util.List<SubSelectExpression>subSelectExpressionsSubselect expressions found in the course of normalization.
-
Constructor Summary
Constructors Constructor Description ExpressionNormalizer(SQLSelectStatement statement)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAdditionalExpression(Expression theExpression)voidaddAdditionalLocalExpression(Expression theExpression)Similar to addAdditionalExpression, this keeps a running expression used for joins so that they can be added locally within 'OR' predicates rather than to the entire where clause.voidaddSubSelectExpression(SubSelectExpression subSelectExpression)INTERNAL: Remember this subselect so that it can be normalized after the enclosing select statement is.booleanencounteredSubSelectExpressions()INTERNAL: Were subselect expressions found while normalizing the selection criteria? Assumes underlying collection is initialized on first add.ExpressiongetAdditionalExpression()java.util.Map<Expression,Expression>getClonedExpressions()AbstractSessiongetSession()SQLSelectStatementgetStatement()booleanisAddAdditionalExpressionsWithinCurrrentExpressionContext()voidnormalizeSubSelects(java.util.Map clonedExpressions)INTERNAL: Normalize all subselect expressions found in the course of normalizing the enclosing query.ExpressionprocessAdditionalLocalExpressions(Expression localExpression, boolean isLogicalExpression)INTERNAL This will return the localExpression if isLogicalExpression is false, otherwise it will check the addAdditionalExpressionsWithinCurrrentExpressionContext flag and clear additionalLocalExpression once adding it to the localExpression.voidsetAddAdditionalExpressionsWithinCurrrentExpressionContext(boolean addAdditionalExpressionsWithinCurrrentExpressionContext)INTERNAL: Allows keeping track when the normalizer is within a logical OR statement, where additionalExpressions might need to be added to the local expression instead of at the end of the where clause.voidsetAdditionalExpression(Expression additionalExpression)voidsetClonedExpressions(java.util.Map<Expression,Expression> clonedExpressions)voidsetSession(AbstractSession session)voidsetStatement(SQLSelectStatement statement)
-
-
-
Field Detail
-
additionalExpression
protected Expression additionalExpression
A new root expression can be made from joins being added to the original expression.
-
statement
protected SQLSelectStatement statement
The statement being normalized.
-
subSelectExpressions
protected java.util.List<SubSelectExpression> subSelectExpressions
Subselect expressions found in the course of normalization.
-
session
protected AbstractSession session
The session being normalized in.
-
clonedExpressions
protected java.util.Map<Expression,Expression> clonedExpressions
Used to maintain identity of cloned expressions.
-
addAdditionalExpressionsWithinCurrrentExpressionContext
protected boolean addAdditionalExpressionsWithinCurrrentExpressionContext
Used to trigger adding additional join operations etc to the expression being processed instead of at the end of the where clause. Useful for dealing with Treat within an Or clause, as the type expression needs to be appended within the OR condition rather AND'd to the entire thing.
-
additionalLocalExpression
protected Expression additionalLocalExpression
Local expression from joins being added to the original expression.
-
-
Constructor Detail
-
ExpressionNormalizer
public ExpressionNormalizer(SQLSelectStatement statement)
-
-
Method Detail
-
getClonedExpressions
public java.util.Map<Expression,Expression> getClonedExpressions()
-
setClonedExpressions
public void setClonedExpressions(java.util.Map<Expression,Expression> clonedExpressions)
-
addAdditionalExpression
public void addAdditionalExpression(Expression theExpression)
-
addSubSelectExpression
public void addSubSelectExpression(SubSelectExpression subSelectExpression)
INTERNAL: Remember this subselect so that it can be normalized after the enclosing select statement is.
-
getAdditionalExpression
public Expression getAdditionalExpression()
-
getSession
public AbstractSession getSession()
-
getStatement
public SQLSelectStatement getStatement()
-
encounteredSubSelectExpressions
public boolean encounteredSubSelectExpressions()
INTERNAL: Were subselect expressions found while normalizing the selection criteria? Assumes underlying collection is initialized on first add.
-
normalizeSubSelects
public void normalizeSubSelects(java.util.Map clonedExpressions)
INTERNAL: Normalize all subselect expressions found in the course of normalizing the enclosing query. This method allows one to completely normalize the parent statement first (which should treat its sub selects as black boxes), and then normalize the subselects (which require full knowledge of the enclosing statement). This should make things clearer too, Assumes encounteredSubSelectExpressions() true. For CR#4223.
-
setAdditionalExpression
public void setAdditionalExpression(Expression additionalExpression)
-
setSession
public void setSession(AbstractSession session)
-
setStatement
public void setStatement(SQLSelectStatement statement)
-
addAdditionalLocalExpression
public void addAdditionalLocalExpression(Expression theExpression)
Similar to addAdditionalExpression, this keeps a running expression used for joins so that they can be added locally within 'OR' predicates rather than to the entire where clause. If addAdditionalExpressionsWithinCurrrentExpressionContext is false, it will work the same as addAdditionalExpression- Parameters:
theExpression-
-
processAdditionalLocalExpressions
public Expression processAdditionalLocalExpressions(Expression localExpression, boolean isLogicalExpression)
INTERNAL This will return the localExpression if isLogicalExpression is false, otherwise it will check the addAdditionalExpressionsWithinCurrrentExpressionContext flag and clear additionalLocalExpression once adding it to the localExpression.- Parameters:
localExpression-isLogicalExpression-- Returns:
-
isAddAdditionalExpressionsWithinCurrrentExpressionContext
public boolean isAddAdditionalExpressionsWithinCurrrentExpressionContext()
-
setAddAdditionalExpressionsWithinCurrrentExpressionContext
public void setAddAdditionalExpressionsWithinCurrrentExpressionContext(boolean addAdditionalExpressionsWithinCurrrentExpressionContext)
INTERNAL: Allows keeping track when the normalizer is within a logical OR statement, where additionalExpressions might need to be added to the local expression instead of at the end of the where clause.- Parameters:
addAdditionalExpressionsWithinCurrrentExpressionContext-
-
-