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

MemberOfNode

public class MemberOfNode extends BinaryOperatorNode
INTERNAL

Purpose: Represent the MEMBER-OF operator

Responsibilities:

  • MEMBER OF is not supported.
author
Jon Driscoll and Joel Lucuik
since
since July 2003

Fields Summary
private boolean
notIndicated
private Expression
leftExpression
Constructors Summary
public MemberOfNode()
Return a new MemberOfNode


             
      
        super();
    
Methods Summary
public oracle.toplink.essentials.expressions.ExpressiongenerateExpression(oracle.toplink.essentials.internal.parsing.GenerationContext context)

        // Need to make sure one of the node is marked as a one to many
        if (getRight().isParameterNode()) {
            makeNodeOneToMany(getLeft());
        } else {
            makeNodeOneToMany(getRight());
        }

        //Handle NOT. Store the expression for the left, let VariableNode handle it.
        if (notIndicated()) {
            Expression resultFromRight = null;
            context.setMemberOfNode(this);
            this.setLeftExpression(getLeft().generateExpression(context));
            resultFromRight = getRight().generateExpression(context);
            //clean up
            context.setMemberOfNode(null);
            this.setLeftExpression(null);
            return resultFromRight;
        } else {
            //otherwise, handle like normal anyOf()
            return getRight().generateExpression(context).equal(getLeft().generateExpression(context));
        }
    
public oracle.toplink.essentials.expressions.ExpressiongetLeftExpression()

        return leftExpression;
    
public voidindicateNot()
INTERNAL Indicate if a NOT was found in the WHERE clause. Examples: ...WHERE ... NOT MEMBER OF

        notIndicated = true;
    
public voidmakeNodeOneToMany(oracle.toplink.essentials.internal.parsing.Node theNode)
INTERNAL makeNodeOneToMany: Traverse to the leaf on theNode and mark as one to many

        Node currentNode = theNode;
        do {
            if (!currentNode.hasRight()) {
                ((AttributeNode)currentNode).setRequiresCollectionAttribute(true);
                return;
            }
            currentNode = currentNode.getRight();
        } while (true);
    
public booleannotIndicated()

        return notIndicated;
    
public voidsetLeftExpression(oracle.toplink.essentials.expressions.Expression newLeftExpression)

        leftExpression = newLeftExpression;
    
public voidvalidate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Validate node and calculates its type.

        super.validate(context);
        Node left = getLeft();
        if (left.isVariableNode() && ((VariableNode)left).isAlias(context)) {
            context.usedVariable(((VariableNode)left).getCanonicalVariableName());
        }
        left.validateParameter(context, right.getType());
        TypeHelper typeHelper = context.getTypeHelper();
        setType(typeHelper.getBooleanType());