FileDocCategorySizeDatePackage
ModNode.javaAPI DocGlassfish v2 API4603Tue May 22 16:54:38 BST 2007oracle.toplink.essentials.internal.parsing

ModNode

public class ModNode extends ArithmeticFunctionNode
INTERNAL

Purpose: Represent a MOD

Responsibilities:

  • Answer the correct expression for a MOD
  • Maintain the parts of a MOD statement e.g. SELECT ... FROM ... WHERE MOD(emp.salary, 2) > 1000
author
Jon Driscoll and Joel Lucuik
since
TopLink 4.0

Fields Summary
private Node
denominator
Constructors Summary
Methods Summary
public oracle.toplink.essentials.expressions.ExpressiongenerateExpression(oracle.toplink.essentials.internal.parsing.GenerationContext context)

        return ExpressionMath.mod(getLeft().generateExpression(context), 
                                  getDenominator().generateExpression(context));
    
public oracle.toplink.essentials.internal.parsing.NodegetDenominator()

        return denominator;
    
public oracle.toplink.essentials.internal.parsing.NodequalifyAttributeAccess(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Check the child nodes for an unqualified field access and if so, replace it by a qualified field access.


                               
        
       if (left != null) {
           left = left.qualifyAttributeAccess(context);
       }
       if (denominator != null) {
           denominator = denominator.qualifyAttributeAccess(context);
       }
       return this;
    
public voidsetDenominator(oracle.toplink.essentials.internal.parsing.Node denominator)

        this.denominator = denominator;
    
public voidvalidate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Validate node and calculate its type.

        TypeHelper typeHelper = context.getTypeHelper();
        if (left != null) {
            left.validate(context);
            left.validateParameter(context, typeHelper.getIntType());

            Object type = left.getType();
            if (!typeHelper.isIntegralType(type))
                throw EJBQLException.invalidFunctionArgument(
                    context.getQueryInfo(), left.getLine(), left.getColumn(), 
                    "MOD", left.getAsString(), "integral type");
        }

        if (denominator != null) {
            denominator.validate(context);
            denominator.validateParameter(context, typeHelper.getIntType());

            Object denominatorType = denominator.getType();
            if (!typeHelper.isIntegralType(denominatorType))
                throw EJBQLException.invalidFunctionArgument(
                    context.getQueryInfo(), denominator.getLine(), denominator.getColumn(), 
                    "MOD", denominator.getAsString(), "integral type");
        }

        setType(typeHelper.getIntType());