added xt.scope (forgotten earlier)
authoradam <adam@megacz.com>
Sun, 27 Feb 2005 20:34:58 +0000 (20:34 +0000)
committeradam <adam@megacz.com>
Sun, 27 Feb 2005 20:34:58 +0000 (20:34 +0000)
darcs-hash:20050227203458-5007d-b9a27015aa6d323839f9ca2deb189f925f999028.gz

src/org/ibex/xt/Scope.java [new file with mode: 0644]

diff --git a/src/org/ibex/xt/Scope.java b/src/org/ibex/xt/Scope.java
new file mode 100644 (file)
index 0000000..7e644e7
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
+package org.ibex.xt;
+import org.ibex.js.*;
+import org.ibex.util.*;
+import org.ibex.io.*;
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+public class Scope extends JS.Obj {
+    private final JS parent;
+    private final Hash declared = new Hash();
+    public Scope(JS parent) { this.parent = parent; }
+    public JS get(JS key) throws JSExn { if (declared.get(key)!=null) return super.get(key); return parent.get(key); }
+    public void put(JS key, JS val) throws JSExn { if (declared.get(key)!=null) super.put(key,val); else parent.put(key,val); }
+    public void declare(JS key) { declared.put(key, Boolean.TRUE); }
+    public void declare(String key) { declare(JSU.S(key)); }
+    public void undeclare(JS key) { declared.remove(key); }
+    public void undeclare(String key) { undeclare(JSU.S(key)); }
+}