use of org.mule.mvel2.CompileException in project mvel by mikebrock.
the class Soundslike method getReducedValue.
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
try {
String i = String.valueOf(soundslike.getReducedValue(ctx, thisValue, factory));
if (i == null)
throw new ClassCastException();
String x = (String) stmt.getReducedValue(ctx, thisValue, factory);
if (x == null)
throw new CompileException("not a string: " + stmt.getName(), stmt.getExpr(), stmt.getStart());
return soundex(i).equals(soundex(x));
} catch (ClassCastException e) {
throw new CompileException("not a string: " + soundslike.getName(), soundslike.getExpr(), soundslike.getStart());
}
}
use of org.mule.mvel2.CompileException in project mvel by mikebrock.
the class TemplateCompiler method captureOrbInternal.
private int captureOrbInternal() {
try {
ParserContext pCtx = new ParserContext();
cursor = balancedCaptureWithLineAccounting(template, start = cursor, length, '{', pCtx);
line += pCtx.getLineCount();
int ret = start + 1;
start = cursor + 1;
return ret;
} catch (CompileException e) {
e.setLineNumber(line);
e.setColumn((cursor - colStart) + 1);
throw e;
}
}
use of org.mule.mvel2.CompileException in project mvel by mvel.
the class CoreConfidenceTests method testUntypedClone.
public void testUntypedClone() {
String expression = "obj.clone();";
ParserContext context = new ParserContext();
context.setStrongTyping(false);
context.setStrictTypeEnforcement(false);
MVEL.analyze(expression, context);
try {
context.addInput("obj", Object.class);
context.setStrongTyping(true);
context.setStrictTypeEnforcement(true);
MVEL.analyze(expression, context);
fail("Must fail with strong typing");
} catch (CompileException e) {
}
}
use of org.mule.mvel2.CompileException in project mvel by mvel.
the class CoreConfidenceTests method testStrTriangleEqualsEquals.
public void testStrTriangleEqualsEquals() {
MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;
try {
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.addInput("this", Triangle.class);
pctx.setStrongTyping(true);
String str = "this.strLabel == this";
try {
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
fail("should have failed");
} catch (CompileException e) {
System.out.println();
return;
}
} finally {
MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = false;
}
}
use of org.mule.mvel2.CompileException in project mvel by mvel.
the class CoreConfidenceTests method testNullCollection.
public void testNullCollection() throws CompileException {
boolean allowCompilerOverride = MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING;
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
String[] names = { "missing" };
String[] values = { null };
try {
MVEL.executeExpression((CompiledExpression) MVEL.compileExpression("1; missing[3]"), new IndexedVariableResolverFactory(names, values));
fail("Should throw a NullPointerExcption");
} catch (Exception e) {
} finally {
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = allowCompilerOverride;
}
}
Aggregations