public static int[] getTypes(Exp[] exps) { int[] types = new int[exps.length]; for (int i = 0; i < exps.length; i++) { types[i] = exps[i].getCategory(); } return types; }
public int getCategory() { return e.getCategory(); }
public static String getParameterName(Exp[] args) { if (args[0] instanceof Literal && args[0].getCategory() == Category.String) { return (String) ((Literal) args[0]).getValue(); } else { throw Util.newInternal("Parameter name must be a string constant"); } }
public FunDef resolve( Exp[] args, Validator validator, List<Conversion> conversions) { if (args.length != 1) { return null; } final Exp exp = args[0]; final int category = exp.getCategory(); final Type type = exp.getType(); return new CacheFunDef( NAME, SIGNATURE, DESCRIPTION, SYNTAX, category, type); }
/** * @return true if exp is a matching FunCall */ protected boolean match(Exp exp) { if ((exp.getCategory() & category) == 0) { return false; } if (!(exp instanceof FunCall)) { return false; } FunCall fc = (FunCall) exp; if (!mdx.equalsIgnoreCase(fc.getFunName())) { return false; } Exp[] args = fc.getArgs(); if (args.length != argCount) { return false; } return true; }
public String compile(Exp exp) { if (!(exp instanceof Literal)) { return null; } if ((exp.getCategory() & Category.Numeric) == 0) { return null; } Literal literal = (Literal) exp; String expr = String.valueOf(literal.getValue()); if (!DECIMAL.matcher(expr).matches()) { throw new MondrianEvaluationException( "Expected to get decimal, but got " + expr); } if (dialect.getDatabaseProduct().getFamily() == Dialect.DatabaseProduct.DB2) { expr = "FLOAT(" + expr + ")"; } return expr; }
|| arg.getCategory() != Category.Symbol)
return new ParenthesesFunDef(args[0].getCategory()); } else { final int[] argTypes = new int[args.length];
private void buildKeySpecList( List<SortKeySpec> keySpecList, ResolvedFunCall call, ExpCompiler compiler) { final int argCount = call.getArgs().length; int j = 1; // args[0] is the input set Calc key; Flag dir; Exp arg; while (j < argCount) { arg = call.getArg(j); key = compiler.compileScalar(arg, true); j++; if ((j >= argCount) || (call.getArg(j).getCategory() != Category.Symbol)) { dir = Flag.ASC; } else { dir = getLiteralArg(call, j, Flag.ASC, Flag.class); j++; } keySpecList.add(new SortKeySpec(key, dir)); } }
return null; int valueType = args[0].getCategory(); int returnType = args[2].getCategory(); int j = 0; int clauseCount = (args.length - 1) / 2;
|| arg.getCategory() != Category.Symbol)
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) { final int category = call.getArg(0).getCategory(); switch (category) { case Category.Tuple: final TupleCalc tupleCalc0 = compiler.compileTuple(call.getArg(0)); final TupleCalc tupleCalc1 = compiler.compileTuple(call.getArg(1)); return new AbstractBooleanCalc( call, new Calc[] {tupleCalc0, tupleCalc1}) { public boolean evaluateBoolean(Evaluator evaluator) { Member[] o0 = tupleCalc0.evaluateTuple(evaluator); Member[] o1 = tupleCalc1.evaluateTuple(evaluator); return equalTuple(o0, o1); } }; default: assert category == call.getArg(1).getCategory(); final Calc calc0 = compiler.compile(call.getArg(0)); final Calc calc1 = compiler.compile(call.getArg(1)); return new AbstractBooleanCalc(call, new Calc[] {calc0, calc1}) { public boolean evaluateBoolean(Evaluator evaluator) { Object o0 = calc0.evaluate(evaluator); Object o1 = calc1.evaluate(evaluator); return o0.equals(o1); } }; } } }
int clauseCount = args.length / 2; int mismatchingArgs = 0; int returnType = args[1].getCategory(); for (int i = 0; i < clauseCount; i++) { if (!validator.canConvert(
/** * Creates a call to the set operator with a given collection of * expressions. * * <p>There must be at least one expression. Each expression may be a set of * members/tuples, or may be a member/tuple, but method assumes that * expressions have compatible types. * * @param args Expressions * @return Call to set operator */ public static ResolvedFunCall wrapAsSet(Exp... args) { assert args.length > 0; final int[] categories = new int[args.length]; Type type = null; for (int i = 0; i < args.length; i++) { final Exp arg = args[i]; categories[i] = arg.getCategory(); final Type argType = arg.getType(); if (argType instanceof SetType) { type = ((SetType) argType).getElementType(); } else { type = argType; } } return new ResolvedFunCall( new SetFunDef(Resolver, categories), args, new SetType(type)); }
int category; Type type = typeArg.getType(); switch (typeArg.getCategory()) { case Category.Dimension: case Category.Hierarchy: + "' is inconsistent with its type, " + typeName); if (exp.getCategory() == Category.Set && category == Category.Member) if (args.length > 3) { if (args[3] instanceof Literal && args[3].getCategory() == Category.String)
final LevelCalc levelCalc = call.getArgCount() > 2 && call.getArg(2).getCategory() != Category.Empty ? compiler.compileLevel(call.getArg(2)) : null;