Package org.mvel2

Examples of org.mvel2.CompileException


        case FUNCTION:
          return ((Function) receiver).call(ctx, thisCtx, new InvokationContextFactory(factory, instance.instanceStates), parms);
        case PROPERTY:
          return receiver;
        case DEFERRED:
          throw new CompileException("unresolved prototype receiver", expr, start);
      }
      return null;
    }
View Full Code Here


      catch (UnresolveablePropertyException e) {
        vr = null;
      }

      if (vr != null && vr.getType() != null) {
        throw new CompileException("variable already defined within scope: " + vr.getType() + " " + name, expr, start);
      }
      else {
        addResolver(name, vr = new ProtoResolver(variables, name, type)).setValue(value);
        return vr;
      }
View Full Code Here

    @Override
    public VariableResolver createIndexedVariable(int index, String name, Object value, Class<?> type) {
      VariableResolver vr = this.variableResolvers != null ? this.variableResolvers.getByIndex(index) : null;
      if (vr != null && vr.getType() != null) {
        throw new CompileException("variable already defined within scope: " + vr.getType() + " " + name, expr, start);
      }
      else {
        return createIndexedVariable(variableIndexOf(name), name, value);
      }
    }
View Full Code Here

    }

    public void setValue(Object value) {
      if (knownType != null && value != null && value.getClass() != knownType) {
        if (!canConvert(knownType, value.getClass())) {
          throw new CompileException("cannot assign " + value.getClass().getName() + " to type: "
              + knownType.getName(), expr, start);
        }
        try {
          value = convert(value, knownType);
        }
        catch (Exception e) {
          throw new CompileException("cannot convert value of " + value.getClass().getName()
              + " to: " + knownType.getName(), expr, start);
        }
      }

      ((Receiver) variableMap.get(name)).receiver = value;
View Full Code Here

          if ((st = cursor) < end && property[cursor] == ',') {
            st = cursor + 1;
          }
          else if (cursor < end) {
            if (ParseTools.opLookup(property[cursor]) == -1) {
              throw new CompileException("unterminated collection element", property, cursor);
            }
          }

          continue;
View Full Code Here

      subCompileExpression(property, start, offset, pCtx);
    }
    else {
      Class r = ((ExecutableStatement) subCompileExpression(property, start, offset, pCtx)).getKnownEgressType();
      if (r != null && !isAssignableFrom(colType, r) && (isStrongType() || !DataConversion.canConvert(r, colType))) {
        throw new CompileException("expected type: " + colType.getName() + "; but found: " + r.getName(), property, cursor);
      }
    }
  }
View Full Code Here

          items.add(ParseTools.createStringTrimmed(contents, start, i - start));
          start = i + 1;
          break;
        case ',':
          if (expr.size() != (items.size() - 1)) {
            throw new CompileException("unexpected character ',' in foreach tag", contents, cStart + i);
          }
          expr.add(ParseTools.createStringTrimmed(contents, start, i - start));
          start = i + 1;
          break;
      }
    }

    if (start < cEnd) {
      if (expr.size() != (items.size() - 1)) {
        throw new CompileException("expected character ':' in foreach tag", contents, cEnd);
      }
      expr.add(ParseTools.createStringTrimmed(contents, start, cEnd - start));
    }

    item = new String[items.size()];
View Full Code Here

        }
        cursor++;
      }
    }
    catch (RuntimeException e) {
      CompileException ce = new CompileException(e.getMessage(), template, cursor, e);
      ce.setExpr(template);

      if (e instanceof CompileException) {
        CompileException ce2 = (CompileException) e;
        if (ce2.getCursor() != -1) {
          ce.setCursor(ce2.getCursor());
          if (ce2.getColumn() == -1) ce.setColumn(ce.getCursor() - colStart);
          else ce.setColumn(ce2.getColumn());
        }
      }
      ce.setLineNumber(line);

      throw ce;
    }

    if (!stack.isEmpty()) {
      CompileException ce = new CompileException("unclosed @" + ((Node) stack.peek()).getName() + "{} block. expected @end{}", template, cursor);
      ce.setColumn(cursor - colStart);
      ce.setLineNumber(line);
      throw ce;
    }

    if (start < template.length) {
      n = n.next = new TextNode(start, template.length);
View Full Code Here

          if ((st = cursor) < end && property[cursor] == ',') {
            st = cursor + 1;
          }
          else if (cursor < end) {
            if (ParseTools.opLookup(property[cursor]) == -1) {
              throw new CompileException("unterminated collection element", property, cursor);
            }
          }

          continue;
View Full Code Here

      subCompileExpression(property, start, offset, pCtx);
    }
    else {
      Class r = ((ExecutableStatement) subCompileExpression(property, start, offset, pCtx)).getKnownEgressType();
      if (!colType.isAssignableFrom(r) && (isStrongType() || !DataConversion.canConvert(r, colType))) {
        throw new CompileException("expected type: " + colType.getName() + "; but found: " + r.getName(), property, cursor);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.mvel2.CompileException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.