1 22 23 package org.xquark.extractor.algebra; 24 25 import java.util.Map ; 26 27 import org.xquark.extractor.common.SqlWrapperException; 28 import org.xquark.extractor.sql.SqlExpression; 29 30 public final class FunAggregate extends UnaryOperator 31 { 32 33 private static final String RCSRevision = "$Revision: 1.4 $"; 34 private static final String RCSName = "$Name: $"; 35 36 public final static int AVG = 0; 37 public final static int COUNT = 1; 38 public final static int MAX = 2; 39 public final static int MIN = 3; 40 public final static int SUM = 4; 41 42 public final static String [] AGGREGATE_FUNCTIONS = { 43 "AVG", 44 "COUNT", 45 "MAX", 46 "MIN", 47 "SUM" 48 }; 49 50 private boolean _distinct; 51 private int _operator ; 52 53 58 public FunAggregate( int operator ,Expression operand, boolean distinct) 59 { 60 61 super ( operand ); 62 setDistinct (distinct ); 63 setOperator (operator) ; 64 } 65 66 synchronized Object clone(Map clonedExprs) throws CloneNotSupportedException 67 { 68 FunAggregate retVal = (FunAggregate)super.clone(clonedExprs); 70 clonedExprs.put(this, retVal); 71 return retVal; 73 } 74 75 79 public boolean getDistinct() 80 { 81 return _distinct ; 82 } 83 84 88 public void setDistinct(boolean distinct) 89 { 90 _distinct = distinct ; 91 } 92 public void setOperator ( int operator ) 93 { 94 _operator = operator ; 95 } 96 97 public int getOperator () 98 { 99 return _operator ; 100 } 101 102 103 public boolean replaceChild(Expression oldChild, Expression newChild) 104 { 105 boolean retVal = false; 107 108 if (getOperand().equals(oldChild)) { 109 setOperand(newChild); 110 retVal = true; 111 } 112 113 return retVal; 115 } 116 117 public SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException 118 { 119 return visitor.visit(this); 120 } 121 122 public void accept (AlgebraVisitor visitor) throws SqlWrapperException 123 { 124 visitor.visit(this); 125 } 126 127 130 public boolean deepEquals(Object o) 131 { 132 if (o instanceof FunAggregate) 133 { 134 FunAggregate cast = (FunAggregate)o; 135 return super.deepEquals(o) && _distinct == cast.getDistinct() 136 && _operator == cast.getOperator(); 137 } 138 return false; 139 } 140 } 141 | Popular Tags |