Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/w3c/dom/events/EventTarget.java
86410 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* This file is available under and governed by the GNU General Public26* License version 2 only, as published by the Free Software Foundation.27* However, the following notice accompanied the original version of this28* file and, per its terms, should not be removed:29*30* Copyright (c) 2000 World Wide Web Consortium,31* (Massachusetts Institute of Technology, Institut National de32* Recherche en Informatique et en Automatique, Keio University). All33* Rights Reserved. This program is distributed under the W3C's Software34* Intellectual Property License. This program is distributed in the35* hope that it will be useful, but WITHOUT ANY WARRANTY; without even36* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR37* PURPOSE.38* See W3C License http://www.w3.org/Consortium/Legal/ for more details.39*/4041package org.w3c.dom.events;4243/**44* The <code>EventTarget</code> interface is implemented by all45* <code>Nodes</code> in an implementation which supports the DOM Event46* Model. Therefore, this interface can be obtained by using47* binding-specific casting methods on an instance of the <code>Node</code>48* interface. The interface allows registration and removal of49* <code>EventListeners</code> on an <code>EventTarget</code> and dispatch50* of events to that <code>EventTarget</code>.51* <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113'>Document Object Model (DOM) Level 2 Events Specification</a>.52* @since DOM Level 253*/54public interface EventTarget {55/**56* This method allows the registration of event listeners on the event57* target. If an <code>EventListener</code> is added to an58* <code>EventTarget</code> while it is processing an event, it will not59* be triggered by the current actions but may be triggered during a60* later stage of event flow, such as the bubbling phase.61* <br> If multiple identical <code>EventListener</code>s are registered62* on the same <code>EventTarget</code> with the same parameters the63* duplicate instances are discarded. They do not cause the64* <code>EventListener</code> to be called twice and since they are65* discarded they do not need to be removed with the66* <code>removeEventListener</code> method.67* @param type The event type for which the user is registering68* @param listener The <code>listener</code> parameter takes an interface69* implemented by the user which contains the methods to be called70* when the event occurs.71* @param useCapture If true, <code>useCapture</code> indicates that the72* user wishes to initiate capture. After initiating capture, all73* events of the specified type will be dispatched to the registered74* <code>EventListener</code> before being dispatched to any75* <code>EventTargets</code> beneath them in the tree. Events which76* are bubbling upward through the tree will not trigger an77* <code>EventListener</code> designated to use capture.78*/79public void addEventListener(String type,80EventListener listener,81boolean useCapture);8283/**84* This method allows the removal of event listeners from the event85* target. If an <code>EventListener</code> is removed from an86* <code>EventTarget</code> while it is processing an event, it will not87* be triggered by the current actions. <code>EventListener</code>s can88* never be invoked after being removed.89* <br>Calling <code>removeEventListener</code> with arguments which do90* not identify any currently registered <code>EventListener</code> on91* the <code>EventTarget</code> has no effect.92* @param type Specifies the event type of the <code>EventListener</code>93* being removed.94* @param listener The <code>EventListener</code> parameter indicates the95* <code>EventListener </code> to be removed.96* @param useCapture Specifies whether the <code>EventListener</code>97* being removed was registered as a capturing listener or not. If a98* listener was registered twice, one with capture and one without,99* each must be removed separately. Removal of a capturing listener100* does not affect a non-capturing version of the same listener, and101* vice versa.102*/103public void removeEventListener(String type,104EventListener listener,105boolean useCapture);106107/**108* This method allows the dispatch of events into the implementations109* event model. Events dispatched in this manner will have the same110* capturing and bubbling behavior as events dispatched directly by the111* implementation. The target of the event is the112* <code> EventTarget</code> on which <code>dispatchEvent</code> is113* called.114* @param evt Specifies the event type, behavior, and contextual115* information to be used in processing the event.116* @return The return value of <code>dispatchEvent</code> indicates117* whether any of the listeners which handled the event called118* <code>preventDefault</code>. If <code>preventDefault</code> was119* called the value is false, else the value is true.120* @exception EventException121* UNSPECIFIED_EVENT_TYPE_ERR: Raised if the <code>Event</code>'s type122* was not specified by initializing the event before123* <code>dispatchEvent</code> was called. Specification of the124* <code>Event</code>'s type as <code>null</code> or an empty string125* will also trigger this exception.126*/127public boolean dispatchEvent(Event evt)128throws EventException;129130}131132133