Exemple #1
0
  public Exp validate(Exp exp, boolean scalar) {
    Exp resolved;
    try {
      resolved = (Exp) resolvedNodes.get(exp);
    } catch (ClassCastException e) {
      // A classcast exception will occur if there is a String
      // placeholder in the map. This is an internal error -- should
      // not occur for any query, valid or invalid.
      throw Util.newInternal(
          e, "Infinite recursion encountered while validating '" + Util.unparse(exp) + "'");
    }
    if (resolved == null) {
      try {
        stack.push((QueryPart) exp);
        // To prevent recursion, put in a placeholder while we're
        // resolving.
        resolvedNodes.put((QueryPart) exp, placeHolder);
        resolved = exp.accept(this);
        Util.assertTrue(resolved != null);
        resolvedNodes.put((QueryPart) exp, (QueryPart) resolved);
      } finally {
        stack.pop();
      }
    }

    if (scalar) {
      final Type type = resolved.getType();
      if (!TypeUtil.canEvaluate(type)) {
        String exprString = Util.unparse(resolved);
        throw MondrianResource.instance().MdxMemberExpIsSet.ex(exprString);
      }
    }

    return resolved;
  }
Exemple #2
0
 public boolean canConvert(
     int ordinal, Exp fromExp, int to, List<Resolver.Conversion> conversions) {
   return TypeUtil.canConvert(ordinal, fromExp.getType(), to, conversions);
 }