1 23 24 package org.objectweb.medor.filter.lib; 25 26 import org.objectweb.jorm.type.api.PTypeSpace; 27 import org.objectweb.medor.expression.api.Expression; 28 import org.objectweb.medor.expression.api.ExpressionException; 29 import org.objectweb.medor.expression.api.MalformedExpressionException; 30 import org.objectweb.medor.expression.api.Operand; 31 import org.objectweb.medor.expression.api.Operator; 32 import org.objectweb.medor.expression.api.ParameterOperand; 33 import org.objectweb.medor.expression.lib.BasicVariableOperand; 34 35 import java.util.Map ; 36 37 52 public class Count extends BasicAggregateOperator { 53 54 private boolean countAll = false; 55 56 public Count() { 57 countAll = true; 58 } 59 60 public Count(Expression e) { 61 super(PTypeSpace.LONG, e); 62 } 63 64 public Count(Expression e, boolean distinct) { 65 super(PTypeSpace.LONG, e, distinct); 66 } 67 68 public Object clone(Object clone, Map obj2clone) throws CloneNotSupportedException { 69 clone = super.clone(clone, obj2clone); 70 ((Count) clone).countAll = countAll; 71 return clone; 72 } 73 74 public String getOperatorString() { 75 return Operator.COUNT; 76 } 77 78 public Operand compileExpression() 79 throws ExpressionException, MalformedExpressionException { 80 if (expressions[0] != null) { 81 expressions[0].compileExpression(); 82 result = new BasicVariableOperand(expressions[0].getType()); 83 verified = true; 84 } 85 else 86 throw new MalformedExpressionException("null children value"); 88 return result; 89 } 90 91 public Operand evaluate(ParameterOperand[] pos, Object o) 92 throws ExpressionException { 93 throw new ExpressionException("Implementation of Avg by MEDOR not yet implemented"); 94 } 95 96 public boolean countAll() { 97 return countAll; 98 } 99 100 public void setCountAll() { 101 countAll = true; 102 distinct = false; 103 } 104 } 105 | Popular Tags |