use of net.sourceforge.processdash.data.compiler.CompiledScript in project processdash by dtuma.
the class Nvl method call.
/** Perform a procedure call.
*
* This method <b>must</b> be thread-safe.
*/
public Object call(List arguments, ExpressionContext context) {
ListStack stack = null;
for (Iterator iter = arguments.iterator(); iter.hasNext(); ) {
Object arg = iter.next();
if (arg instanceof CompiledScript) {
try {
CompiledScript script = (CompiledScript) arg;
if (stack == null)
stack = new ListStack();
else
stack.clear();
script.run(stack, context);
arg = stack.pop();
} catch (Exception e) {
}
}
if (arg instanceof SimpleData && !isBadValue((SimpleData) arg))
return arg;
}
return null;
}
use of net.sourceforge.processdash.data.compiler.CompiledScript in project processdash by dtuma.
the class RollupAutoData method debugPrint.
private void debugPrint(Map definitions) {
String loggerName = RollupAutoData.class.getName() + "." + definesRollupID;
Logger logger = Logger.getLogger(loggerName);
if (!logger.isLoggable(Level.FINEST))
return;
StringBuffer msg = new StringBuffer();
msg.append("Definitions for ").append(definesRollupID).append(" Rollup ------------------------------\n");
Iterator i = definitions.entrySet().iterator();
Map.Entry e;
while (i.hasNext()) {
e = (Map.Entry) i.next();
msg.append("[").append(e.getKey()).append("] = ");
if (e.getValue() instanceof CompiledScript)
msg.append(((CompiledScript) e.getValue()).saveString());
else
msg.append(e.getValue());
msg.append("\n");
}
msg.append("----End--------------------------------------");
logger.finest(msg.toString());
}
use of net.sourceforge.processdash.data.compiler.CompiledScript in project processdash by dtuma.
the class Eval method call.
/** Perform a procedure call.
*
* This method <b>must</b> be thread-safe.
*/
public Object call(List arguments, ExpressionContext context) {
String expression = asString(getArg(arguments, 0));
if (expression == null || expression.length() == 0)
return null;
String prefix = asString(getArg(arguments, 1));
CompiledScript script = Compiler.compile(expression);
try {
Stack stack = new ListStack();
if (prefix != null)
context = new RelativeExpressionContext(context, prefix);
script.run(stack, context);
return stack.pop();
} catch (ExecutionException ee) {
return null;
}
}
use of net.sourceforge.processdash.data.compiler.CompiledScript 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;
}
use of net.sourceforge.processdash.data.compiler.CompiledScript in project processdash by dtuma.
the class Iff method call.
/** Perform a procedure call.
*
* This method <b>must</b> be thread-safe.
*/
public Object call(List arguments, ExpressionContext context) {
if (arguments.size() < 2)
return null;
SimpleData test = getArg(arguments, 0);
Object result = null;
if (test != null && test.test())
result = arguments.get(1);
else if (arguments.size() > 2)
result = arguments.get(2);
if (result instanceof CompiledScript) {
try {
CompiledScript script = (CompiledScript) result;
ListStack stack = new ListStack();
script.run(stack, context);
result = stack.pop();
} catch (Exception e) {
}
}
return result;
}
Aggregations