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

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

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

MVEL.analysisCompile介绍

[英]Performs an analysis compileShared, which will populate the ParserContext with type, input and variable information, but will not produce a payload.
[中]执行compileShared分析,该分析将使用类型、输入和变量信息填充ParserContext,但不会生成有效负载。

代码示例

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

public static void analysisCompile(String expression, ParserContext ctx) {
 analysisCompile(expression.toCharArray(), ctx);
}

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

public static void analysisCompile(String expression, ParserContext ctx) {
 analysisCompile(expression.toCharArray(), ctx);
}

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

public static void analysisCompile(String expression, ParserContext ctx) {
  analysisCompile(expression.toCharArray(), ctx);
}

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

public static SharedVariableSpaceModel compileShared(String expr, ParserContext pCtx, Object[] vars) {
 String[] varNames = pCtx.getIndexedVarNames();
 ParserContext analysisContext = ParserContext.create();
 analysisContext.setIndexAllocation(true);
 MVEL.analysisCompile(expr, analysisContext);
 Set<String> localNames = analysisContext.getVariables().keySet();
 pCtx.addIndexedLocals(localNames);
 String[] locals = localNames.toArray(new String[localNames.size()]);
 String[] allVars = new String[varNames.length + locals.length];
 System.arraycopy(varNames, 0, allVars, 0, varNames.length);
 System.arraycopy(locals, 0, allVars, varNames.length, locals.length);
 return new SharedVariableSpaceModel(allVars, vars);
}

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

public static SharedVariableSpaceModel compileShared(String expr, ParserContext pCtx, Object[] vars) {
 String[] varNames = pCtx.getIndexedVarNames();
 ParserContext analysisContext = ParserContext.create();
 analysisContext.setIndexAllocation(true);
 MVEL.analysisCompile(expr, analysisContext);
 Set<String> localNames = analysisContext.getVariables().keySet();
 pCtx.addIndexedLocals(localNames);
 String[] locals = localNames.toArray(new String[localNames.size()]);
 String[] allVars = new String[varNames.length + locals.length];
 System.arraycopy(varNames, 0, allVars, 0, varNames.length);
 System.arraycopy(locals, 0, allVars, varNames.length, locals.length);
 return new SharedVariableSpaceModel(allVars, vars);
}

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

public static SimpleVariableSpaceModel compile(String expr, ParserContext pCtx) {
  String[] varNames = pCtx.getIndexedVarNames();

  ParserContext analysisContext = ParserContext.create();
  analysisContext.setIndexAllocation(true);

  MVEL.analysisCompile(expr, analysisContext);

  Set<String> localNames = analysisContext.getVariables().keySet();

  pCtx.addIndexedLocals(localNames);

  String[] locals = localNames.toArray(new String[localNames.size()]);
  String[] allVars = new String[varNames.length + locals.length];

  System.arraycopy(varNames, 0, allVars, 0, varNames.length);
  System.arraycopy(locals, 0, allVars, varNames.length, locals.length);

  return new SimpleVariableSpaceModel(allVars);
 }
}

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

public static SimpleVariableSpaceModel compile(String expr, ParserContext pCtx) {
  String[] varNames = pCtx.getIndexedVarNames();

  ParserContext analysisContext = ParserContext.create();
  analysisContext.setIndexAllocation(true);

  MVEL.analysisCompile(expr, analysisContext);

  Set<String> localNames = analysisContext.getVariables().keySet();

  pCtx.addIndexedLocals(localNames);

  String[] locals = localNames.toArray(new String[localNames.size()]);
  String[] allVars = new String[varNames.length + locals.length];

  System.arraycopy(varNames, 0, allVars, 0, varNames.length);
  System.arraycopy(locals, 0, allVars, varNames.length, locals.length);

  return new SimpleVariableSpaceModel(allVars);
 }
}

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

