1 19 20 package org.apache.cayenne.exp.parser; 21 22 import org.apache.commons.collections.Transformer; 23 import org.apache.cayenne.exp.ExpressionException; 24 25 33 public abstract class AggregateConditionNode extends SimpleNode { 34 AggregateConditionNode(int i) { 35 super(i); 36 } 37 38 protected boolean pruneNodeForPrunedChild(Object prunedChild) { 39 return false; 40 } 41 42 protected Object transformExpression(Transformer transformer) { 43 Object transformed = super.transformExpression(transformer); 44 45 if (!(transformed instanceof AggregateConditionNode)) { 46 return transformed; 47 } 48 49 AggregateConditionNode condition = (AggregateConditionNode) transformed; 50 51 switch (condition.getOperandCount()) { 54 case 1 : 55 return condition.getOperand(0); 56 case 0 : 57 return PRUNED_NODE; 58 default : 59 return condition; 60 } 61 } 62 63 public void jjtSetParent(Node n) { 64 67 if (!(n instanceof AggregateConditionNode)) { 69 String label = 70 (n instanceof SimpleNode) 71 ? ((SimpleNode) n).expName() 72 : String.valueOf(n); 73 throw new ExpressionException(expName() + ": invalid parent - " + label); 74 } 75 76 super.jjtSetParent(n); 77 } 78 79 public void jjtAddChild(Node n, int i) { 80 83 if (!(n instanceof ConditionNode) && !(n instanceof AggregateConditionNode)) { 85 String label = 86 (n instanceof SimpleNode) 87 ? ((SimpleNode) n).expName() 88 : String.valueOf(n); 89 throw new ExpressionException(expName() + ": invalid child - " + label); 90 } 91 92 super.jjtAddChild(n, i); 93 } 94 } 95 | Popular Tags |