Search in sources :

Example 1 with LocalExpressionContext

use of net.sourceforge.processdash.data.compiler.LocalExpressionContext in project processdash by dtuma.

the class Filter method call.

/** Perform a procedure call.
     *
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    CompiledScript script = null;
    try {
        script = (CompiledScript) arguments.get(0);
    } catch (ClassCastException cce) {
    }
    if (script == null)
        return null;
    ListData result = new ListData();
    LocalExpressionContext lContext = new LocalExpressionContext(context);
    ListStack stack = new ListStack();
    Iterator i = collapseLists(arguments, 1).iterator();
    Object item;
    while (i.hasNext()) try {
        lContext.setLocalValue(item = i.next());
        stack.clear();
        script.run(stack, lContext);
        handleItem(result, item, stack.pop());
    } catch (Exception e) {
    }
    return result;
}
Also used : CompiledScript(net.sourceforge.processdash.data.compiler.CompiledScript) LocalExpressionContext(net.sourceforge.processdash.data.compiler.LocalExpressionContext) ListStack(net.sourceforge.processdash.data.compiler.ListStack) Iterator(java.util.Iterator) ListData(net.sourceforge.processdash.data.ListData)

Aggregations

Iterator (java.util.Iterator)1 ListData (net.sourceforge.processdash.data.ListData)1 CompiledScript (net.sourceforge.processdash.data.compiler.CompiledScript)1 ListStack (net.sourceforge.processdash.data.compiler.ListStack)1 LocalExpressionContext (net.sourceforge.processdash.data.compiler.LocalExpressionContext)1