MVEL.analysisCompile( expr, pctx );
} catch (Exception e) {

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

public void testStaticFieldAccessForInputs() {
  MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;
  ParserContext pCtx = ParserContext.create();
  MVEL.analysisCompile("java.math.BigDecimal.TEN", pCtx);

  assertFalse(pCtx.getInputs().containsKey("java"));

  assertEquals(0,
      pCtx.getInputs().size());

//        MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;        
//        
//        pCtx = ParserContext.create();
//        MVEL.analysisCompile("java.math.BigDecimal.TEN", pCtx);
//
//        assertFalse(pCtx.getInputs().containsKey("java"));
//
//        assertEquals(0,
//                pCtx.getInputs().size());        
 }

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

public void testUnwantedImport() {
 ParserConfiguration conf = new ParserConfiguration();
 conf.addPackageImport("java.util");
 conf.addPackageImport("org.mvel2.tests.core.res");
 ParserContext pctx = new ParserContext( conf );
 MVEL.analysisCompile( "ScenarioType.Set.ADD", pctx );
 assertNull(conf.getImports().get("Set"));
}

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

public void testStaticFieldAccessForInputsWithStrictStrong() {
 ParserContext pCtx = ParserContext.create();
 pCtx.setStrictTypeEnforcement(true);
 pCtx.setStrongTyping(true);
 MVEL.analysisCompile("java.math.BigDecimal.TEN", pCtx);
 assertFalse(pCtx.getInputs().containsKey("java"));
 assertEquals(0,
     pCtx.getInputs().size());
 MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;
 pCtx = ParserContext.create();
 pCtx.setStrictTypeEnforcement(true);
 pCtx.setStrongTyping(true);
 MVEL.analysisCompile("java.math.BigDecimal.TEN", pCtx);
 assertFalse(pCtx.getInputs().containsKey("java"));
 assertEquals(0,
     pCtx.getInputs().size());
}

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

MVEL.analysisCompile(new String(expr, start, cursor - start), pCtx);

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

MVEL.analysisCompile(new String(expr, start, cursor - start), pCtx);

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

public void testGenericInference2() {
 ParserContext ctx;
 MVEL.analysisCompile("$result = person.maptributes['fooey'].name",
     ctx = ParserContext.create().stronglyTyped().withInput("person", Person.class));
 assertEquals(String.class, ctx.getVarOrInputTypeOrNull("$result"));
}

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

public void testVarInputs5() {
 ParserContext pCtx = ParserContext.create().withInput("list", List.class);
 MVEL.analysisCompile("String nodeName = list[0];\nSystem.out.println(nodeName);nodeName = list[1];\nSystem.out.println(nodeName);", pCtx);
 assertEquals(1,
     pCtx.getInputs().size());
 assertTrue(pCtx.getInputs().containsKey("list"));
 assertEquals(1,
     pCtx.getVariables().size());
 assertTrue(pCtx.getVariables().containsKey("nodeName"));
 assertEquals(List.class,
     pCtx.getVarOrInputType("list"));
 assertEquals(String.class,
     pCtx.getVarOrInputType("nodeName"));
}

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

public void testVarInputs() {
 ParserContext pCtx = ParserContext.create();
 MVEL.analysisCompile("test != foo && bo.addSomething(trouble) " +
     "&& 1 + 2 / 3 == 1; String bleh = foo; twa = bleh;", pCtx);
 assertEquals(4,
     pCtx.getInputs().size());
 assertTrue(pCtx.getInputs().containsKey("test"));
 assertTrue(pCtx.getInputs().containsKey("foo"));
 assertTrue(pCtx.getInputs().containsKey("bo"));
 assertTrue(pCtx.getInputs().containsKey("trouble"));
 assertEquals(2,
     pCtx.getVariables().size());
 assertTrue(pCtx.getVariables().containsKey("bleh"));
 assertTrue(pCtx.getVariables().containsKey("twa"));
 assertEquals(String.class,
     pCtx.getVarOrInputType("bleh"));
}

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

public void testGenericInference() {
 String expression = "$result = person.footributes[0].name";
 ParserContext ctx;
 MVEL.analysisCompile(expression,
     ctx = ParserContext.create().stronglyTyped().withInput("person", Person.class));
 assertEquals(String.class, ctx.getVarOrInputTypeOrNull("$result"));
 Serializable s =
     MVEL.compileExpression(expression, ParserContext.create().stronglyTyped().withInput("person", Person.class));
 Map<String, Object> vars = new HashMap<String, Object>();
 Person p = new Person();
 p.setFootributes(new ArrayList<Foo>());
 p.getFootributes().add(new Foo());
 vars.put("person", p);
 assertEquals("dog", executeExpression(s, vars));
}

相关文章