1 10 package mondrian.olap.fun; 11 12 import mondrian.olap.FunDef; 13 import mondrian.olap.Evaluator; 14 import mondrian.olap.Util; 15 import mondrian.calc.Calc; 16 import mondrian.calc.ExpCompiler; 17 import mondrian.calc.impl.AbstractBooleanCalc; 18 import mondrian.mdx.ResolvedFunCall; 19 20 27 class IsEmptyFunDef extends FunDefBase { 28 static final ReflectiveMultiResolver FunctionResolver = new ReflectiveMultiResolver( 29 "IsEmpty", 30 "IsEmpty(<Value Expression>)", 31 "Determines if an expression evaluates to the empty cell value.", 32 new String [] {"fbS", "fbn"}, 33 IsEmptyFunDef.class); 34 35 static final ReflectiveMultiResolver PostfixResolver = new ReflectiveMultiResolver( 36 "IS EMPTY", 37 "<Value Expression> IS EMPTY", 38 "Determines if an expression evaluates to the empty cell value.", 39 new String [] {"Qbm", "Qbt"}, 40 IsEmptyFunDef.class); 41 42 public IsEmptyFunDef(FunDef dummyFunDef) { 43 super(dummyFunDef); 44 } 45 46 public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) { 47 final Calc calc = compiler.compileScalar(call.getArg(0), true); 48 return new AbstractBooleanCalc(call, new Calc[] {calc}) { 49 public boolean evaluateBoolean(Evaluator evaluator) { 50 Object o = calc.evaluate(evaluator); 51 return o == null; 52 } 53 }; 54 } 55 } 56 57 | Popular Tags |