1 11 12 package mondrian.mdx; 13 import mondrian.calc.Calc; 14 import mondrian.calc.ExpCompiler; 15 import mondrian.olap.fun.*; 16 import mondrian.olap.type.Type; 17 import mondrian.olap.*; 18 19 import java.io.PrintWriter ; 20 21 30 public class ResolvedFunCall extends ExpBase implements FunCall { 31 32 36 private final Exp[] args; 37 38 41 private final Type returnType; 42 43 46 private final FunDef funDef; 47 48 55 public ResolvedFunCall(FunDef funDef, Exp[] args, Type returnType) { 56 assert funDef != null; 57 assert args != null; 58 assert returnType != null; 59 this.funDef = funDef; 60 this.args = args; 61 this.returnType = returnType; 62 } 63 64 public String toString() { 65 return Util.unparse(this); 66 } 67 68 public ResolvedFunCall clone() { 69 return new ResolvedFunCall(funDef, ExpBase.cloneArray(args), returnType); 70 } 71 72 80 public Exp getArg(int index) { 81 return args[index]; 82 } 83 84 91 public Exp[] getArgs() { 92 return args; 93 } 94 95 101 public final int getArgCount() { 102 return args.length; 103 } 104 105 public String getFunName() { 106 return funDef.getName(); 107 } 108 109 public Syntax getSyntax() { 110 return funDef.getSyntax(); 111 } 112 113 public Object [] getChildren() { 114 return args; 115 } 116 117 122 public FunDef getFunDef() { 123 return funDef; 124 } 125 126 public final int getCategory() { 127 return funDef.getReturnCategory(); 128 } 129 130 public final Type getType() { 131 return returnType; 132 } 133 134 public Exp accept(Validator validator) { 135 Exp[] newArgs = new Exp[args.length]; 139 FunUtil.resolveFunArgs( 140 validator, args, newArgs, getFunName(), getSyntax()); 141 142 return this; 143 } 144 145 public void unparse(PrintWriter pw) { 146 funDef.unparse(args, pw); 147 } 148 149 public Calc accept(ExpCompiler compiler) { 150 return funDef.compileCall(this, compiler); 151 } 152 153 public Object accept(MdxVisitor visitor) { 154 final Object o = visitor.visit(this); 155 for (Exp arg : args) { 157 arg.accept(visitor); 158 } 159 return o; 160 } 161 } 162 163 | Popular Tags |