public ParmValuePair(String parameter, ExecutableStatement statement, Class ingressType, ParserContext pCtx) { if (parameter != null && parameter.length() != 0) { this.setExpression = MVEL.compileSetExpression(parameter, ingressType != null ? getReturnType(ingressType, parameter, pCtx) : Object.class , pCtx); } this.statement = statement; }
public ExecutablePairs(String parameter, ExecutableStatement statement, Class ingressType, ParserContext pCtx) { if (parameter != null && parameter.length() != 0) { this.setExpression = MVEL.compileSetExpression(parameter, ingressType != null ? getReturnType(ingressType, parameter, pCtx) : Object.class, pCtx); } this.statement = statement; }
public ParmValuePair(String parameter, ExecutableStatement statement, Class ingressType, ParserContext pCtx) { if (parameter != null && parameter.length() != 0) { this.setExpression = MVEL.compileSetExpression(parameter, ingressType != null ? getReturnType(ingressType, parameter, pCtx) : Object.class , pCtx); } this.statement = statement; }
public ExecutablePairs(String parameter, ExecutableStatement statement, Class ingressType, ParserContext pCtx) { if (parameter != null && parameter.length() != 0) { this.setExpression = MVEL.compileSetExpression(parameter, ingressType != null ? getReturnType(ingressType, parameter, pCtx) : Object.class, pCtx); } this.statement = statement; }
public ParmValuePair(String parameter, ExecutableStatement statement, Class ingressType, ParserContext pCtx) { if (parameter != null && parameter.length() != 0) { this.setExpression = MVEL.compileSetExpression(parameter, ingressType != null ? getReturnType(ingressType, parameter, pCtx) : Object.class , pCtx); } this.statement = statement; }
public ExecutablePairs(String parameter, ExecutableStatement statement, Class ingressType, ParserContext pCtx) { if (parameter != null && parameter.length() != 0) { this.setExpression = MVEL.compileSetExpression(parameter, ingressType != null ? getReturnType(ingressType, parameter, pCtx) : Object.class , getCurrentThreadParserContext()); } this.statement = statement; }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { if (statement == null) { statement = (ExecutableStatement) subCompileExpression(expr, this.start, this.offset, pCtx); acc = (CompiledAccExpression) compileSetExpression(property.toCharArray(), statement.getKnownEgressType(), pCtx); } acc.setValue(ctx, thisValue, factory, ctx = statement.getValue(ctx, thisValue, factory)); return ctx; }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { if (statement == null) { statement = (ExecutableStatement) subCompileExpression(expr, this.start, this.offset, pCtx); acc = (CompiledAccExpression) compileSetExpression(property.toCharArray(), statement.getKnownEgressType(), pCtx); } acc.setValue(ctx, thisValue, factory, ctx = statement.getValue(ctx, thisValue, factory)); return ctx; }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { if (statement == null) { statement = (ExecutableStatement) subCompileExpression(stmt); acc = (CompiledAccExpression) compileSetExpression(property.toCharArray(), statement.getKnownEgressType(), getCurrentThreadParserContext()); } acc.setValue(ctx, thisValue, factory, ctx = statement.getValue(ctx, thisValue, factory)); return ctx; }
public void testBindListToArray() { Map<String, Object> vars = createTestMap(); ArrayList<String> list = new ArrayList<String>(); list.add("a"); list.add("b"); list.add("c"); OptimizerFactory.setDefaultOptimizer("reflective"); Serializable s = MVEL.compileSetExpression("foo.charArray"); MVEL.executeSetExpression(s, vars, list); assertEquals(((Foo) vars.get("foo")).getCharArray().length, 3); }
public void testSetExpressions1() { Map<String, Object> myMap = new HashMap<String, Object>(); final Serializable fooExpr = compileSetExpression("foo"); executeSetExpression(fooExpr, myMap, "blah"); assertEquals("blah", myMap.get("foo")); executeSetExpression(fooExpr, myMap, "baz"); assertEquals("baz", myMap.get("foo")); }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { if (accExpr == null) { accExpr = (CompiledAccExpression) compileSetExpression(indexTarget); } if (col) { return accExpr.setValue(ctx, thisValue, factory, statement.getValue(ctx, thisValue, factory)); } else if (statement != null) { return factory.createVariable(varName, statement.getValue(ctx, thisValue, factory)).getValue(); } else { factory.createVariable(varName, null); return null; } }
public void testSetExpressions2() { Foo foo = new Foo(); Collection col = new ArrayList(); final Serializable fooExpr = compileSetExpression("collectionTest"); executeSetExpression(fooExpr, foo, col); assertEquals(col, foo.getCollectionTest()); }
public void testBindingNullToPrimitiveTypes4() { Map<String, Object> vars = createTestMap(); ((Foo) vars.get("foo")).charTestFld = 'a'; OptimizerFactory.setDefaultOptimizer("reflective"); Serializable s = MVEL.compileSetExpression("foo.charTestFld"); MVEL.executeSetExpression(s, vars, null); assertEquals(((Foo) vars.get("foo")).charTestFld, 0); OptimizerFactory.setDefaultOptimizer("ASM"); s = MVEL.compileSetExpression("foo.charTestFld"); MVEL.executeSetExpression(s, vars, null); assertEquals(((Foo) vars.get("foo")).charTestFld, 0); MVEL.executeSetExpression(s, vars, null); assertEquals(((Foo) vars.get("foo")).charTestFld, 0); }
public void testListPropertyHandler2() { MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true; Serializable s = MVEL.compileSetExpression("list[0]"); Base b; MVEL.executeSetExpression(s, new Base(), "hey you"); MVEL.executeSetExpression(s, b = new Base(), "hey you"); assertEquals("set", b.list.get(0)); }
public void testSetterViaMapNotation() { TestClass tc = new TestClass(); tc.getExtra().put("test", "value"); ParserContext ctx = new ParserContext(); ctx.withInput("this", TestClass.class); ctx.setStrongTyping(true); String expression = "extra[\"test\"]"; Serializable compiled = MVEL.compileSetExpression(expression, tc.getClass(), ctx); MVEL.executeSetExpression(compiled, tc, "value3"); assertEquals("value3", tc.getExtra().get("test")); }
public void testBindingNullToPrimitiveTypes3() { Map<String, Object> vars = createTestMap(); ((Foo) vars.get("foo")).setCharTest('a'); OptimizerFactory.setDefaultOptimizer("reflective"); Serializable s = MVEL.compileSetExpression("foo.charTest"); MVEL.executeSetExpression(s, vars, null); assertEquals(((Foo) vars.get("foo")).getCharTest(), 0); OptimizerFactory.setDefaultOptimizer("ASM"); s = MVEL.compileSetExpression("foo.charTest"); MVEL.executeSetExpression(s, vars, null); assertEquals(((Foo) vars.get("foo")).getCharTest(), 0); MVEL.executeSetExpression(s, vars, null); assertEquals(((Foo) vars.get("foo")).getCharTest(), 0); }
public void testSetterViaDotNotation() { TestClass tc = new TestClass(); tc.getExtra().put("test", "value"); ParserContext ctx = new ParserContext(); ctx.setStrongTyping(true); String expression = "extra.test"; Serializable compiled = MVEL.compileSetExpression(expression, ctx); MVEL.executeSetExpression(compiled, tc, "value2"); assertEquals("value2", tc.getExtra().get("test")); }
public void testBindingNullToPrimitiveTypes2() { Map<String, Object> vars = createTestMap(); ((Foo) vars.get("foo")).setCountTest(10); OptimizerFactory.setDefaultOptimizer("reflective"); Serializable s = MVEL.compileSetExpression("foo.boolTest"); MVEL.executeSetExpression(s, vars, null); assertFalse(((Foo) vars.get("foo")).isBoolTest()); OptimizerFactory.setDefaultOptimizer("ASM"); s = MVEL.compileSetExpression("foo.boolTest"); MVEL.executeSetExpression(s, vars, null); assertFalse(((Foo) vars.get("foo")).isBoolTest()); MVEL.executeSetExpression(s, vars, null); assertFalse(((Foo) vars.get("foo")).isBoolTest()); }
public void testListPropertyHandler3() { MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true; OptimizerFactory.setDefaultOptimizer("ASM"); Serializable s = MVEL.compileSetExpression("list[0]"); Base b; MVEL.executeSetExpression(s, new Base(), "hey you"); MVEL.executeSetExpression(s, b = new Base(), "hey you"); assertEquals("set", b.list.get(0)); }