home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / script / AbstractScriptEngine.class (.txt) next >
Encoding:
Java Class File  |  2006-11-29  |  2.4 KB  |  105 lines

  1. package javax.script;
  2.  
  3. import java.io.Reader;
  4.  
  5. public abstract class AbstractScriptEngine implements ScriptEngine {
  6.    protected ScriptContext context;
  7.  
  8.    public AbstractScriptEngine() {
  9.       this.context = new SimpleScriptContext();
  10.    }
  11.  
  12.    public AbstractScriptEngine(Bindings var1) {
  13.       this();
  14.       if (var1 == null) {
  15.          throw new NullPointerException("n is null");
  16.       } else {
  17.          this.context.setBindings(var1, 100);
  18.       }
  19.    }
  20.  
  21.    public void setContext(ScriptContext var1) {
  22.       if (var1 == null) {
  23.          throw new NullPointerException("null context");
  24.       } else {
  25.          this.context = var1;
  26.       }
  27.    }
  28.  
  29.    public ScriptContext getContext() {
  30.       return this.context;
  31.    }
  32.  
  33.    public Bindings getBindings(int var1) {
  34.       if (var1 == 200) {
  35.          return this.context.getBindings(200);
  36.       } else if (var1 == 100) {
  37.          return this.context.getBindings(100);
  38.       } else {
  39.          throw new IllegalArgumentException("Invalid scope value.");
  40.       }
  41.    }
  42.  
  43.    public void setBindings(Bindings var1, int var2) {
  44.       if (var2 == 200) {
  45.          this.context.setBindings(var1, 200);
  46.       } else {
  47.          if (var2 != 100) {
  48.             throw new IllegalArgumentException("Invalid scope value.");
  49.          }
  50.  
  51.          this.context.setBindings(var1, 100);
  52.       }
  53.  
  54.    }
  55.  
  56.    public void put(String var1, Object var2) {
  57.       Bindings var3 = this.getBindings(100);
  58.       if (var3 != null) {
  59.          var3.put(var1, var2);
  60.       }
  61.  
  62.    }
  63.  
  64.    public Object get(String var1) {
  65.       Bindings var2 = this.getBindings(100);
  66.       return var2 != null ? var2.get(var1) : null;
  67.    }
  68.  
  69.    public Object eval(Reader var1, Bindings var2) throws ScriptException {
  70.       ScriptContext var3 = this.getScriptContext(var2);
  71.       return this.eval((Reader)var1, (ScriptContext)var3);
  72.    }
  73.  
  74.    public Object eval(String var1, Bindings var2) throws ScriptException {
  75.       ScriptContext var3 = this.getScriptContext(var2);
  76.       return this.eval((String)var1, (ScriptContext)var3);
  77.    }
  78.  
  79.    public Object eval(Reader var1) throws ScriptException {
  80.       return this.eval((Reader)var1, (ScriptContext)this.context);
  81.    }
  82.  
  83.    public Object eval(String var1) throws ScriptException {
  84.       return this.eval((String)var1, (ScriptContext)this.context);
  85.    }
  86.  
  87.    protected ScriptContext getScriptContext(Bindings var1) {
  88.       SimpleScriptContext var2 = new SimpleScriptContext();
  89.       Bindings var3 = this.getBindings(200);
  90.       if (var3 != null) {
  91.          var2.setBindings(var3, 200);
  92.       }
  93.  
  94.       if (var1 != null) {
  95.          var2.setBindings(var1, 100);
  96.          var2.setReader(this.context.getReader());
  97.          var2.setWriter(this.context.getWriter());
  98.          var2.setErrorWriter(this.context.getErrorWriter());
  99.          return var2;
  100.       } else {
  101.          throw new NullPointerException("Engine scope Bindings may not be null.");
  102.       }
  103.    }
  104. }
  105.