1 21 package oracle.toplink.essentials.internal.parsing; 23 24 import oracle.toplink.essentials.queryframework.ObjectLevelReadQuery; 25 import oracle.toplink.essentials.queryframework.ReportQuery; 26 import oracle.toplink.essentials.expressions.Expression; 27 28 35 public class AvgNode extends AggregateNode { 36 37 41 public void applyToQuery(ObjectLevelReadQuery theQuery, GenerationContext context) { 42 if (theQuery.isReportQuery()) { 43 ReportQuery reportQuery = (ReportQuery)theQuery; 44 reportQuery.addAverage(resolveAttribute(), 45 getArgumentExpression(context), Double .class); 46 } 47 } 48 49 53 public void validate(ParseTreeContext context) { 54 if (left != null) { 55 left.validate(context); 56 } 57 TypeHelper typeHelper = context.getTypeHelper(); 58 setType(typeHelper.getDoubleClassType()); 59 } 60 61 65 public Expression generateExpression(GenerationContext context) { 66 return getArgumentExpression(context).average(); 67 } 68 69 73 public String getAsString() { 74 return "AVG(" + left.getAsString() + ")"; 75 } 76 } 77 | Popular Tags |