View Javadoc
1   /*
2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3    *
4    * This code is free software; you can redistribute it and/or modify it
5    * under the terms of the GNU General Public License version 2 only, as
6    * published by the Free Software Foundation.  Oracle designates this
7    * particular file as subject to the "Classpath" exception as provided
8    * by Oracle in the LICENSE file that accompanied this code.
9    *
10   * This code is distributed in the hope that it will be useful, but WITHOUT
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13   * version 2 for more details (a copy is included in the LICENSE file that
14   * accompanied this code).
15   *
16   * You should have received a copy of the GNU General Public License version
17   * 2 along with this work; if not, write to the Free Software Foundation,
18   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19   *
20   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21   * or visit www.oracle.com if you need additional information or have any
22   * questions.
23   */
24  
25  /*
26   * This file is available under and governed by the GNU General Public
27   * License version 2 only, as published by the Free Software Foundation.
28   * However, the following notice accompanied the original version of this
29   * file and, per its terms, should not be removed:
30   *
31   * Copyright (c) 2000 World Wide Web Consortium,
32   * (Massachusetts Institute of Technology, Institut National de
33   * Recherche en Informatique et en Automatique, Keio University). All
34   * Rights Reserved. This program is distributed under the W3C's Software
35   * Intellectual Property License. This program is distributed in the
36   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
37   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
38   * PURPOSE.
39   * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
40   */
41  
42  package org.w3c.dom.events;
43  
44  /**
45   * The <code>Event</code> interface is used to provide contextual information
46   * about an event to the handler processing the event. An object which
47   * implements the <code>Event</code> interface is generally passed as the
48   * first parameter to an event handler. More specific context information is
49   * passed to event handlers by deriving additional interfaces from
50   * <code>Event</code> which contain information directly relating to the
51   * type of event they accompany. These derived interfaces are also
52   * implemented by the object passed to the event listener.
53   * <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>.
54   * @since DOM Level 2
55   */
56  public interface Event {
57      // PhaseType
58      /**
59       * The current event phase is the capturing phase.
60       */
61      public static final short CAPTURING_PHASE           = 1;
62      /**
63       * The event is currently being evaluated at the target
64       * <code>EventTarget</code>.
65       */
66      public static final short AT_TARGET                 = 2;
67      /**
68       * The current event phase is the bubbling phase.
69       */
70      public static final short BUBBLING_PHASE            = 3;
71  
72      /**
73       * The name of the event (case-insensitive). The name must be an XML name.
74       */
75      public String getType();
76  
77      /**
78       * Used to indicate the <code>EventTarget</code> to which the event was
79       * originally dispatched.
80       */
81      public EventTarget getTarget();
82  
83      /**
84       * Used to indicate the <code>EventTarget</code> whose
85       * <code>EventListeners</code> are currently being processed. This is
86       * particularly useful during capturing and bubbling.
87       */
88      public EventTarget getCurrentTarget();
89  
90      /**
91       * Used to indicate which phase of event flow is currently being
92       * evaluated.
93       */
94      public short getEventPhase();
95  
96      /**
97       * Used to indicate whether or not an event is a bubbling event. If the
98       * event can bubble the value is true, else the value is false.
99       */
100     public boolean getBubbles();
101 
102     /**
103      * Used to indicate whether or not an event can have its default action
104      * prevented. If the default action can be prevented the value is true,
105      * else the value is false.
106      */
107     public boolean getCancelable();
108 
109     /**
110      *  Used to specify the time (in milliseconds relative to the epoch) at
111      * which the event was created. Due to the fact that some systems may
112      * not provide this information the value of <code>timeStamp</code> may
113      * be not available for all events. When not available, a value of 0
114      * will be returned. Examples of epoch time are the time of the system
115      * start or 0:0:0 UTC 1st January 1970.
116      */
117     public long getTimeStamp();
118 
119     /**
120      * The <code>stopPropagation</code> method is used prevent further
121      * propagation of an event during event flow. If this method is called
122      * by any <code>EventListener</code> the event will cease propagating
123      * through the tree. The event will complete dispatch to all listeners
124      * on the current <code>EventTarget</code> before event flow stops. This
125      * method may be used during any stage of event flow.
126      */
127     public void stopPropagation();
128 
129     /**
130      * If an event is cancelable, the <code>preventDefault</code> method is
131      * used to signify that the event is to be canceled, meaning any default
132      * action normally taken by the implementation as a result of the event
133      * will not occur. If, during any stage of event flow, the
134      * <code>preventDefault</code> method is called the event is canceled.
135      * Any default action associated with the event will not occur. Calling
136      * this method for a non-cancelable event has no effect. Once
137      * <code>preventDefault</code> has been called it will remain in effect
138      * throughout the remainder of the event's propagation. This method may
139      * be used during any stage of event flow.
140      */
141     public void preventDefault();
142 
143     /**
144      * The <code>initEvent</code> method is used to initialize the value of an
145      * <code>Event</code> created through the <code>DocumentEvent</code>
146      * interface. This method may only be called before the
147      * <code>Event</code> has been dispatched via the
148      * <code>dispatchEvent</code> method, though it may be called multiple
149      * times during that phase if necessary. If called multiple times the
150      * final invocation takes precedence. If called from a subclass of
151      * <code>Event</code> interface only the values specified in the
152      * <code>initEvent</code> method are modified, all other attributes are
153      * left unchanged.
154      * @param eventTypeArg Specifies the event type. This type may be any
155      *   event type currently defined in this specification or a new event
156      *   type.. The string must be an XML name. Any new event type must not
157      *   begin with any upper, lower, or mixed case version of the string
158      *   "DOM". This prefix is reserved for future DOM event sets. It is
159      *   also strongly recommended that third parties adding their own
160      *   events use their own prefix to avoid confusion and lessen the
161      *   probability of conflicts with other new events.
162      * @param canBubbleArg Specifies whether or not the event can bubble.
163      * @param cancelableArg Specifies whether or not the event's default
164      *   action can be prevented.
165      */
166     public void initEvent(String eventTypeArg,
167                           boolean canBubbleArg,
168                           boolean cancelableArg);
169 
170 }