Purpose: Model a SUM
Responsibilities:
INTERNAL return expr.sum();
return expr.sum();
INTERNAL Apply this node to the passed query if (theQuery.isReportQuery()) { ReportQuery reportQuery = (ReportQuery)theQuery; reportQuery.addAttribute(resolveAttribute(), generateExpression(context), calculateReturnType(context)); }
if (theQuery.isReportQuery()) { ReportQuery reportQuery = (ReportQuery)theQuery; reportQuery.addAttribute(resolveAttribute(), generateExpression(context), calculateReturnType(context)); }
INTERNAL This method calculates the return type of the SUM operation. Class returnType = null; if (getLeft().isDotNode()){ DotNode arg = (DotNode)getLeft(); Class fieldType = arg.getTypeOfDirectToField(context); TypeHelper helper = context.getParseTreeContext().getTypeHelper(); returnType = (Class)calculateReturnType(fieldType, helper); } return returnType;
Class returnType = null; if (getLeft().isDotNode()){ DotNode arg = (DotNode)getLeft(); Class fieldType = arg.getTypeOfDirectToField(context); TypeHelper helper = context.getParseTreeContext().getTypeHelper(); returnType = (Class)calculateReturnType(fieldType, helper); } return returnType;
INTERNAL Helper method to calculate the return type of the SUM operation. Object returnType = null; if (helper.isIntegralType(argType)) { returnType = helper.getLongClassType(); } else if (helper.isFloatingPointType(argType)) { returnType = helper.getDoubleClassType(); } else if (helper.isBigIntegerType(argType)) { returnType = helper.getBigIntegerType(); } else if (helper.isBigDecimalType(argType)) { returnType = helper.getBigDecimalType(); } return returnType;
Object returnType = null; if (helper.isIntegralType(argType)) { returnType = helper.getLongClassType(); } else if (helper.isFloatingPointType(argType)) { returnType = helper.getDoubleClassType(); } else if (helper.isBigIntegerType(argType)) { returnType = helper.getBigIntegerType(); } else if (helper.isBigDecimalType(argType)) { returnType = helper.getBigDecimalType(); } return returnType;
INTERNAL Get the string representation of this node. return "SUM(" + left.getAsString() + ")";
return "SUM(" + left.getAsString() + ")";
INTERNAL Validate node and calculate its type. if (left != null) { left.validate(context); TypeHelper typeHelper = context.getTypeHelper(); setType(calculateReturnType(left.getType(), typeHelper)); }
if (left != null) { left.validate(context); TypeHelper typeHelper = context.getTypeHelper(); setType(calculateReturnType(left.getType(), typeHelper)); }