From: adam Date: Sun, 27 Feb 2005 20:34:58 +0000 (+0000) Subject: added xt.scope (forgotten earlier) X-Git-Url: http://git.megacz.com/?p=org.ibex.xt.git;a=commitdiff_plain;h=3f3b2560f1b42d5417b8622ae66648ec042b1159 added xt.scope (forgotten earlier) darcs-hash:20050227203458-5007d-b9a27015aa6d323839f9ca2deb189f925f999028.gz --- diff --git a/src/org/ibex/xt/Scope.java b/src/org/ibex/xt/Scope.java new file mode 100644 index 0000000..7e644e7 --- /dev/null +++ b/src/org/ibex/xt/Scope.java @@ -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)); } +}