KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > fun > IsEmptyFunDef


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/fun/IsEmptyFunDef.java#2 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2006-2006 Julian Hyde
7 // All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 */

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 /**
21  * Definition of the <code>IsEmpty</code> MDX function.
22  *
23  * @author jhyde
24  * @version $Id: //open/mondrian/src/main/mondrian/olap/fun/IsEmptyFunDef.java#2 $
25  * @since Mar 23, 2006
26  */

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 JavaDoc[] {"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 JavaDoc[] {"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 JavaDoc o = calc.evaluate(evaluator);
51                 return o == null;
52             }
53         };
54     }
55 }
56
57 // End IsEmptyFunDef.java
58
Popular Tags