1 7 8 package javax.script; 9 10 import java.util.Map ; 11 12 27 public abstract class CompiledScript { 28 29 42 43 public abstract Object eval(ScriptContext context) throws ScriptException; 44 45 60 public Object eval(Bindings bindings) throws ScriptException { 61 62 ScriptContext ctxt = getEngine().getContext(); 63 64 if (bindings != null) { 65 SimpleScriptContext tempctxt = new SimpleScriptContext(); 66 tempctxt.setBindings(bindings, ScriptContext.ENGINE_SCOPE); 67 tempctxt.setBindings(ctxt.getBindings(ScriptContext.GLOBAL_SCOPE), 68 ScriptContext.GLOBAL_SCOPE); 69 tempctxt.setWriter(ctxt.getWriter()); 70 tempctxt.setReader(ctxt.getReader()); 71 tempctxt.setErrorWriter(ctxt.getErrorWriter()); 72 ctxt = tempctxt; 73 } 74 75 return eval(ctxt); 76 } 77 78 79 88 public Object eval() throws ScriptException { 89 return eval(getEngine().getContext()); 90 } 91 92 98 public abstract ScriptEngine getEngine(); 99 100 } 101 | Popular Tags |