Package org.mvel2.integration.impl

Examples of org.mvel2.integration.impl.MapVariableResolverFactory


        (((Foo) ((Map) executeExpression(s)).get("foo")).getBar().getName()));
  }

  public void testSataticClassImportViaFactoryAndWithModification() {
    OptimizerFactory.setDefaultOptimizer("ASM");
    MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
    ClassImportResolverFactory classes = new ClassImportResolverFactory(null, null, false);
    classes.addClass(Person.class);

    ResolverTools.appendFactory(mvf,
        classes);
View Full Code Here


  }

  public void testMVEL225() {
    Serializable compileExpression = MVEL.compileExpression(
        "def f() { int a=1;a++;return a; }; f();");
    MapVariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>());
    assertEquals(2, MVEL.executeExpression(compileExpression, factory));
  }
View Full Code Here

            "&& x__0 == 'boob';"));
  }


  public void testFunctionReuse() {
    VariableResolverFactory functionFactory = new MapVariableResolverFactory();
    MVEL.eval("def foo() { \"foo\"; }; def bar() { \"bar\" };", functionFactory);

    VariableResolverFactory myVarFactory = new MapVariableResolverFactory();
    myVarFactory.setNextFactory(functionFactory);

    Serializable s = MVEL.compileExpression("foo() + bar();");

    assertEquals("foobar", MVEL.executeExpression(s, myVarFactory));
  }
View Full Code Here

    }
  }

  public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    if ((Boolean) condition.getValue(ctx, thisValue, factory)) {
      return nestedStatement.getValue(ctx, thisValue, idxAlloc ? factory : new MapVariableResolverFactory(new HashMap(0), factory));
    }
    else if (elseIf != null) {
      return elseIf.getReducedValueAccelerated(ctx, thisValue, idxAlloc ? factory : new MapVariableResolverFactory(new HashMap(0), factory));
    }
    else if (elseBlock != null) {
      return elseBlock.getValue(ctx, thisValue, idxAlloc ? factory : new MapVariableResolverFactory(new HashMap(0), factory));
    }
    else {
      return null;
    }
  }
View Full Code Here

    }
  }

  public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
    if ((Boolean) eval(expr, start, offset, ctx, factory)) {
      return eval(expr, blockStart, blockOffset, ctx, new MapVariableResolverFactory(new HashMap(0), factory));
    }
    else if (elseIf != null) {
      return elseIf.getReducedValue(ctx, thisValue, new MapVariableResolverFactory(new HashMap(0), factory));
    }
    else if (elseBlock != null) {
      return elseBlock.getValue(ctx, thisValue, new MapVariableResolverFactory(new HashMap(0), factory));
    }
    else {
      return null;
    }
  }
View Full Code Here

    }

    try {
      Serializable xx = serializationTest(compiledD);
      AbstractParser.resetParserContext();
      eighth = executeExpression(xx, new Base(), new MapVariableResolverFactory(createTestMap()));
    }
    catch (Exception e) {
      if (failErrors == null) failErrors = new StringAppender();
      failErrors.append("\nEIGHTH TEST (Serializability): { " + ex + " }: EXCEPTION REPORT: \n\n");
View Full Code Here

      }
    };

    MVELRuntime.setThreadDebugger(testDebugger);

    assertEquals(10, MVEL.executeDebugger(compiled, null, new MapVariableResolverFactory(createTestMap())));
    assertTrue("did not break at line 7", breaked.contains(7));
  }
View Full Code Here

      }
    };

    MVELRuntime.setThreadDebugger(testDebugger);

    assertEquals(1, MVEL.executeDebugger(compiled, null, new MapVariableResolverFactory(createTestMap())));
    assertTrue("Debugger did not break at line 9", linesEncountered.contains(9));
  }
View Full Code Here

      }
    };

    MVELRuntime.setThreadDebugger(testDebugger);

    assertEquals(1, MVEL.executeDebugger(compiled, null, new MapVariableResolverFactory(createTestMap())));
    assertEquals("did not break at expected lines", Make.Set.<Integer>$()._(6)._(8)._(9)._(10)._(), breaked);
  }
View Full Code Here

    };


    MVELRuntime.setThreadDebugger(testDebugger);

    assertEquals("bar", MVEL.executeDebugger(compiled, null, new MapVariableResolverFactory(createTestMap())));
    assertTrue("did not fire before", result.firedBefore);
    assertTrue("did not fire after", result.firedAfter);
    assertEquals("did not break at expected points", Make.Set.<Integer>$()._(3)._(4)._(5)._(), breaked);
  }
View Full Code Here

TOP

Related Classes of org.mvel2.integration.impl.MapVariableResolverFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.