1 /*
2 * Copyright (c) 1996, 2012, 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
139 // Call two argument remove method.
140 removePropertyChangeListener(proxy.getPropertyName(),
141 proxy.getListener());
142 } else {
143 this.map.remove(null, listener);
144 }
145 }
146
147 /**
148 * Returns an array of all the listeners that were added to the
149 * PropertyChangeSupport object with addPropertyChangeListener().
150 * <p>
151 * If some listeners have been added with a named property, then
152 * the returned array will be a mixture of PropertyChangeListeners
153 * and <code>PropertyChangeListenerProxy</code>s. If the calling
154 * method is interested in distinguishing the listeners then it must
155 * test each element to see if it's a
156 * <code>PropertyChangeListenerProxy</code>, perform the cast, and examine
157 * the parameter.
158 *
159 * <pre>
160 * PropertyChangeListener[] listeners = bean.getPropertyChangeListeners();
161 * for (int i = 0; i < listeners.length; i++) {
162 * if (listeners[i] instanceof PropertyChangeListenerProxy) {
163 * PropertyChangeListenerProxy proxy =
164 * (PropertyChangeListenerProxy)listeners[i];
165 * if (proxy.getPropertyName().equals("foo")) {
166 * // proxy is a PropertyChangeListener which was associated
167 * // with the property named "foo"
168 * }
169 * }
170 * }
171 *</pre>
172 *
173 * @see PropertyChangeListenerProxy
174 * @return all of the <code>PropertyChangeListeners</code> added or an
175 * empty array if no listeners have been added
176 * @since 1.4
177 */
178 public PropertyChangeListener[] getPropertyChangeListeners() {
179 return this.map.getListeners();
180 }
181
182 /**
183 * Add a PropertyChangeListener for a specific property. The listener
184 * will be invoked only when a call on firePropertyChange names that
185 * specific property.
186 * The same listener object may be added more than once. For each
187 * property, the listener will be invoked the number of times it was added
188 * for that property.
189 * If <code>propertyName</code> or <code>listener</code> is null, no
190 * exception is thrown and no action is taken.
191 *
|
1 /*
2 * Copyright (c) 1996, 2013, 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
139 // Call two argument remove method.
140 removePropertyChangeListener(proxy.getPropertyName(),
141 proxy.getListener());
142 } else {
143 this.map.remove(null, listener);
144 }
145 }
146
147 /**
148 * Returns an array of all the listeners that were added to the
149 * PropertyChangeSupport object with addPropertyChangeListener().
150 * <p>
151 * If some listeners have been added with a named property, then
152 * the returned array will be a mixture of PropertyChangeListeners
153 * and <code>PropertyChangeListenerProxy</code>s. If the calling
154 * method is interested in distinguishing the listeners then it must
155 * test each element to see if it's a
156 * <code>PropertyChangeListenerProxy</code>, perform the cast, and examine
157 * the parameter.
158 *
159 * <pre>{@code
160 * PropertyChangeListener[] listeners = bean.getPropertyChangeListeners();
161 * for (int i = 0; i < listeners.length; i++) {
162 * if (listeners[i] instanceof PropertyChangeListenerProxy) {
163 * PropertyChangeListenerProxy proxy =
164 * (PropertyChangeListenerProxy)listeners[i];
165 * if (proxy.getPropertyName().equals("foo")) {
166 * // proxy is a PropertyChangeListener which was associated
167 * // with the property named "foo"
168 * }
169 * }
170 * }
171 * }</pre>
172 *
173 * @see PropertyChangeListenerProxy
174 * @return all of the <code>PropertyChangeListeners</code> added or an
175 * empty array if no listeners have been added
176 * @since 1.4
177 */
178 public PropertyChangeListener[] getPropertyChangeListeners() {
179 return this.map.getListeners();
180 }
181
182 /**
183 * Add a PropertyChangeListener for a specific property. The listener
184 * will be invoked only when a call on firePropertyChange names that
185 * specific property.
186 * The same listener object may be added more than once. For each
187 * property, the listener will be invoked the number of times it was added
188 * for that property.
189 * If <code>propertyName</code> or <code>listener</code> is null, no
190 * exception is thrown and no action is taken.
191 *
|