use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class OperativeAssign method getReducedValueAccelerated.
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
VariableResolver resolver = factory.getVariableResolver(varName);
resolver.setValue(ctx = MathProcessor.doOperations(resolver.getValue(), operation, knownInType, statement.getValue(ctx, thisValue, factory)));
return ctx;
}
use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class OperativeAssign method getReducedValue.
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
VariableResolver resolver = factory.getVariableResolver(varName);
resolver.setValue(ctx = MathProcessor.doOperations(resolver.getValue(), operation, eval(expr, start, offset, ctx, factory)));
return ctx;
}
use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class Soundslike method getReducedValue.
public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
try {
String i = String.valueOf(soundslike.getReducedValue(ctx, thisValue, factory));
if (i == null)
throw new ClassCastException();
String x = (String) stmt.getReducedValue(ctx, thisValue, factory);
if (x == null)
throw new CompileException("not a string: " + stmt.getName(), stmt.getExpr(), stmt.getStart());
return soundex(i).equals(soundex(x));
} catch (ClassCastException e) {
throw new CompileException("not a string: " + soundslike.getName(), soundslike.getExpr(), soundslike.getStart());
}
}
use of org.mvel2.integration.VariableResolverFactory in project mvel by mikebrock.
the class CompiledForEachNode 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.executeExpression(ce[i], ctx, factory)) instanceof Iterable) {
iters[i] = ((Iterable) o).iterator();
} else if (o instanceof Object[]) {
iters[i] = new ArrayIterator((Object[]) o);
} else if (o instanceof Integer) {
iters[i] = new CountIterator((Integer) 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.executeExpression(cSepExpr, 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 ReflectiveAccessorOptimizer method optimizeCollection.
public Accessor optimizeCollection(ParserContext pCtx, Object o, Class type, char[] property, int start, int offset, Object ctx, Object thisRef, VariableResolverFactory factory) {
this.start = this.cursor = start;
this.length = start + offset;
this.returnType = type;
this.ctx = ctx;
this.variableFactory = factory;
this.pCtx = pCtx;
Accessor root = _getAccessor(o, returnType);
if (property != null && length > start) {
return new Union(root, property, cursor, offset);
} else {
return root;
}
}
Aggregations