/** * Returns whether there is an event listener for the given namespace URI. */ public boolean hasEventListener(String namespaceURI) { if (namespaceURI == null) { return n != 0; } return counts.get(namespaceURI) != 0; }
/** * Increments the value associated with the given key. */ public int inc(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value++; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, 1, table[index]); return 0; }
/** * Adds a listener. */ public void addListener(String namespaceURI, Object group, EventListener listener) { for (Entry e = head; e != null; e = e.next) { if ((namespaceURI != null && namespaceURI.equals(e.namespaceURI) || namespaceURI == null && e.namespaceURI == null) && e.listener == listener) { // Listener is already in the list, so do nothing. return; } } head = new Entry(listener, namespaceURI, group, head); counts.inc(namespaceURI); n++; listeners = null; listenersNS.remove(namespaceURI); }
counts.dec(namespaceURI); n--; listeners = null;
/** * Decrements the value associated with the given key. */ public int dec(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value--; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, -1, table[index]); return 0; }
/** * Adds a listener. */ public void addListener(String namespaceURI, Object group, EventListener listener) { for (Entry e = head; e != null; e = e.next) { if ((namespaceURI != null && namespaceURI.equals(e.namespaceURI) || namespaceURI == null && e.namespaceURI == null) && e.listener == listener) { // Listener is already in the list, so do nothing. return; } } head = new Entry(listener, namespaceURI, group, head); counts.inc(namespaceURI); n++; listeners = null; listenersNS.remove(namespaceURI); }
counts.dec(namespaceURI); n--; listeners = null;
/** * Decrements the value associated with the given key. */ public int dec(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value--; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, -1, table[index]); return 0; }
/** * Returns whether there is an event listener for the given namespace URI. */ public boolean hasEventListener(String namespaceURI) { if (namespaceURI == null) { return n != 0; } return counts.get(namespaceURI) != 0; }
/** * Adds a listener. */ public void addListener(String namespaceURI, Object group, EventListener listener) { for (Entry e = head; e != null; e = e.next) { if ((namespaceURI != null && namespaceURI.equals(e.namespaceURI) || namespaceURI == null && e.namespaceURI == null) && e.listener == listener) { // Listener is already in the list, so do nothing. return; } } head = new Entry(listener, namespaceURI, group, head); counts.inc(namespaceURI); n++; listeners = null; listenersNS.remove(namespaceURI); }
counts.dec(namespaceURI); n--; listeners = null;
/** * Increments the value associated with the given key. */ public int inc(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value++; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, 1, table[index]); return 0; }
/** * Returns whether there is an event listener for the given namespace URI. */ public boolean hasEventListener(String namespaceURI) { if (namespaceURI == null) { return n != 0; } return counts.get(namespaceURI) != 0; }
/** * Decrements the value associated with the given key. */ public int dec(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value--; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, -1, table[index]); return 0; }
/** * Returns an array of EventListeners that match the given namespace URI. */ public Entry[] getEventListeners(String namespaceURI) { if (namespaceURI == null) { return getEventListeners(); } Entry[] ls = (Entry[]) listenersNS.get(namespaceURI); if (ls != null) { return ls; } int count = counts.get(namespaceURI); if (count == 0) { return null; } ls = new Entry[count]; listenersNS.put(namespaceURI, ls); int i = 0; for (Entry e = head; i < count; e = e.next) { if (namespaceURI.equals(e.namespaceURI)) { ls[i++] = e; } } return ls; }
/** * Sets the value associated with the given key. */ public int put(Object key, int value) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { int old = e.value; e.value = value; return old; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, value, table[index]); return 0; }
/** * Returns an array of EventListeners that match the given namespace URI. */ public Entry[] getEventListeners(String namespaceURI) { if (namespaceURI == null) { return getEventListeners(); } Entry[] ls = (Entry[]) listenersNS.get(namespaceURI); if (ls != null) { return ls; } int count = counts.get(namespaceURI); if (count == 0) { return null; } ls = new Entry[count]; listenersNS.put(namespaceURI, ls); int i = 0; for (Entry e = head; i < count; e = e.next) { if (namespaceURI.equals(e.namespaceURI)) { ls[i++] = e; } } return ls; }
/** * Increments the value associated with the given key. */ public int inc(Object key) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { return e.value++; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, 1, table[index]); return 0; }
/** * Returns an array of EventListeners that match the given namespace URI. */ public Entry[] getEventListeners(String namespaceURI) { if (namespaceURI == null) { return getEventListeners(); } Entry[] ls = (Entry[]) listenersNS.get(namespaceURI); if (ls != null) { return ls; } int count = counts.get(namespaceURI); if (count == 0) { return null; } ls = new Entry[count]; listenersNS.put(namespaceURI, ls); int i = 0; for (Entry e = head; i < count; e = e.next) { if (namespaceURI.equals(e.namespaceURI)) { ls[i++] = e; } } return ls; }
/** * Sets the value associated with the given key. */ public int put(Object key, int value) { int hash = key == null ? 0 : key.hashCode() & 0x7FFFFFFF; int index = hash % table.length; for (Entry e = table[index]; e != null; e = e.next) { if (e.hash == hash && (e.key == null && key == null || e.key != null && e.key.equals(key))) { int old = e.value; e.value = value; return old; } } // The key is not in the hash table int len = table.length; if (count++ >= (len - (len >> 2))) { // more than 75% loaded: grow rehash(); index = hash % table.length; } table[index] = new Entry(hash, key, value, table[index]); return 0; }