1 10 package mondrian.olap.fun; 11 12 import mondrian.olap.*; 13 import mondrian.calc.Calc; 14 import mondrian.calc.ExpCompiler; 15 import mondrian.calc.TupleCalc; 16 import mondrian.calc.impl.AbstractBooleanCalc; 17 import mondrian.mdx.ResolvedFunCall; 18 19 27 class IsFunDef extends FunDefBase { 28 static final ReflectiveMultiResolver Resolver = new ReflectiveMultiResolver( 29 "IS", 30 "<Expression> IS <Expression>", 31 "Returns whether two objects are the same", 32 new String [] {"ibmm", "ibll", "ibhh", "ibdd", "ibtt"}, 33 IsFunDef.class); 34 35 public IsFunDef(FunDef dummyFunDef) { 36 super(dummyFunDef); 37 } 38 39 public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) { 40 final int category = call.getArg(0).getCategory(); 41 switch (category) { 42 case Category.Tuple: 43 final TupleCalc tupleCalc0 = compiler.compileTuple(call.getArg(0)); 44 final TupleCalc tupleCalc1 = compiler.compileTuple(call.getArg(1)); 45 return new AbstractBooleanCalc(call, new Calc[] {tupleCalc0, tupleCalc1}) { 46 public boolean evaluateBoolean(Evaluator evaluator) { 47 Member[] o0 = tupleCalc0.evaluateTuple(evaluator); 48 Member[] o1 = tupleCalc1.evaluateTuple(evaluator); 49 return equalTuple(o0, o1); 50 } 51 }; 52 default: 53 assert category == call.getArg(1).getCategory(); 54 final Calc calc0 = compiler.compile(call.getArg(0)); 55 final Calc calc1 = compiler.compile(call.getArg(1)); 56 return new AbstractBooleanCalc(call, new Calc[] {calc0, calc1}) { 57 public boolean evaluateBoolean(Evaluator evaluator) { 58 Object o0 = calc0.evaluate(evaluator); 59 Object o1 = calc1.evaluate(evaluator); 60 return o0 == o1; 61 } 62 }; 63 } 64 } 65 } 66 67 | Popular Tags |