public void generateTemplates(final String ruleTemplate, final String invokerTemplate, final ProcessBuildContext context, final String className, final Map vars, final Object invokerLookup, final BaseDescr descrLookup) { TemplateRegistry registry = getRuleTemplateRegistry(); context.getMethods().add((String) TemplateRuntime.execute(registry.getNamedTemplate(ruleTemplate), null, new MapVariableResolverFactory(vars), registry) ); registry = getInvokerTemplateRegistry(); final String invokerClassName = context.getPkg().getName() + "." + context.getProcessDescr().getClassName() + StringUtils.ucFirst(className) + "Invoker"; context.getInvokers().put(invokerClassName, (String)TemplateRuntime.execute(registry.getNamedTemplate(invokerTemplate), null, new MapVariableResolverFactory(vars), registry) ); context.addInvokerLookup(invokerClassName, invokerLookup); context.addDescrLookups(invokerClassName, descrLookup); }
if (value == null) { try { value = MVELSafeHelper.getEvaluator().eval(association.getSources().get(0), new MapVariableResolverFactory(objects)); } catch (Throwable t) {
new MapVariableResolverFactory( map ), registry );
Object method = TemplateRuntime.execute( registry.getNamedTemplate( "accumulateInvoker" ), null, new MapVariableResolverFactory( map ), registry );
Object method = TemplateRuntime.execute( registry.getNamedTemplate( "accumulateInvoker" ), null, new MapVariableResolverFactory( map ), registry );
public VariableResolver createVariable(String name, Object value) { if (nextFactory == null) { nextFactory = new MapVariableResolverFactory(new HashMap()); } /** * Delegate to the next factory. */ return nextFactory.createVariable(name, value); }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { VariableResolverFactory ctxFactory = new MapVariableResolverFactory(new HashMap<String, Object>(0), factory); do { compiledBlock.getValue(ctx, thisValue, ctxFactory); } while ((Boolean) condition.getValue(ctx, thisValue, factory)); return null; }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { VariableResolverFactory ctxFactory = new MapVariableResolverFactory(new HashMap<String, Object>(0), factory); do { compiledBlock.getValue(ctx, thisValue, ctxFactory); } while ((Boolean) condition.getValue(ctx, thisValue, factory)); return null; }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { VariableResolverFactory lc = new MapVariableResolverFactory(new HashMap(0), factory); do { compiledBlock.getValue(ctx, thisValue, lc); } while (!(Boolean) condition.getValue(ctx, thisValue, lc)); return null; }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { VariableResolverFactory ctxFactory = new MapVariableResolverFactory(new HashMap<String, Object>(), factory); while ((Boolean) condition.getValue(ctx, thisValue, factory)) { compiledBlock.getValue(ctx, thisValue, ctxFactory); } return null; }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { VariableResolverFactory ctxFactory = new MapVariableResolverFactory(new HashMap(0), factory); while (!(Boolean) condition.getValue(ctx, thisValue, factory)) { compiledBlock.getValue(ctx, thisValue, ctxFactory); } return null; }
public IndexedVariableResolverFactory(String[] varNames, Object[] values, VariableResolverFactory nextFactory) { this.indexedVariableNames = varNames; this.nextFactory = new MapVariableResolverFactory(); this.nextFactory.setNextFactory(nextFactory); this.indexedVariableResolvers = createResolvers(values, varNames.length); }
@Override public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { final MapVariableResolverFactory resolverFactory = new MapVariableResolverFactory(new HashMap<String, Object>(), factory); function.getCompiledBlock().getValue(ctx, thisValue, resolverFactory); return new PrototypalFunctionInstance(function, resolverFactory); }
/** * {@inheritDoc} */ @Override public Object run(Map<String, Object> variables) { if (variables == null) { variables = new HashMap<String, Object>(); } VariableResolverFactory factory = new MapVariableResolverFactory(variables, _propertyResolverFactory); return isCompiled() ? MVEL.executeExpression(_compiled, factory) : MVEL.eval(_expression, factory); }
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) { PrototypalFunctionInstance instance = new PrototypalFunctionInstance(this, new MapVariableResolverFactory()); if (name != null) { if (!factory.isIndexedFactory() && factory.isResolveable(name)) throw new CompileException("duplicate function: " + name, expr, start); factory.createVariable(name, instance); } return instance; }
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) { PrototypalFunctionInstance instance = new PrototypalFunctionInstance(this, new MapVariableResolverFactory()); if (name != null) { if (!factory.isIndexedFactory() && factory.isResolveable(name)) throw new CompileException("duplicate function: " + name, expr, start); factory.createVariable(name, instance); } return instance; }
public String generateFieldMapperGenerator(TypeOracle oracle, JField targetWidget, JType targetType, JField targetEntityMember, JField targetEntityField) { InputStream istream = this.getClass().getResourceAsStream("TextBoxFMGenerator.mv"); Map<String, Object> vars = new HashMap<String, Object>(); vars.put("typeOracle", oracle); vars.put("targetWidget", targetWidget.getType().isClassOrInterface().getQualifiedSourceName()); vars.put("targetType", targetType.isClassOrInterface().getQualifiedSourceName()); vars.put("fieldType", targetEntityMember.getType().isClassOrInterface().getQualifiedSourceName()); vars.put("fieldName", targetEntityMember.getName()); return (String) TemplateRuntime.eval(istream, null, new MapVariableResolverFactory(vars), null); }
public void testThisReferenceMapVirtualObjects() { Map<String, String> map = new HashMap<String, String>(); map.put("foo", "bar"); VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>()); factory.createVariable("this", map); assertEquals(true, eval("this.foo == 'bar'", map, factory)); }
public void testReflectiveOptimizerWorksFine() { OptimizerFactory.setDefaultOptimizer("reflective"); Serializable compileExpression = MVEL.compileExpression( biglistTestScript ); VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap()); int actual = (Integer) executeExpression(compileExpression, factory); assertEquals( actual, 25); }
public void testTestIntToLong() { String s = "1+(long)a"; ParserContext pc = new ParserContext(); pc.addInput("a", Integer.class); ExpressionCompiler compiler = new ExpressionCompiler(s, pc); CompiledExpression expr = compiler.compile(); Map vars = new HashMap(); vars.put("a", 1); Object r = ((ExecutableStatement) expr).getValue(null, new MapVariableResolverFactory(vars)); assertEquals(new Long(2), r); }