/** * Registers an event listener that will not be stopped by the usual * XBL stopping. */ public void addImplementationEventListenerNS(String namespaceURI, String type, EventListener listener, boolean useCapture) { HashTable listeners; if (useCapture) { if (capturingImplementationListeners == null) { capturingImplementationListeners = new HashTable(); } listeners = capturingImplementationListeners; } else { if (bubblingImplementationListeners == null) { bubblingImplementationListeners = new HashTable(); } listeners = bubblingImplementationListeners; } EventListenerList list = (EventListenerList) listeners.get(type); if (list == null) { list = new EventListenerList(); listeners.put(type, list); } list.addListener(namespaceURI, null, listener); }
/** * Returns the pseudo attributes in a table. */ public HashTable getPseudoAttributes() { if (pseudoAttributes == null) { pseudoAttributes = new HashTable(); pseudoAttributes.put("alternate", "no"); pseudoAttributes.put("media", "all"); DOMUtilities.parseStyleSheetPIData(data, pseudoAttributes); } return pseudoAttributes; }
/** * Returns the implementation listneers. */ public EventListenerList getImplementationEventListeners (String type, boolean useCapture) { HashTable listeners = useCapture ? capturingImplementationListeners : bubblingImplementationListeners; if (listeners == null) { return null; } return (EventListenerList) listeners.get(type); }
/** * Unregisters an implementation event listener. */ public void removeImplementationEventListenerNS(String namespaceURI, String type, EventListener listener, boolean useCapture) { HashTable listeners = useCapture ? capturingImplementationListeners : bubblingImplementationListeners; if (listeners == null) { return; } EventListenerList list = (EventListenerList) listeners.get(type); if (list == null) { return; } list.removeListener(namespaceURI, listener); if (list.size() == 0) { listeners.remove(type); } }
/** * Extracts the first XSL processing instruction from the input * XML document. */ protected String extractXSLProcessingInstruction(Document doc) { Node child = doc.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { ProcessingInstruction pi = (ProcessingInstruction)child; HashTable table = new HashTable(); DOMUtilities.parseStyleSheetPIData(pi.getData(), table); Object type = table.get(PSEUDO_ATTRIBUTE_TYPE); if (XSL_PROCESSING_INSTRUCTION_TYPE.equals(type)) { Object href = table.get(PSEUDO_ATTRIBUTE_HREF); if (href != null) { return href.toString(); } else { return null; } } } child = child.getNextSibling(); } return null; }
/** * 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; }
/** * Registers a new EventFactory object. */ public void registerEventFactory(String eventType, EventFactory factory) { eventFactories.put(eventType.toLowerCase(), factory); }
n--; listeners = null; listenersNS.remove(namespaceURI);
/** * Creates a new link. */ public Link(Link n) { table = new HashTable(); next = n; if (next != null) defaultStr = next.defaultStr; } }
/** * Sets a new value for the given variable * @return the old value or null */ public Object put(Object key, Object 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))) { Object 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; } Entry e = new Entry(hash, key, value, table[index]); table[index] = e; return null; }
/** * Returns a list event listeners depending on the specified event * type and phase. * @param type the event type * @param useCapture */ public EventListenerList getEventListeners(String type, boolean useCapture) { HashTable listeners = useCapture ? capturingListeners : bubblingListeners; if (listeners == null) { return null; } return (EventListenerList) listeners.get(type); }
/** * Deregisters an event listener. */ public void removeEventListenerNS(String namespaceURI, String type, EventListener listener, boolean useCapture) { HashTable listeners; if (useCapture) { listeners = capturingListeners; } else { listeners = bubblingListeners; } if (listeners == null) { return; } EventListenerList list = (EventListenerList) listeners.get(type); if (list != null) { list.removeListener(namespaceURI, listener); if (list.size() == 0) { listeners.remove(type); } } }
/** * Registers a DOM feature. */ protected void registerFeature(String name, Object value) { features.put(name.toLowerCase(), value); }
/** * 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); }
/** * Registers an event listener for the given namespaced event type * in the specified group. */ public void addEventListenerNS(String namespaceURI, String type, EventListener listener, boolean useCapture, Object group) { HashTable listeners; if (useCapture) { if (capturingListeners == null) { capturingListeners = new HashTable(); } listeners = capturingListeners; } else { if (bubblingListeners == null) { bubblingListeners = new HashTable(); } listeners = bubblingListeners; } EventListenerList list = (EventListenerList) listeners.get(type); if (list == null) { list = new EventListenerList(); listeners.put(type, list); } list.addListener(namespaceURI, group, listener); }
/** * Gets an item in the table on the top of the stack. */ public String get(String s) { if (s.length() == 0) return current.defaultStr; for (Link l = current; l != null; l = l.next) { String uri = (String)l.table.get(s); if (uri != null) { return uri; } } return null; }
/** * Creates a mapping in the table on the top of the stack. */ public String put(String s, String v) { if (current.pushCount != 0) { current.pushCount--; current = new Link(current); } if (s.length() == 0) current.defaultStr = v; return (String)current.table.put(s, v); }
Object v = features.get(feature.toLowerCase()); if (v == null) { return false;
"Wrong xml-stylesheet data: " + data); table.put(ident.toString().intern(), value.toString()); i++;
/** * Returns whether this node target has an event listener for the * given event namespace URI and type. */ public boolean hasEventListenerNS(String namespaceURI, String type) { if (capturingListeners != null) { EventListenerList ell = (EventListenerList) capturingListeners.get(type); if (ell != null) { if (ell.hasEventListener(namespaceURI)) { return true; } } } if (bubblingListeners != null) { EventListenerList ell = (EventListenerList) capturingListeners.get(type); if (ell != null) { return ell.hasEventListener(namespaceURI); } } return false; }