001 /* 002 // $Id: //open/mondrian/src/main/mondrian/calc/impl/AbstractIntegerCalc.java#4 $ 003 // This software is subject to the terms of the Common Public License 004 // Agreement, available at the following URL: 005 // http://www.opensource.org/licenses/cpl.html. 006 // Copyright (C) 2006-2006 Julian Hyde 007 // All Rights Reserved. 008 // You must accept the terms of that agreement to use this software. 009 */ 010 package mondrian.calc.impl; 011 012 import mondrian.olap.Evaluator; 013 import mondrian.olap.Exp; 014 import mondrian.olap.fun.FunUtil; 015 import mondrian.olap.type.NumericType; 016 import mondrian.calc.IntegerCalc; 017 import mondrian.calc.Calc; 018 019 /** 020 * Abstract implementation of the {@link mondrian.calc.IntegerCalc} interface. 021 * 022 * <p>The derived class must 023 * implement the {@link #evaluateInteger(mondrian.olap.Evaluator)} method, 024 * and the {@link #evaluate(mondrian.olap.Evaluator)} method will call it. 025 * 026 * @author jhyde 027 * @version $Id: //open/mondrian/src/main/mondrian/calc/impl/AbstractIntegerCalc.java#4 $ 028 * @since Sep 26, 2005 029 */ 030 public abstract class AbstractIntegerCalc 031 extends AbstractCalc 032 implements IntegerCalc { 033 private final Calc[] calcs; 034 035 protected AbstractIntegerCalc(Exp exp, Calc[] calcs) { 036 super(exp); 037 this.calcs = calcs; 038 assert getType() instanceof NumericType; 039 } 040 041 public Object evaluate(Evaluator evaluator) { 042 int i = evaluateInteger(evaluator); 043 if (i == FunUtil.IntegerNull) { 044 return null; 045 } else { 046 return i; 047 } 048 } 049 050 public Calc[] getCalcs() { 051 return calcs; 052 } 053 } 054 055 // End AbstractIntegerCalc.java