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.olap.fun; 011 012import mondrian.calc.Calc; 013import mondrian.calc.ExpCompiler; 014import mondrian.calc.impl.AbstractBooleanCalc; 015import mondrian.mdx.ResolvedFunCall; 016import mondrian.olap.Evaluator; 017import mondrian.olap.FunDef; 018 019/** 020 * Definition of the <code>IsEmpty</code> MDX function. 021 * 022 * @author jhyde 023 * @since Mar 23, 2006 024 */ 025class IsEmptyFunDef extends FunDefBase { 026 static final ReflectiveMultiResolver FunctionResolver = 027 new ReflectiveMultiResolver( 028 "IsEmpty", 029 "IsEmpty(<Value Expression>)", 030 "Determines if an expression evaluates to the empty cell value.", 031 new String[] {"fbS", "fbn"}, 032 IsEmptyFunDef.class); 033 034 static final ReflectiveMultiResolver PostfixResolver = 035 new ReflectiveMultiResolver( 036 "IS EMPTY", 037 "<Value Expression> IS EMPTY", 038 "Determines if an expression evaluates to the empty cell value.", 039 new String[] {"Qbm", "Qbt"}, 040 IsEmptyFunDef.class); 041 042 public IsEmptyFunDef(FunDef dummyFunDef) { 043 super(dummyFunDef); 044 } 045 046 public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) { 047 final Calc calc = compiler.compileScalar(call.getArg(0), true); 048 return new AbstractBooleanCalc(call, new Calc[] {calc}) { 049 public boolean evaluateBoolean(Evaluator evaluator) { 050 Object o = calc.evaluate(evaluator); 051 return o == null; 052 } 053 }; 054 } 055} 056 057// End IsEmptyFunDef.java