1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import org.apache.commons.collections.Transformer; 59 import org.objectstyle.cayenne.exp.Expression; 60 import org.objectstyle.cayenne.exp.ExpressionException; 61 62 70 public abstract class AggregateConditionNode extends SimpleNode { 71 AggregateConditionNode(int i) { 72 super(i); 73 } 74 75 protected boolean pruneNodeForPrunedChild(Object prunedChild) { 76 return false; 77 } 78 79 public Expression transform(Transformer transformer) { 80 Expression copy = super.transform(transformer); 81 82 if (!(copy instanceof AggregateConditionNode)) { 83 return copy; 84 } 85 86 switch (copy.getOperandCount()) { 89 case 1 : 90 return (Expression) copy.getOperand(0); 91 case 0 : 92 return null; 93 default : 94 return copy; 95 } 96 } 97 98 public void jjtSetParent(Node n) { 99 102 if (!(n instanceof AggregateConditionNode)) { 104 String label = 105 (n instanceof SimpleNode) 106 ? ((SimpleNode) n).expName() 107 : String.valueOf(n); 108 throw new ExpressionException(expName() + ": invalid parent - " + label); 109 } 110 111 super.jjtSetParent(n); 112 } 113 114 public void jjtAddChild(Node n, int i) { 115 118 if (!(n instanceof ConditionNode) && !(n instanceof AggregateConditionNode)) { 120 String label = 121 (n instanceof SimpleNode) 122 ? ((SimpleNode) n).expName() 123 : String.valueOf(n); 124 throw new ExpressionException(expName() + ": invalid child - " + label); 125 } 126 127 super.jjtAddChild(n, i); 128 } 129 } 130 | Popular Tags |