001    /*
002    // $Id: //open/mondrian/src/main/mondrian/calc/impl/AbstractLevelCalc.java#2 $
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.type.LevelType;
015    import mondrian.calc.impl.AbstractCalc;
016    import mondrian.calc.LevelCalc;
017    import mondrian.calc.Calc;
018    
019    /**
020     * Abstract implementation of the {@link mondrian.calc.LevelCalc} interface.
021     *
022     * <p>The derived class must
023     * implement the {@link #evaluateLevel(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/AbstractLevelCalc.java#2 $
028     * @since Sep 26, 2005
029     */
030    public abstract class AbstractLevelCalc
031            extends AbstractCalc
032            implements LevelCalc {
033        private final Calc[] calcs;
034    
035        protected AbstractLevelCalc(Exp exp, Calc[] calcs) {
036            super(exp);
037            this.calcs = calcs;
038            assert getType() instanceof LevelType;
039        }
040    
041        public Object evaluate(Evaluator evaluator) {
042            return evaluateLevel(evaluator);
043        }
044    
045        public Calc[] getCalcs() {
046            return calcs;
047        }
048    }
049    
050    // End AbstractLevelCalc.java