use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class ForEachNode method eval.
public Object eval(TemplateRuntime runtime, TemplateOutputStream appender, Object ctx, VariableResolverFactory factory) {
Iterator[] iters = new Iterator[item.length];
Object o;
for (int i = 0; i < iters.length; i++) {
if ((o = MVEL.eval(expression[i], ctx, factory)) instanceof Iterable) {
iters[i] = ((Iterable) o).iterator();
} else if (o instanceof Object[]) {
iters[i] = new ArrayIterator((Object[]) o);
} else {
throw new TemplateRuntimeError("cannot iterate object type: " + o.getClass().getName());
}
}
Map<String, Object> locals = new HashMap<String, Object>();
MapVariableResolverFactory localFactory = new MapVariableResolverFactory(locals, factory);
int iterate = iters.length;
while (true) {
for (int i = 0; i < iters.length; i++) {
if (!iters[i].hasNext()) {
iterate--;
locals.put(item[i], "");
} else {
locals.put(item[i], iters[i].next());
}
}
if (iterate != 0) {
nestedNode.eval(runtime, appender, ctx, localFactory);
if (sepExpr != null) {
for (Iterator it : iters) {
if (it.hasNext()) {
appender.append(String.valueOf(MVEL.eval(sepExpr, ctx, factory)));
break;
}
}
}
} else
break;
}
return next != null ? next.eval(runtime, appender, ctx, factory) : null;
}
use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class IndexedOperativeAssign method getReducedValueAccelerated.
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
VariableResolver resolver = factory.getIndexedVariableResolver(register);
resolver.setValue(ctx = MathProcessor.doOperations(resolver.getValue(), operation, statement.getValue(ctx, thisValue, factory)));
return ctx;
}
use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class BaseVariableResolverFactory method appendFactory.
public void appendFactory(VariableResolverFactory resolverFactory) {
if (nextFactory == null) {
nextFactory = resolverFactory;
} else {
VariableResolverFactory vrf = nextFactory;
while (vrf.getNextFactory() != null) {
vrf = vrf.getNextFactory();
}
vrf.setNextFactory(nextFactory);
}
}
use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class IndexedPostFixDecNode method getReducedValueAccelerated.
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
VariableResolver vResolver = factory.getIndexedVariableResolver(register);
// ctx = vResolver.getValue();
vResolver.setValue(MathProcessor.doOperations(ParseTools.resolveType(ctx = vResolver.getValue()), ctx, Operator.SUB, DataTypes.INTEGER, 1));
return ctx;
}
use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class IndexedPostFixIncNode method getReducedValueAccelerated.
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
VariableResolver vResolver = factory.getIndexedVariableResolver(register);
vResolver.setValue(MathProcessor.doOperations(ctx = vResolver.getValue(), Operator.ADD, DataTypes.INTEGER, 1));
return ctx;
}
Aggregations