FileDocCategorySizeDatePackage
OrNode.javaAPI DocGlassfish v2 API4614Tue May 22 16:54:38 BST 2007oracle.toplink.essentials.internal.parsing

OrNode

public class OrNode extends LogicalOperatorNode
INTERNAL

Purpose: Represent an OR

Responsibilities:

  • Generate the correct expression for an OR
author
Jon Driscoll and Joel Lucuik
since
TopLink 4.0

Fields Summary
private Set
leftOuterScopeVariables
private Set
rightOuterScopeVariables
Constructors Summary
public OrNode()
Return a new OrNode.


             
      
        super();
    
Methods Summary
private oracle.toplink.essentials.expressions.ExpressionappendOuterScopeVariableJoins(oracle.toplink.essentials.expressions.Expression expr, java.util.Set outerScopeVariables, oracle.toplink.essentials.internal.parsing.GenerationContext context)
INTERNAL

        if ((outerScopeVariables == null) || outerScopeVariables.isEmpty()) {
            // no outer scope variables => nothing to be done
            return expr;
        }
        Expression joins = context.joinVariables(outerScopeVariables);
        return appendExpression(expr, joins);
    
public oracle.toplink.essentials.expressions.ExpressiongenerateExpression(oracle.toplink.essentials.internal.parsing.GenerationContext context)
INTERNAL Return a TopLink expression by 'OR'ing the expressions from the left and right nodes

        // Get the left expression
        Expression leftExpr = getLeft().generateExpression(context);
        leftExpr = appendOuterScopeVariableJoins(
            leftExpr, leftOuterScopeVariables, context);

        Expression rightExpr = getRight().generateExpression(context);
        rightExpr = appendOuterScopeVariableJoins(
            rightExpr, rightOuterScopeVariables, context);
        
        // Or it with whatever the right expression is
        return leftExpr.or(rightExpr);
    
public voidvalidate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Validate node and calculate its type.

        Set saved = context.getOuterScopeVariables();
        if (left != null) {
            context.resetOuterScopeVariables();
            left.validate(context);
            leftOuterScopeVariables = context.getOuterScopeVariables();
        }
        if (right != null) {
            context.resetOuterScopeVariables();
            right.validate(context);
            rightOuterScopeVariables = context.getOuterScopeVariables();
        }
        context.resetOuterScopeVariables(saved);
        if ((left != null) && (right != null)) {
            left.validateParameter(context, right.getType());
            right.validateParameter(context, left.getType());
        }
        
        TypeHelper typeHelper = context.getTypeHelper();
        setType(typeHelper.getBooleanType());