1 21 package oracle.toplink.essentials.internal.parsing; 23 24 import oracle.toplink.essentials.expressions.*; 25 import oracle.toplink.essentials.queryframework.*; 26 import java.util.*; 27 28 33 public class SetNode extends MajorNode { 34 private List assignmentNodes = null; 35 36 public SetNode() { 37 super(); 38 assignmentNodes = new Vector(); 39 } 40 41 45 public void addUpdatesToQuery(UpdateAllQuery theQuery, GenerationContext context) { 46 Iterator iterator = assignmentNodes.iterator(); 47 while (iterator.hasNext()) { 48 EqualsAssignmentNode node = (EqualsAssignmentNode)iterator.next(); 49 Expression leftExpression = getExpressionForNode(node.getLeft(), theQuery.getReferenceClass(), context); 50 Expression rightExpression = getExpressionForNode(node.getRight(), theQuery.getReferenceClass(), context); 51 theQuery.addUpdate(leftExpression, rightExpression); 52 } 53 } 54 55 59 public void validate(ParseTreeContext context) { 60 for (Iterator i = assignmentNodes.iterator(); i.hasNext(); ) { 61 Node item = (Node)i.next(); 62 item.validate(context); 63 } 64 } 65 66 71 protected Expression getExpressionForNode(Node node, Class referenceClass, GenerationContext context) { 72 Expression expression = null; 73 if (node.isAttributeNode()) { 74 String classVariable = context.getParseTreeContext().getVariableNameForClass(referenceClass, context); 76 expression = context.expressionFor(classVariable); 77 if (expression == null) { 78 expression = new ExpressionBuilder(); 79 context.addExpression(expression, classVariable); 80 } 81 expression = node.addToExpression(expression, context); 82 } else { 83 expression = node.generateExpression(context); 84 } 85 return expression; 86 } 87 88 91 public void setAssignmentNodes(List nodes) { 92 assignmentNodes = nodes; 93 } 94 95 } 96 | Popular Tags |