1 10 package mondrian.calc.impl; 11 12 import mondrian.olap.Evaluator; 13 import mondrian.olap.Exp; 14 import mondrian.olap.type.SetType; 15 import mondrian.calc.ListCalc; 16 import mondrian.calc.Calc; 17 import mondrian.calc.ExpCompiler; 18 19 import java.util.List ; 20 21 32 public abstract class AbstractListCalc 33 extends AbstractCalc 34 implements ListCalc { 35 private final Calc[] calcs; 36 private final boolean mutable; 37 38 46 protected AbstractListCalc(Exp exp, Calc[] calcs) { 47 this(exp, calcs, true); 48 } 49 50 59 protected AbstractListCalc(Exp exp, Calc[] calcs, boolean mutable) { 60 super(exp); 61 this.calcs = calcs; 62 this.mutable = mutable; 63 assert getType() instanceof SetType : "expecting a set: " + getType(); 64 } 65 66 public Object evaluate(Evaluator evaluator) { 67 final List list = evaluateList(evaluator); 68 assert list != null : "null as empty list is deprecated"; 69 return list; 70 } 71 72 public Calc[] getCalcs() { 73 return calcs; 74 } 75 76 public ExpCompiler.ResultStyle getResultStyle() { 77 return mutable ? 78 ExpCompiler.ResultStyle.MUTABLE_LIST : 79 ExpCompiler.ResultStyle.LIST; 80 } 81 } 82 83 | Popular Tags |