1 2 12 package com.versant.core.ejb.query; 13 14 17 public class AggregateNode extends Node { 18 19 public static final int AVG = 1; 20 public static final int MAX = 2; 21 public static final int MIN = 3; 22 public static final int SUM = 4; 23 public static final int COUNT = 5; 24 25 private int op; 26 private boolean distinct; 27 private PathNode path; 28 29 public AggregateNode(int op, boolean distinct, PathNode path) { 30 this.op = op; 31 this.distinct = distinct; 32 this.path = path; 33 } 34 35 public int getOp() { 36 return op; 37 } 38 39 public boolean isDistinct() { 40 return distinct; 41 } 42 43 public PathNode getPath() { 44 return path; 45 } 46 47 public String getOpStr() { 48 switch (op) { 49 case AVG: return "AVG"; 50 case MAX: return "MAX"; 51 case MIN: return "MIN"; 52 case SUM: return "SUM"; 53 case COUNT: return "COUNT"; 54 } 55 return "<? op " + op + "?>"; 56 } 57 58 public Object arrive(NodeVisitor v, Object msg) { 59 return v.arriveAggregateNode(this, msg); 60 } 61 62 public String toStringImp() { 63 StringBuffer s = new StringBuffer (); 64 s.append(getOpStr()); 65 s.append('('); 66 if (distinct) { 67 s.append("DISTINCT "); 68 } 69 s.append(path); 70 s.append(')'); 71 return s.toString(); 72 } 73 74 public void resolve(ResolveContext rc) { 75 path.resolve(rc); 76 } 77 78 } 79 80 | Popular Tags |