1 10 package mondrian.mdx; 11 12 import mondrian.olap.*; 13 import mondrian.olap.fun.*; 14 import mondrian.olap.type.Type; 15 import mondrian.calc.Calc; 16 import mondrian.calc.ExpCompiler; 17 18 import java.io.PrintWriter ; 19 20 29 public class UnresolvedFunCall extends ExpBase implements FunCall { 30 private final String name; 31 private final Syntax syntax; 32 private final Exp[] args; 33 34 37 public UnresolvedFunCall(String name, Exp[] args) { 38 this(name, Syntax.Function, args); 39 } 40 41 44 public UnresolvedFunCall(String name, Syntax syntax, Exp[] args) { 45 assert name != null; 46 assert syntax != null; 47 assert args != null; 48 this.name = name; 49 this.syntax = syntax; 50 this.args = args; 51 if (syntax == Syntax.Braces) { 52 Util.assertTrue(name.equals("{}")); 53 } else if (syntax == Syntax.Parentheses) { 54 Util.assertTrue(name.equals("()")); 55 } else if (syntax == Syntax.Internal) { 56 Util.assertTrue(name.startsWith("$")); 57 } else { 58 Util.assertTrue(!name.startsWith("$") && 59 !name.equals("{}") && 60 !name.equals("()")); 61 } 62 } 63 64 public UnresolvedFunCall clone() { 65 return new UnresolvedFunCall(name, syntax, ExpBase.cloneArray(args)); 66 } 67 68 public int getCategory() { 69 throw new UnsupportedOperationException (); 70 } 71 72 public Type getType() { 73 throw new UnsupportedOperationException (); 74 } 75 76 public void unparse(PrintWriter pw) { 77 syntax.unparse(name, args, pw); 78 } 79 80 public Object accept(MdxVisitor visitor) { 81 final Object o = visitor.visit(this); 82 for (Exp arg : args) { 84 arg.accept(visitor); 85 } 86 return o; 87 } 88 89 public Exp accept(Validator validator) { 90 Exp[] newArgs = new Exp[args.length]; 91 FunDef funDef = 92 FunUtil.resolveFunArgs(validator, args, newArgs, name, syntax); 93 return funDef.createCall(validator, newArgs); 94 } 95 96 public Calc accept(ExpCompiler compiler) { 97 throw new UnsupportedOperationException (); 98 } 99 100 105 public String getFunName() { 106 return name; 107 } 108 109 114 public Syntax getSyntax() { 115 return syntax; 116 } 117 118 126 public Exp getArg(int index) { 127 return args[index]; 128 } 129 130 137 public Exp[] getArgs() { 138 return args; 139 } 140 141 147 public final int getArgCount() { 148 return args.length; 149 } 150 151 public Object [] getChildren() { 152 return args; 153 } 154 } 155 156 | Popular Tags |