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

SetNode

public class SetNode extends MajorNode
INTERNAL: This node holds a list of all the updates that will occur in an Update Query. Slightly differnt from other nodes since holds more than two children in a list.

Fields Summary
private List
assignmentNodes
Constructors Summary
public SetNode()


      
        super();
        assignmentNodes = new Vector();
    
Methods Summary
public voidaddUpdatesToQuery(oracle.toplink.essentials.queryframework.UpdateAllQuery theQuery, oracle.toplink.essentials.internal.parsing.GenerationContext context)
Iterate through the updates in this query and build expressions for them. Set the built expressions on the query.

        Iterator iterator = assignmentNodes.iterator();
        while (iterator.hasNext()) {
            EqualsAssignmentNode node = (EqualsAssignmentNode)iterator.next();
            Expression leftExpression = getExpressionForNode(node.getLeft(), theQuery.getReferenceClass(), context);
            Expression rightExpression = getExpressionForNode(node.getRight(), theQuery.getReferenceClass(), context);
            theQuery.addUpdate(leftExpression, rightExpression);
        }
    
protected oracle.toplink.essentials.expressions.ExpressiongetExpressionForNode(oracle.toplink.essentials.internal.parsing.Node node, java.lang.Class referenceClass, oracle.toplink.essentials.internal.parsing.GenerationContext context)
Create an expression to represent one of the nodes on a SetToNode. We will assume that set_to nodes change elements that are direct mappings on the reference class of the query.

        Expression expression = null;
        if (node.isAttributeNode()) {
            // look up a preexisting expression based on the reference class of the query.
            String classVariable = context.getParseTreeContext().getVariableNameForClass(referenceClass, context);
            expression = context.expressionFor(classVariable);
            if (expression == null) {
                expression = new ExpressionBuilder();
                context.addExpression(expression, classVariable);
            }
            expression = node.addToExpression(expression, context);
        } else {
            expression = node.generateExpression(context);
        }
        return expression;
    
public oracle.toplink.essentials.internal.parsing.NodequalifyAttributeAccess(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Check the update item node for a path expression starting with a unqualified field access and if so, replace it by a qualified field access.

        for (Iterator i = assignmentNodes.iterator(); i.hasNext(); ) {
            Node item = (Node)i.next();
            item.qualifyAttributeAccess(context);
        }
        return this;
    
public voidsetAssignmentNodes(java.util.List nodes)
INTERNAL

        assignmentNodes = nodes;
    
public voidvalidate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Validate node.

        for (Iterator i = assignmentNodes.iterator(); i.hasNext(); ) {
            Node item = (Node)i.next();
            item.validate(context);
        }