001 /*
002 // $Id: //open/mondrian-release/3.2/src/main/mondrian/calc/impl/AbstractIntegerCalc.java#1 $
003 // This software is subject to the terms of the Eclipse Public License v1.0
004 // Agreement, available at the following URL:
005 // http://www.eclipse.org/legal/epl-v10.html.
006 // Copyright (C) 2006-2009 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-release/3.2/src/main/mondrian/calc/impl/AbstractIntegerCalc.java#1 $
028 * @since Sep 26, 2005
029 */
030 public abstract class AbstractIntegerCalc
031 extends AbstractCalc
032 implements IntegerCalc
033 {
034 /**
035 * Creates an AbstractIntegerCalc.
036 *
037 * @param exp Source expression
038 * @param calcs Child compiled expressions
039 */
040 protected AbstractIntegerCalc(Exp exp, Calc[] calcs) {
041 super(exp, calcs);
042 assert getType() instanceof NumericType;
043 }
044
045 public Object evaluate(Evaluator evaluator) {
046 int i = evaluateInteger(evaluator);
047 if (i == FunUtil.IntegerNull) {
048 return null;
049 } else {
050 return i;
051 }
052 }
053 }
054
055 // End AbstractIntegerCalc.java