001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2006-2009 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.calc.impl;
011
012import mondrian.calc.BooleanCalc;
013import mondrian.calc.Calc;
014import mondrian.olap.Evaluator;
015import mondrian.olap.Exp;
016
017/**
018 * Abstract implementation of the {@link mondrian.calc.BooleanCalc} interface.
019 *
020 * <p>The derived class must
021 * implement the {@link #evaluateBoolean(mondrian.olap.Evaluator)} method,
022 * and the {@link #evaluate(mondrian.olap.Evaluator)} method will call it.
023 *
024 * @author jhyde
025 * @since Sep 26, 2005
026 */
027public abstract class AbstractBooleanCalc
028    extends AbstractCalc
029    implements BooleanCalc
030{
031    /**
032     * Creates an AbstractBooleanCalc.
033     *
034     * @param exp Source expression
035     * @param calcs Child compiled expressions
036     */
037    public AbstractBooleanCalc(Exp exp, Calc[] calcs) {
038        super(exp, calcs);
039        // now supports int and double conversion (see
040        // AbstractExpCompiler.compileBoolean():
041        // assert getType() instanceof BooleanType;
042    }
043
044    public Object evaluate(Evaluator evaluator) {
045        return Boolean.valueOf(evaluateBoolean(evaluator));
046    }
047}
048
049// End AbstractBooleanCalc.java