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 37 public class CountNode extends AggregateNode { 38 39 43 public void applyToQuery(ObjectLevelReadQuery theQuery, GenerationContext context) { 44 if (theQuery.isReportQuery()) { 45 ReportQuery reportQuery = (ReportQuery)theQuery; 46 if (getLeft().isDotNode()) { 47 reportQuery.addCount(resolveAttribute(), 50 getArgumentExpression(context), Long .class); 51 } else { 52 reportQuery.addCount("COUNT", getArgumentExpression(context), Long .class); 53 } 54 } 55 } 56 57 61 public void validate(ParseTreeContext context) { 62 if (left != null) { 63 left.validate(context); 64 TypeHelper typeHelper = context.getTypeHelper(); 65 setType(typeHelper.getLongClassType()); 66 } 67 } 68 69 73 public Expression generateExpression(GenerationContext context) { 74 return getArgumentExpression(context).count(); 75 } 76 77 81 public boolean isCountNode() { 82 return true; 83 } 84 88 public String getAsString() { 89 return "COUNT(" + left.getAsString() + ")"; 90 } 91 } 92 | Popular Tags |