Code example for SimpleBindings

Methods: getput

0
        String ext = scriptName.substring(idx + 1);
        ScriptEngine engine = manager.getEngineByExtension(ext);
        SMSValidate.notNull(engine, "no scripting engine for " + scriptName);
        Debugger.getInstance().debug("running script " + scriptName + " with " + engine.getFactory().getEngineName());
 
        Bindings bindings = new SimpleBindings();
        if (args.length > 2) {
            String[] scriptArgs = new String[args.length - 2];
            System.arraycopy(args, 2, scriptArgs, 0, scriptArgs.length);
            bindings.put("args", scriptArgs);
        } else { 
            bindings.put("args", new String[0]);
        } 
        bindings.put("view", trigger instanceof SMSView ? trigger : null);
        bindings.put("trigger", trigger);
        bindings.put("commandSender", sender);
        bindings.put("result", true);
        File scriptFile = new File(DirectoryStructure.getScriptsFolder(), scriptName);
        boolean retval = true;
        try { 
            engine.eval(new BufferedReader(new FileReader(scriptFile)), bindings);
            Object o = bindings.get("result");
            if (o instanceof Boolean) {
                retval = (Boolean) o;
                Debugger.getInstance().debug("script " + scriptName + " returns: " + retval);
            } 
        } catch (FileNotFoundException e) {
Experience pair programming with AI  Get Codota for Java