KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/fun/IsNullFunDef.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.calc.Calc;
13 import mondrian.calc.ExpCompiler;
14 import mondrian.calc.MemberCalc;
15 import mondrian.calc.impl.AbstractBooleanCalc;
16 import mondrian.mdx.ResolvedFunCall;
17 import mondrian.olap.Evaluator;
18 import mondrian.olap.FunDef;
19 import mondrian.olap.Member;
20 import mondrian.olap.Literal;
21
22 /**
23  * Definition of the <code>IS NULL</code> MDX function.
24  *
25  * @author medstat
26  * @version $Id: //open/mondrian/src/main/mondrian/olap/fun/IsNullFunDef.java#2 $
27  * @since Aug 21, 2006
28  */

29 class IsNullFunDef extends FunDefBase {
30     /**
31      * Resolves calls to the <code>IS NULL</code> postfix operator.
32      */

33     static final ReflectiveMultiResolver Resolver = new ReflectiveMultiResolver(
34             "IS NULL",
35             "<Expression> IS NULL",
36             "Returns whether an object is null",
37             new String JavaDoc[]{"Qbm", "Qbl", "Qbh", "Qbd"},
38             IsNullFunDef.class);
39
40     public IsNullFunDef(FunDef dummyFunDef) {
41         super(dummyFunDef);
42     }
43
44     public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
45         assert call.getArgCount() == 1;
46         final MemberCalc memberCalc = compiler.compileMember(call.getArg(0));
47         return new AbstractBooleanCalc(call, new Calc[]{memberCalc}) {
48             public boolean evaluateBoolean(Evaluator evaluator) {
49                 Member member = memberCalc.evaluateMember(evaluator);
50                 return member.isNull();
51             }
52         };
53     }
54 }
55
56 // End IsNullFunDef.java
57
Popular Tags