Refine search
@Override public String getUrlToLoad(int x, int y, int zoom) { try { return (String) bshInterpreter.eval("getTileUrl("+zoom+","+x+","+y+");"); } catch (bsh.EvalError e) { log.error(e.getMessage(), e); return null; } }
public static void bsh() throws EvalError { String expression = "input=2+2-5"; String value = " "; Interpreter i = new Interpreter(); try { i.eval(expression); } catch (EvalError evalError) { evalError.printStackTrace(); } value = String.valueOf((Integer)i.get("input")); System.out.println(value); }
public BshInterpreter() { interpreter = new Interpreter(); try { interpreter.eval("import org.ujmp.*"); interpreter.eval("import org.jdmp.*"); } catch (EvalError e) { e.printStackTrace(); } }
throws MojoFailureException Interpreter interpreter = new Interpreter(); interpreter.eval( source ); new MojoFailureException( "error during Beanshell script execution: " + ee.getMessage() ); mfe.initCause( ee ); throw mfe; try value = interpreter.get( property ); + property + "': " + ee.getMessage() ); mfe.initCause( ee ); throw mfe;
i.set("action", a); i.set("request", request); i.set("response", response); } else { i.set("response", httpResponse); log(request, "Error running custom beanshell rule (" + id + ") - " + e.getMessage());
private Object interpretBeanShell(String text, Map<String, Object> params) throws SensorException { bsh.Interpreter bsh = new bsh.Interpreter(); try { for (String name : params.keySet()) { Object val = params.get(name); if (val instanceof Number) { if (val instanceof Integer) { bsh.set(name, ((Integer) val).intValue()); } else if (val instanceof Long) { bsh.set(name, ((Long) val).longValue()); } else if (val instanceof Double) { bsh.set(name, ((Double) val).doubleValue()); } else if (val instanceof Float) { bsh.set(name, ((Float) val).floatValue()); } else { bsh.set(name, val); } } else if (val instanceof Boolean) { bsh.set(name, ((Boolean) val).booleanValue()); } else { bsh.set(name, params.get(name)); } } return bsh.eval(text); } catch (EvalError e) { throw new SensorException("Error executing bean script: " + e.getMessage(), e); } }
/** Extended form of print target error. This indirection is used to print UndeclaredThrowableExceptions which are possible when the proxy mechanism is available. We are shielded from compile problems by using a bsh script. This is acceptable here because we're not in a critical path... Otherwise we'd need yet another dynamically loaded module just for this. */ private String xPrintTargetError( Throwable t ) { String getTarget = "import java.lang.reflect.UndeclaredThrowableException;"+ "String result=\"\";"+ "while ( target instanceof UndeclaredThrowableException ) {"+ " target=target.getUndeclaredThrowable(); " + " result+=\"Nested: \"+target.toString();" + "}"+ "return result;"; Interpreter i = new Interpreter(); try { i.set("target", t); return (String)i.eval( getTarget ); } catch ( EvalError e ) { throw new InterpreterError("xprintarget: "+e.toString() ); } }
public int filterObject(CaptureSearchResult o) { int result = FILTER_EXCLUDE; try { boolean bResult = false; Interpreter interpreter = getInterpreter(); interpreter.set("result", o); if(expression != null) { bResult = (Boolean) interpreter.eval(expression); } else if(method != null) { bResult = (Boolean) interpreter.eval("matches(result)"); } else if(scriptPath != null) { bResult = (Boolean) interpreter.eval("matches(result)"); } if(bResult) { result = FILTER_INCLUDE; } } catch (EvalError e) { e.printStackTrace(); } return result; }
try { classLoader = findClassLoader(json, workflowRunID); interpreter.setClassLoader(classLoader); } catch (RuntimeException rex) { String message = "Unable to obtain the classloader for Beanshell service"; callback.getContext()); inputName = sanatisePortName(inputName); interpreter.set(inputName, input); interpreter.eval(json.get("script").asText()); logger.error(e); try { int lineNumber = e.getErrorLineNumber();
/** Parses an AE defined on ONE line in inline java code (interpreted) */ private static void parseAEJava(String line, IteratorWithPrevious<String> it, Pipeline pipeline) throws ParseException { LOG.info("+-parsing line '{}'", line); Interpreter i = new Interpreter(); // Construct an interpreter // Eval a statement and get the result try { String script = line.replaceFirst("ae_java: ", "").trim(); i.eval("aed = " + script + ";"); AnalysisEngineDescription aed = (AnalysisEngineDescription) i .get("aed"); pipeline.addAe(aed); } catch (EvalError e) { e.fillInStackTrace(); throw new ParseException( "cannot compile and run 'ae_java' command, " + e.toString(), -1); } }
/** * */ public JRBshEvaluator(String bshScript) throws JRException { super(); this.bshScript = bshScript; interpreter = new Interpreter(); interpreter.setClassLoader(Thread.currentThread().getContextClassLoader()); try { interpreter.eval(new StringReader(bshScript)); } catch(EvalError e) { throw new JRException( "Error evaluating report expressions BeanShell script." + "\nMessage : " + e.getMessage() + "\nLine " + e.getErrorLineNumber() + " : " + extractLineContent(e) ); } }
final Interpreter i = new Interpreter(); try { Object res = i.eval("(24 + 3) < 4"); System.out.println("Result is " + res); } catch (EvalError ex) { System.err.println("Error while evaluating expression: " + ex.getMessage()); }
public BusinessDataTestResult test(User user, Map context, QueryManager queryManager) { BusinessDataTestResult result = new BusinessDataTestResult(); Interpreter interpreter = new Interpreter(); String script = toScript(); try { eval(interpreter, user, context, queryManager); Boolean contain = (Boolean) interpreter .get(SystemConstant.IS_BUSINESS_DATA_VALID); Map variableMap = (Map) interpreter .get(SystemConstant.VARIABLE_MAP); result.setValid(contain.booleanValue()); result.setFailed(false); result.setScript(script); result.setVariableMap(variableMap); } catch (EvalError e) { result.setFailed(true); StringWriter sw=new StringWriter(); PrintWriter pw=new PrintWriter( sw ); e.printStackTrace( pw ); result.setErrorMessage( sw.toString() ); result.setScript(script); } return result; }
interpreter = new Interpreter(new StringReader(""), System.out, System.err, false, new NameSpace(master, "global"), null, null); } else { interpreter = new Interpreter(); interpreter.setClassLoader(classLoader); interpreter.set("bsf", mgr); } catch (EvalError e) { throw new BSFException("bsh internal error: "+e.toString());
console.setLocation(0, 0); beanshell.add(console); Interpreter interpreter = new Interpreter(console); try { interpreter.eval("addClassPath(\"" + absoluteVodka + "\")"); } else if (absoluteVodka.endsWith(".class")) { String classPathName = JavaUtil.retrieveCanonicalNameFromClass(((File) applicationLibs[lCont])); interpreter.eval("addClassPath(\"" + absoluteVodka + "\")"); interpreter.eval("import *"); } catch (EvalError ex) { manager.getStdErr().println("[!] BeanShell EvalErrorException: " + ex.toString().trim()); } catch (IOException iex) { manager.getStdErr().println("[!] BeanShell IOException: " + iex.toString().trim());
Interpreter interp = new Interpreter(); result = interp.eval( reader ); Thread.currentThread().setContextClassLoader( oldClassLoader ); container.getLogger().info( "Error text: " + evalError.getErrorText() );
private Object evalSource(Object source, ScriptContext scriptContext) throws ScriptException { bsh.NameSpace contextNameSpace = getEngineNameSpace(scriptContext); Interpreter bsh = getInterpreter(); bsh.setNameSpace(contextNameSpace); bsh.setOut(toPrintStream(scriptContext.getWriter())); bsh.setErr(toPrintStream(scriptContext.getErrorWriter())); try { if (source instanceof Reader) { return bsh.eval((Reader) source); } else { return bsh.eval((String) source); } //} catch (ParseException e) { // explicit parsing error TODO how to handle parse exception ? //throw new ScriptException(e.toString()); //e.getErrorSourceFile(), e.getErrorLineNumber()); } catch (TargetError e) { // The script threw an application level exception // set it as the cause ? ScriptException se = new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); se.initCause(e.getTarget()); throw se; } catch (EvalError e) { // The script couldn't be evaluated properly throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber()); } catch (InterpreterError e) { // The interpreter had a fatal problem throw new ScriptException(e.toString()); } }
public Object eval(String command) { try { return interpreter.eval(command); } catch (EvalError e) { e.printStackTrace(); return null; } }
Interpreter.debug("eval: nameSpace = ", nameSpace); throw e; } catch ( InterpreterError e ) { throw new EvalError( "Sourced file: "+sourceFileInfo+" internal Error: " + e.getMessage(), node, callstack, e); } catch ( EvalError e) { if ( DEBUG.get()) e.printStackTrace(); if ( e.getNode()==null ) e.setNode( node ); e.reThrow( "Sourced file: "+sourceFileInfo ); } catch ( Exception e) { if ( DEBUG.get()) e.printStackTrace(); throw new EvalError( "Sourced file: "+sourceFileInfo+" unknown error: " + e.getMessage(), node, callstack, e); localInterpreter.setErr(null); } catch (IOException ioe) { throw new EvalError("Sourced file: "+sourceFileInfo+" " + ioe.toString(), null, null, ioe);
if ( interactive && null == getParent() ) try { eval("printBanner();"); } catch ( EvalError e ) { println( "BeanShell "+VERSION+" - by Pat Niemeyer (pat@pat.net)"); error( "Evaluation Error: "+e.getMessage() ); else error( "Evaluation Error: "+e.getRawMessage() ); if(DEBUG.get()) e.printStackTrace(); if(!interactive) EOF = true;