org.mvel2.MVEL.executeSetExpression()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中org.mvel2.MVEL.executeSetExpression()方法的一些代码示例,展示了MVEL.executeSetExpression()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MVEL.executeSetExpression()方法的具体详情如下:
包路径:org.mvel2.MVEL
类名称:MVEL
方法名:executeSetExpression

MVEL.executeSetExpression介绍

暂无

代码示例

代码示例来源:origin: org.mvel/mvel2

public void eval(Object ctx, VariableResolverFactory factory) {
  if (setExpression == null) {
   this.statement.getValue(ctx, factory);
  }
  else {
   MVEL.executeSetExpression(setExpression, ctx, factory, this.statement.getValue(ctx, factory));
  }
 }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

public void eval(Object ctx, VariableResolverFactory factory) {
  if (setExpression == null) {
   this.statement.getValue(ctx, factory);
  }
  else {
   MVEL.executeSetExpression(setExpression, ctx, factory, this.statement.getValue(ctx, factory));
  }
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mvel

public void eval(Object ctx, VariableResolverFactory factory) {
    if (setExpression == null) {
      this.statement.getValue(ctx, factory);
    }
    else {
      MVEL.executeSetExpression(setExpression, ctx, factory, this.statement.getValue(ctx, factory));
    }
  }
}

代码示例来源:origin: org.mvel/mvel2

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"));
}

代码示例来源:origin: org.mvel/mvel2

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));
}

代码示例来源:origin: org.mvel/mvel2

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));
}

代码示例来源:origin: org.mvel/mvel2

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);
}

代码示例来源:origin: org.mvel/mvel2

public Object processWith(Object ctx, Object thisValue, VariableResolverFactory factory) {
 for (WithNode.ParmValuePair pvp : withExpressions) {
  if (pvp.getSetExpression() != null) {
   executeSetExpression(pvp.getSetExpression(), ctx, factory, pvp.getStatement().getValue(ctx, thisValue, factory));
  }
  else {
   pvp.getStatement().getValue(ctx, thisValue, factory);
  }
 }
 return ctx;
}

代码示例来源:origin: org.mvel/mvel2

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);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

public Object processWith(Object ctx, Object thisValue, VariableResolverFactory factory) {
 for (WithNode.ParmValuePair pvp : withExpressions) {
  if (pvp.getSetExpression() != null) {
   executeSetExpression(pvp.getSetExpression(), ctx, factory, pvp.getStatement().getValue(ctx, thisValue, factory));
  }
  else {
   pvp.getStatement().getValue(ctx, thisValue, factory);
  }
 }
 return ctx;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mvel

public Object processWith(Object ctx, Object thisValue, VariableResolverFactory factory) {
  for (WithNode.ParmValuePair pvp : withExpressions) {
    if (pvp.getSetExpression() != null) {
      executeSetExpression(pvp.getSetExpression(), ctx, factory, pvp.getStatement().getValue(ctx, thisValue, factory));
    }
    else {
      pvp.getStatement().getValue(ctx, thisValue, factory);
    }
  }
  return ctx;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
 if (thisValue == null) throw new CompileException("with-block against null pointer (this)", expr, start);
 for (ParmValuePair pvp : withExpressions) {
  if (pvp.getSetExpression() != null) {
   executeSetExpression(pvp.getSetExpression(), thisValue, factory, pvp.getStatement().getValue(ctx, thisValue, factory));
  }
  else {
   pvp.getStatement().getValue(thisValue, thisValue, factory);
  }
 }
 return thisValue;
}

代码示例来源:origin: org.mvel/mvel2

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);
}

代码示例来源:origin: org.mvel/mvel2

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());
}

代码示例来源:origin: org.mvel/mvel2

public void testSetExpressions2() {
 Foo foo = new Foo();
 Collection col = new ArrayList();
 final Serializable fooExpr = compileSetExpression("collectionTest");
 executeSetExpression(fooExpr,
   foo,
   col);
 assertEquals(col,
   foo.getCollectionTest());
}

代码示例来源:origin: org.mvel/mvel2

public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
 if (thisValue == null) throw new CompileException("with-block against null pointer (this)", expr, start);
 for (ParmValuePair pvp : withExpressions) {
  if (pvp.getSetExpression() != null) {
   executeSetExpression(pvp.getSetExpression(), thisValue, factory, pvp.getStatement().getValue(ctx, thisValue, factory));
  }
  else {
   pvp.getStatement().getValue(thisValue, thisValue, factory);
  }
 }
 return thisValue;
}

代码示例来源:origin: org.mvel/mvel2

public void testBindingNullToPrimitiveTypes() {
 Map<String, Object> vars = createTestMap();
 ((Foo) vars.get("foo")).setCountTest(10);
 OptimizerFactory.setDefaultOptimizer("reflective");
 Serializable s = MVEL.compileSetExpression("foo.countTest");
 MVEL.executeSetExpression(s, vars, null);
 assertEquals(((Foo) vars.get("foo")).getCountTest(), 0);
 OptimizerFactory.setDefaultOptimizer("ASM");
 s = MVEL.compileSetExpression("foo.countTest");
 MVEL.executeSetExpression(s, vars, null);
 assertEquals(((Foo) vars.get("foo")).getCountTest(), 0);
 MVEL.executeSetExpression(s, vars, null);
 assertEquals(((Foo) vars.get("foo")).getCountTest(), 0);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mvel

public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
  if (thisValue == null) throw new CompileException("with-block against null pointer (this)");
  for (ParmValuePair pvp : withExpressions) {
    if (pvp.getSetExpression() != null) {
      executeSetExpression(pvp.getSetExpression(), thisValue, factory, pvp.getStatement().getValue(ctx, thisValue, factory));
    }
    else {
      pvp.getStatement().getValue(thisValue, thisValue, factory);
    }
  }
  return thisValue;
}

代码示例来源:origin: org.mvel/mvel2

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"));
}

代码示例来源:origin: org.mvel/mvel2

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"));
}

相关文章