1 13 package mondrian.olap.fun; 14 import mondrian.olap.*; 15 import mondrian.olap.type.Type; 16 import mondrian.calc.Calc; 17 import mondrian.calc.ExpCompiler; 18 import mondrian.mdx.ResolvedFunCall; 19 20 import java.io.PrintWriter ; 21 22 30 class ParenthesesFunDef extends FunDefBase { 31 private final int argType; 32 ParenthesesFunDef(int argType) { 33 super( 34 "()", 35 "(<Expression>)", 36 "Parenthesis enclose an expression and indicate precedence.", 37 Syntax.Parentheses, 38 argType, 39 new int[] {argType}); 40 this.argType = argType; 41 } 42 public void unparse(Exp[] args, PrintWriter pw) { 43 if (args.length != 1) { 44 ExpBase.unparseList(pw, args, "(", ",", ")"); 45 } else { 46 args[0].unparse(pw); 50 } 51 } 52 53 public Type getResultType(Validator validator, Exp[] args) { 54 Util.assertTrue(args.length == 1); 55 return args[0].getType(); 56 } 57 58 public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) { 59 return compiler.compile(call.getArg(0)); 60 } 61 } 62 63 | Popular Tags |