Class EventListenersContainer

  • All Implemented Interfaces:
    java.io.Serializable

    public class EventListenersContainer
    extends java.lang.Object
    implements java.io.Serializable
    Container for event listener.
    See Also:
    Serialized Form
    • Constructor Detail

      • EventListenersContainer

        public EventListenersContainer​(EventTarget jsNode)
        The constructor.
        Parameters:
        jsNode - the node.
    • Method Detail

      • addEventListener

        public boolean addEventListener​(java.lang.String type,
                                        org.htmlunit.corejs.javascript.Scriptable listener,
                                        boolean useCapture)
        Adds an event listener.
        Parameters:
        type - the event type to listen for (like "load")
        listener - the event listener
        useCapture - If true, indicates that the user wishes to initiate capture (not yet implemented)
        Returns:
        true if the listener has been added
      • getListeners

        public java.util.List<org.htmlunit.corejs.javascript.Scriptable> getListeners​(java.lang.String eventType,
                                                                                      boolean useCapture)
        Returns the relevant listeners.
        Parameters:
        eventType - the event type
        useCapture - whether to use capture of not
        Returns:
        the listeners list (empty list when empty)
      • removeEventListener

        void removeEventListener​(java.lang.String eventType,
                                 org.htmlunit.corejs.javascript.Scriptable listener,
                                 boolean useCapture)
        Removes event listener.
        Parameters:
        eventType - the type
        listener - the listener
        useCapture - to use capture or not
      • setEventHandler

        public void setEventHandler​(java.lang.String eventType,
                                    java.lang.Object value)
        Sets the handler property (with a handler or something else).
        Parameters:
        eventType - the event type (like "click")
        value - the new property
      • executeEventListeners

        private void executeEventListeners​(int eventPhase,
                                           Event event,
                                           java.lang.Object[] args)
      • executeBubblingListeners

        public void executeBubblingListeners​(Event event,
                                             java.lang.Object[] args)
        Executes bubbling listeners.
        Parameters:
        event - the event
        args - arguments
      • executeCapturingListeners

        public void executeCapturingListeners​(Event event,
                                              java.lang.Object[] args)
        Executes capturing listeners.
        Parameters:
        event - the event
        args - the arguments
      • executeAtTargetListeners

        public void executeAtTargetListeners​(Event event,
                                             java.lang.Object[] args)
        Executes listeners for events targeting the node. (non-propagation phase)
        Parameters:
        event - the event
        args - the arguments
      • getEventHandler

        public org.htmlunit.corejs.javascript.Function getEventHandler​(java.lang.String eventType)
        Returns an event handler.
        Parameters:
        eventType - the event name (e.g. "click")
        Returns:
        the handler function, null if the property is null or not a function
      • hasEventListeners

        boolean hasEventListeners​(java.lang.String eventType)
        Returns true if there are any event listeners for the specified event.
        Parameters:
        eventType - the event type (e.g. "click")
        Returns:
        true if there are any event listeners for the specified event, false otherwise
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object