1 Clazz.declarePackage ("java.beans");
2 Clazz.load (null, "java.beans.ChangeListenerMap", ["java.util.ArrayList", "$.Collections", "$.EventListenerProxy", "$.HashMap"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 Clazz.instantialize (this, arguments);
6 }, java.beans, "ChangeListenerMap");
7 Clazz.defineMethod (c$, "add",
8 function (name, listener) {
9 if (this.map == null) {
10 this.map = new java.util.HashMap ();
11 }var array = this.map.get (name);
12 var size = (array != null) ? array.length : 0;
13 var clone = this.newArray (size + 1);
14 clone[size] = listener;
16 System.arraycopy (array, 0, clone, 0, size);
17 }this.map.put (name, clone);
19 Clazz.defineMethod (c$, "remove",
20 function (name, listener) {
21 if (this.map != null) {
22 var array = this.map.get (name);
24 for (var i = 0; i < array.length; i++) {
25 if (listener.equals (array[i])) {
26 var size = array.length - 1;
28 var clone = this.newArray (size);
29 System.arraycopy (array, 0, clone, 0, i);
30 System.arraycopy (array, i + 1, clone, i, size - i);
31 this.map.put (name, clone);
33 this.map.remove (name);
34 if (this.map.isEmpty ()) {
39 Clazz.defineMethod (c$, "get",
41 return (this.map != null) ? this.map.get (name) : null;
43 Clazz.defineMethod (c$, "set",
44 function (name, listeners) {
45 if (listeners != null) {
46 if (this.map == null) {
47 this.map = new java.util.HashMap ();
48 }this.map.put (name, listeners);
49 } else if (this.map != null) {
50 this.map.remove (name);
51 if (this.map.isEmpty ()) {
54 Clazz.defineMethod (c$, "getListeners",
56 if (this.map == null) {
57 return this.newArray (0);
58 }var list = new java.util.ArrayList ();
59 var listeners = this.map.get (null);
60 if (listeners != null) {
61 for (var listener, $listener = 0, $$listener = listeners; $listener < $$listener.length && ((listener = $$listener[$listener]) || true); $listener++) {
64 }for (var entry, $entry = this.map.entrySet ().iterator (); $entry.hasNext () && ((entry = $entry.next ()) || true);) {
65 var name = entry.getKey ();
67 for (var listener, $listener = 0, $$listener = entry.getValue (); $listener < $$listener.length && ((listener = $$listener[$listener]) || true); $listener++) {
68 list.add (this.newProxy (name, listener));
71 return list.toArray (this.newArray (list.size ()));
73 Clazz.defineMethod (c$, "getListeners",
76 var listeners = this.get (name);
77 if (listeners != null) {
78 return listeners.clone ();
79 }}return this.newArray (0);
81 Clazz.defineMethod (c$, "hasListeners",
83 if (this.map == null) {
85 }var array = this.map.get (null);
86 return (array != null) || ((name != null) && (null != this.map.get (name)));
88 Clazz.defineMethod (c$, "getEntries",
90 return (this.map != null) ? this.map.entrySet () : java.util.Collections.emptySet ();
92 Clazz.defineMethod (c$, "extract",
94 while (Clazz.instanceOf (listener, java.util.EventListenerProxy)) {
96 listener = proxy.getListener ();