1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
85 * notification method in the FooListener interface.
86 * <p>
87 * <strong>Warning:</strong>
88 * Serialized objects of this class will not be compatible with
89 * future Swing releases. The current serialization support is
90 * appropriate for short term storage or RMI between applications running
91 * the same version of Swing. As of 1.4, support for long term storage
92 * of all JavaBeans™
93 * has been added to the <code>java.beans</code> package.
94 * Please see {@link java.beans.XMLEncoder}.
95 *
96 * @author Georges Saab
97 * @author Hans Muller
98 * @author James Gosling
99 */
100 @SuppressWarnings("serial")
101 public class EventListenerList implements Serializable {
102 /* A null array to be shared by all empty listener lists*/
103 private static final Object[] NULL_ARRAY = new Object[0];
104 /** The list of ListenerType - Listener pairs */
105 protected transient Object[] listenerList = NULL_ARRAY;
106
107 /**
108 * Passes back the event listener list as an array
109 * of ListenerType-listener pairs. Note that for
110 * performance reasons, this implementation passes back
111 * the actual data structure in which the listener data
112 * is stored internally!
113 * This method is guaranteed to pass back a non-null
114 * array, so that no null-checking is required in
115 * fire methods. A zero-length array of Object should
116 * be returned if there are currently no listeners.
117 *
118 * WARNING!!! Absolutely NO modification of
119 * the data contained in this array should be made -- if
120 * any such manipulation is necessary, it should be done
121 * on a copy of the array returned rather than the array
122 * itself.
123 *
124 * @return array of ListenerType-listener pairs
125 */
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
85 * notification method in the FooListener interface.
86 * <p>
87 * <strong>Warning:</strong>
88 * Serialized objects of this class will not be compatible with
89 * future Swing releases. The current serialization support is
90 * appropriate for short term storage or RMI between applications running
91 * the same version of Swing. As of 1.4, support for long term storage
92 * of all JavaBeans™
93 * has been added to the <code>java.beans</code> package.
94 * Please see {@link java.beans.XMLEncoder}.
95 *
96 * @author Georges Saab
97 * @author Hans Muller
98 * @author James Gosling
99 */
100 @SuppressWarnings("serial")
101 public class EventListenerList implements Serializable {
102 /* A null array to be shared by all empty listener lists*/
103 private static final Object[] NULL_ARRAY = new Object[0];
104 /** The list of ListenerType - Listener pairs */
105 protected volatile transient Object[] listenerList = NULL_ARRAY;
106
107 /**
108 * Passes back the event listener list as an array
109 * of ListenerType-listener pairs. Note that for
110 * performance reasons, this implementation passes back
111 * the actual data structure in which the listener data
112 * is stored internally!
113 * This method is guaranteed to pass back a non-null
114 * array, so that no null-checking is required in
115 * fire methods. A zero-length array of Object should
116 * be returned if there are currently no listeners.
117 *
118 * WARNING!!! Absolutely NO modification of
119 * the data contained in this array should be made -- if
120 * any such manipulation is necessary, it should be done
121 * on a copy of the array returned rather than the array
122 * itself.
123 *
124 * @return array of ListenerType-listener pairs
125 */
|