2003/11/18 10:47:26
[org.ibex.core.git] / src / org / xwt / js / JSTrap.java
diff --git a/src/org/xwt/js/JSTrap.java b/src/org/xwt/js/JSTrap.java
deleted file mode 100644 (file)
index 56a076a..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
-package org.xwt.js;
-
-import java.util.*;
-import org.xwt.util.*;
-import java.io.*;
-
-/**
- *  This class encapsulates a single trap placed on a given node. The
- *  traps for a given property name on a given box are maintained as a
- *  linked list stack, with the most recently placed trap at the head
- *  of the list.
- */
-public class JSTrap {
-
-    JSTrappable trapee = null;   ///< the box on which this trap was placed
-    JSFunction f = null;                 ///< the function for this trap
-    JSTrap next = null;          ///< the next trap down the trap stack
-    Object name = null;          ///< the property that the trap was placed on
-
-    private JSTrap(JSTrappable b, String n, JSFunction f, JSTrap nx) { trapee = b; name = n; this.f = f; this.next = nx; }
-
-    /** adds a trap, avoiding duplicates */
-    public static void addTrap(JSTrappable trapee, Object name, JSFunction f) {
-        for(JSTrap t = trapee.getTrap(name); t != null; t = t.next) if (t.f == f) return;
-        trapee.putTrap(name, new JSTrap(trapee, name.toString(), f, (JSTrap)trapee.getTrap(name)));
-    }
-
-    /** deletes a trap, if present */
-    public static void delTrap(JSTrappable trapee, Object name, JSFunction f) {
-        JSTrap t = (JSTrap)trapee.getTrap(name);
-        if (t == null) return;
-        if (t.f == f) { trapee.putTrap(t.name, t.next); return; }
-        for(; t.next != null; t = t.next) if (t.next.f == f) { t.next = t.next.next; return; }
-    }
-
-    /** objects onto which traps may be placed */
-    public static interface JSTrappable {
-        public abstract JSTrap getTrap(Object key);
-        public abstract void putTrap(Object key, JSTrap trap);
-        public abstract void putAndTriggerJSTraps(Object key, Object value);
-    }
-
-    static class JSTrapScope extends JSScope {
-        JSTrap t;
-        Object val = null;
-        boolean cascadeHappened = false;
-        public JSTrapScope(JSScope parent, JSTrap t, Object val) { super(parent); this.t = t; this.val = val; }
-        public Object get(Object key) {
-            if (key.equals("trapee")) return t.trapee;
-            if (key.equals("trapname")) return t.name;
-            return super.get(key);
-        }
-    }
-}
-