FileDocCategorySizeDatePackage
SumNode.javaAPI DocGlassfish v2 API4796Tue May 22 16:54:40 BST 2007oracle.toplink.essentials.internal.parsing

SumNode

public class SumNode extends AggregateNode
INTERNAL

Purpose: Model a SUM

Responsibilities:

  • Apply itself to a query correctly

Fields Summary
Constructors Summary
Methods Summary
protected oracle.toplink.essentials.expressions.ExpressionaddAggregateExression(oracle.toplink.essentials.expressions.Expression expr)
INTERNAL

        return expr.sum();
    
public voidapplyToQuery(oracle.toplink.essentials.queryframework.ObjectLevelReadQuery theQuery, oracle.toplink.essentials.internal.parsing.GenerationContext context)
INTERNAL Apply this node to the passed query

        if (theQuery.isReportQuery()) {
            ReportQuery reportQuery = (ReportQuery)theQuery;
            reportQuery.addAttribute(resolveAttribute(), 
                                     generateExpression(context), 
                                     calculateReturnType(context));
            
        }
    
protected java.lang.ClasscalculateReturnType(oracle.toplink.essentials.internal.parsing.GenerationContext 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;
    
protected java.lang.ObjectcalculateReturnType(java.lang.Object argType, oracle.toplink.essentials.internal.parsing.TypeHelper helper)
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;
    
public java.lang.StringgetAsString()
INTERNAL Get the string representation of this node.

        return "SUM(" + left.getAsString() + ")";
    
public voidvalidate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Validate node and calculate its type.

        if (left != null) {
            left.validate(context);
            TypeHelper typeHelper = context.getTypeHelper();
            setType(calculateReturnType(left.getType(), typeHelper));
        }