当前位置: 首页>>代码示例>>Java>>正文


Java ParserContext.addInput方法代码示例

本文整理汇总了Java中org.mvel2.ParserContext.addInput方法的典型用法代码示例。如果您正苦于以下问题:Java ParserContext.addInput方法的具体用法?Java ParserContext.addInput怎么用?Java ParserContext.addInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mvel2.ParserContext的用法示例。


在下文中一共展示了ParserContext.addInput方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testQualifiedForLoop

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public void testQualifiedForLoop() {
    ParserContext pCtx = new ParserContext();
    pCtx.setStrongTyping(true);
    pCtx.addImport(Foo.class);
    pCtx.addInput("l", ArrayList.class, new Class[] { Foo.class });

    List l = new ArrayList();
    l.add(new Foo());
    l.add(new Foo());
    l.add(new Foo());

    Map vars = new HashMap();
    vars.put("l", l);

    Serializable s = MVEL.compileExpression("String s = ''; for (Foo f : l) { s += f.name }; s", pCtx);

    String r  = (String) MVEL.executeExpression(s, vars);

    assertEquals("dogdogdog", r);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:21,代码来源:ControlFlowTests.java

示例2: ForEachNode

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public ForEachNode(char[] condition, char[] block, int fields, ParserContext pCtx) {
    handleCond(this.name = condition, this.fields = fields, pCtx);
    this.block = block;

    if ((fields & COMPILE_IMMEDIATE) != 0) {
        if (pCtx.isStrictTypeEnforcement() && itemType != null) {
            pCtx = pCtx.createSubcontext();
            pCtx.addInput(item, itemType);
        }

        this.compiledBlock = (ExecutableStatement) subCompileExpression(block, pCtx);
    }
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:14,代码来源:ForEachNode.java

示例3: testInlineWith5

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public void testInlineWith5() {
    OptimizerFactory.setDefaultOptimizer("ASM");

    ParserContext pCtx = new ParserContext();
    pCtx.setStrongTyping(true);

    pCtx.addInput("foo", Foo.class);

    CompiledExpression expr = new ExpressionCompiler("foo.{name='poopy', aValue='bar'}").compile(pCtx);
    Foo f = (Foo) executeExpression(expr, createTestMap());
    assertEquals("poopy", f.getName());
    assertEquals("bar", f.aValue);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:14,代码来源:WithTests.java

示例4: testStrongTypingModeComparison

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public void testStrongTypingModeComparison() {
    ParserContext parserContext = new ParserContext();
    parserContext.setStrongTyping(true);
    parserContext.addInput("a", Long.class);

    CompiledExpression compiledExpression = new ExpressionCompiler("a==0").compile(parserContext);
    HashMap<String, Object> variables = new HashMap<String, Object>();
    variables.put("a", 0l);
    MVEL.executeExpression(compiledExpression, variables);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:11,代码来源:ArithmeticTests.java

示例5: testInferLastTypeParametersFromProperty

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public final void testInferLastTypeParametersFromProperty() {
    ParserContext context = new ParserContext();
    context.setStrongTyping(true);

    context.addInput("a", A.class);

    final CompiledExpression compiledExpression = new ExpressionCompiler("a.strings")
            .compile(context);

    final Object val = MVEL.executeExpression(compiledExpression, new AWrapper());

    assertTrue("Expression did not evaluate correctly: " + val, STRINGS.equals(val));
    assertTrue("No type parameters detected", null != context.getLastTypeParameters());
    assertTrue("Wrong parametric type inferred", String.class.equals(context.getLastTypeParameters()[0]));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:16,代码来源:GenericsTypeInferenceTest.java

示例6: testInferLastTypeParametersFromMethod

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public final void testInferLastTypeParametersFromMethod() {
    ParserContext context = new ParserContext();
    context.setStrongTyping(true);

    context.addInput("a", A.class);

    final CompiledExpression compiledExpression = new ExpressionCompiler("a.values()")
            .compile(context);

    final Object val = MVEL.executeExpression(compiledExpression, new AWrapper());

    assertTrue("Expression did not evaluate correctly: " + val, STRINGS.equals(val));
    assertTrue("No type parameters detected", null != context.getLastTypeParameters());
    assertTrue("Wrong parametric type inferred", String.class.equals(context.getLastTypeParameters()[0]));
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:16,代码来源:GenericsTypeInferenceTest.java

示例7: testInferLastTypeParametersFromPropertyMethod

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public final void testInferLastTypeParametersFromPropertyMethod() {
    ParserContext context = new ParserContext();
    context.setStrongTyping(true);

    context.addInput("a", A.class);

    final CompiledExpression compiledExpression = new ExpressionCompiler("a.getFooMap()[\"key\"].someMethod()")
            .compile(context);

    final Object val = MVEL.executeExpression(compiledExpression, new AWrapper());

    assertEquals("Expression did not evaluate correctly: ", "bar", val);
    assertNotNull("No type parameters detected", context.getLastTypeParameters());
    assertEquals("Wrong parametric type inferred", String.class, context.getLastTypeParameters()[0]);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:16,代码来源:GenericsTypeInferenceTest.java

示例8: testDeepAssignment2

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public void testDeepAssignment2() {
    Map map = createTestMap();

    ExpressionCompiler compiler = new ExpressionCompiler("foo.bar.age = 21");
    ParserContext ctx = new ParserContext();

    ctx.addInput("foo", Foo.class);
    ctx.setStrongTyping(true);

    CompiledExpression ce = compiler.compile(ctx);

    executeExpression(ce, map);

    assertEquals(((Foo) map.get("foo")).getBar().getAge(), 21);
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:16,代码来源:MutationsTests.java

示例9: testTypeByMethod

import org.mvel2.ParserContext; //导入方法依赖的package包/类
public final void testTypeByMethod() {
    ParserContext context = new ParserContext();
    context.setStrongTyping(true);

    context.addInput("a", A.class);

     CompiledExpression compiledExpression = new ExpressionCompiler("!a.show").compile(context);

    assertEquals(Boolean.class, compiledExpression.getKnownEgressType());
}
 
开发者ID:codehaus,项目名称:mvel,代码行数:11,代码来源:GenericsTypeInferenceTest.java


注:本文中的org.mvel2.ParserContext.addInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。