1 2 12 package com.versant.core.jdo.query; 13 14 import com.versant.core.metadata.ClassMetaData; 15 16 19 public class AggregateNode extends UnaryNode { 20 21 public static final int TYPE_SUM = 1; 22 public static final int TYPE_AVG = 2; 23 public static final int TYPE_COUNT = 3; 24 public static final int TYPE_MIN = 4; 25 public static final int TYPE_MAX = 5; 26 27 private int type; 28 29 public AggregateNode(Node child, int type) { 30 super(child); 31 this.asValue = child.asValue; 32 this.type = type; 33 } 34 35 public AggregateNode() { 36 type = TYPE_COUNT; 37 } 38 39 43 public void resolve(QueryParser comp, ClassMetaData cmd, boolean ordering) { 44 childList.resolve(comp, cmd, ordering); 45 } 46 47 public String getTypeString() { 48 switch (type) { 49 case AggregateNode.TYPE_AVG: 50 return "AVG"; 51 case AggregateNode.TYPE_COUNT: 52 return "COUNT"; 53 case AggregateNode.TYPE_MAX: 54 return "MAX"; 55 case AggregateNode.TYPE_MIN: 56 return "MIN"; 57 case AggregateNode.TYPE_SUM: 58 return "SUM"; 59 } 60 return "UNKNOWN(" + type + ")"; 61 } 62 63 public int getType() { 64 return type; 65 } 66 67 public String toString() { 68 return super.toString() + "Type " + getTypeString() + " as " + asValue; 69 } 70 71 public Object accept(NodeVisitor visitor, Object [] results) { 72 return visitor.visitAggregateNode(this, results); 73 } 74 75 public Object arrive(NodeVisitor v, Object msg) { 76 return v.arriveAggregateNode(this, msg); 77 } 78 } 79 | Popular Tags |