author | serb |
Fri, 12 Feb 2016 16:09:39 +0300 | |
changeset 36451 | 0f5d1613d67d |
parent 35667 | ed476aba94de |
permissions | -rw-r--r-- |
2 | 1 |
/* |
19213 | 2 |
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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 |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
package java.beans; |
|
26 |
||
27 |
import java.io.Serializable; |
|
28 |
import java.io.ObjectStreamField; |
|
29 |
import java.io.ObjectOutputStream; |
|
30 |
import java.io.ObjectInputStream; |
|
31 |
import java.io.IOException; |
|
32 |
import java.util.Hashtable; |
|
33 |
import java.util.Map.Entry; |
|
34 |
||
35 |
/** |
|
36 |
* This is a utility class that can be used by beans that support bound |
|
1307
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
37 |
* properties. It manages a list of listeners and dispatches |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
38 |
* {@link PropertyChangeEvent}s to them. You can use an instance of this class |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
39 |
* as a member field of your bean and delegate these types of work to it. |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
40 |
* The {@link PropertyChangeListener} can be registered for all properties |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
41 |
* or for a property specified by name. |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
42 |
* <p> |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
43 |
* Here is an example of {@code PropertyChangeSupport} usage that follows |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
44 |
* the rules and recommendations laid out in the JavaBeans™ specification: |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
45 |
* <pre> |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
46 |
* public class MyBean { |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
47 |
* private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
48 |
* |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
49 |
* public void addPropertyChangeListener(PropertyChangeListener listener) { |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
50 |
* this.pcs.addPropertyChangeListener(listener); |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
51 |
* } |
2 | 52 |
* |
1307
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
53 |
* public void removePropertyChangeListener(PropertyChangeListener listener) { |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
54 |
* this.pcs.removePropertyChangeListener(listener); |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
55 |
* } |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
56 |
* |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
57 |
* private String value; |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
58 |
* |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
59 |
* public String getValue() { |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
60 |
* return this.value; |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
61 |
* } |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
62 |
* |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
63 |
* public void setValue(String newValue) { |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
64 |
* String oldValue = this.value; |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
65 |
* this.value = newValue; |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
66 |
* this.pcs.firePropertyChange("value", oldValue, newValue); |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
67 |
* } |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
68 |
* |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
69 |
* [...] |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
70 |
* } |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
71 |
* </pre> |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
72 |
* <p> |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
73 |
* A {@code PropertyChangeSupport} instance is thread-safe. |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
74 |
* <p> |
2 | 75 |
* This class is serializable. When it is serialized it will save |
76 |
* (and restore) any listeners that are themselves serializable. Any |
|
77 |
* non-serializable listeners will be skipped during serialization. |
|
1307
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
78 |
* |
7603aea0ec0e
5026703: RFE: DOC: Are PropertyChangeSupport & VetoableChangeSupport Thread-Safe? --Docs Should Say
malenkov
parents:
1292
diff
changeset
|
79 |
* @see VetoableChangeSupport |
25130
adfaa02ea516
8044855: Add missing @since tag under java.beans.*
henryjen
parents:
19213
diff
changeset
|
80 |
* @since 1.1 |
2 | 81 |
*/ |
82 |
public class PropertyChangeSupport implements Serializable { |
|
83 |
private PropertyChangeListenerMap map = new PropertyChangeListenerMap(); |
|
84 |
||
85 |
/** |
|
35667 | 86 |
* Constructs a {@code PropertyChangeSupport} object. |
2 | 87 |
* |
88 |
* @param sourceBean The bean to be given as the source for any events. |
|
89 |
*/ |
|
90 |
public PropertyChangeSupport(Object sourceBean) { |
|
91 |
if (sourceBean == null) { |
|
92 |
throw new NullPointerException(); |
|
93 |
} |
|
94 |
source = sourceBean; |
|
95 |
} |
|
96 |
||
97 |
/** |
|
98 |
* Add a PropertyChangeListener to the listener list. |
|
99 |
* The listener is registered for all properties. |
|
100 |
* The same listener object may be added more than once, and will be called |
|
101 |
* as many times as it is added. |
|
35667 | 102 |
* If {@code listener} is null, no exception is thrown and no action |
2 | 103 |
* is taken. |
104 |
* |
|
105 |
* @param listener The PropertyChangeListener to be added |
|
106 |
*/ |
|
107 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
108 |
if (listener == null) { |
|
109 |
return; |
|
110 |
} |
|
111 |
if (listener instanceof PropertyChangeListenerProxy) { |
|
112 |
PropertyChangeListenerProxy proxy = |
|
113 |
(PropertyChangeListenerProxy)listener; |
|
114 |
// Call two argument add method. |
|
115 |
addPropertyChangeListener(proxy.getPropertyName(), |
|
116 |
proxy.getListener()); |
|
117 |
} else { |
|
118 |
this.map.add(null, listener); |
|
119 |
} |
|
120 |
} |
|
121 |
||
122 |
/** |
|
123 |
* Remove a PropertyChangeListener from the listener list. |
|
124 |
* This removes a PropertyChangeListener that was registered |
|
125 |
* for all properties. |
|
35667 | 126 |
* If {@code listener} was added more than once to the same event |
2 | 127 |
* source, it will be notified one less time after being removed. |
35667 | 128 |
* If {@code listener} is null, or was never added, no exception is |
2 | 129 |
* thrown and no action is taken. |
130 |
* |
|
131 |
* @param listener The PropertyChangeListener to be removed |
|
132 |
*/ |
|
133 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
134 |
if (listener == null) { |
|
135 |
return; |
|
136 |
} |
|
137 |
if (listener instanceof PropertyChangeListenerProxy) { |
|
138 |
PropertyChangeListenerProxy proxy = |
|
139 |
(PropertyChangeListenerProxy)listener; |
|
140 |
// Call two argument remove method. |
|
141 |
removePropertyChangeListener(proxy.getPropertyName(), |
|
142 |
proxy.getListener()); |
|
143 |
} else { |
|
144 |
this.map.remove(null, listener); |
|
145 |
} |
|
146 |
} |
|
147 |
||
148 |
/** |
|
149 |
* Returns an array of all the listeners that were added to the |
|
150 |
* PropertyChangeSupport object with addPropertyChangeListener(). |
|
151 |
* <p> |
|
152 |
* If some listeners have been added with a named property, then |
|
153 |
* the returned array will be a mixture of PropertyChangeListeners |
|
35667 | 154 |
* and {@code PropertyChangeListenerProxy}s. If the calling |
2 | 155 |
* method is interested in distinguishing the listeners then it must |
156 |
* test each element to see if it's a |
|
35667 | 157 |
* {@code PropertyChangeListenerProxy}, perform the cast, and examine |
2 | 158 |
* the parameter. |
159 |
* |
|
19213 | 160 |
* <pre>{@code |
2 | 161 |
* PropertyChangeListener[] listeners = bean.getPropertyChangeListeners(); |
162 |
* for (int i = 0; i < listeners.length; i++) { |
|
163 |
* if (listeners[i] instanceof PropertyChangeListenerProxy) { |
|
164 |
* PropertyChangeListenerProxy proxy = |
|
165 |
* (PropertyChangeListenerProxy)listeners[i]; |
|
166 |
* if (proxy.getPropertyName().equals("foo")) { |
|
167 |
* // proxy is a PropertyChangeListener which was associated |
|
168 |
* // with the property named "foo" |
|
169 |
* } |
|
170 |
* } |
|
171 |
* } |
|
19213 | 172 |
* }</pre> |
2 | 173 |
* |
174 |
* @see PropertyChangeListenerProxy |
|
35667 | 175 |
* @return all of the {@code PropertyChangeListeners} added or an |
2 | 176 |
* empty array if no listeners have been added |
177 |
* @since 1.4 |
|
178 |
*/ |
|
179 |
public PropertyChangeListener[] getPropertyChangeListeners() { |
|
180 |
return this.map.getListeners(); |
|
181 |
} |
|
182 |
||
183 |
/** |
|
184 |
* Add a PropertyChangeListener for a specific property. The listener |
|
185 |
* will be invoked only when a call on firePropertyChange names that |
|
186 |
* specific property. |
|
187 |
* The same listener object may be added more than once. For each |
|
188 |
* property, the listener will be invoked the number of times it was added |
|
189 |
* for that property. |
|
35667 | 190 |
* If {@code propertyName} or {@code listener} is null, no |
2 | 191 |
* exception is thrown and no action is taken. |
192 |
* |
|
193 |
* @param propertyName The name of the property to listen on. |
|
194 |
* @param listener The PropertyChangeListener to be added |
|
25130
adfaa02ea516
8044855: Add missing @since tag under java.beans.*
henryjen
parents:
19213
diff
changeset
|
195 |
* @since 1.2 |
2 | 196 |
*/ |
197 |
public void addPropertyChangeListener( |
|
198 |
String propertyName, |
|
199 |
PropertyChangeListener listener) { |
|
200 |
if (listener == null || propertyName == null) { |
|
201 |
return; |
|
202 |
} |
|
203 |
listener = this.map.extract(listener); |
|
204 |
if (listener != null) { |
|
205 |
this.map.add(propertyName, listener); |
|
206 |
} |
|
207 |
} |
|
208 |
||
209 |
/** |
|
210 |
* Remove a PropertyChangeListener for a specific property. |
|
35667 | 211 |
* If {@code listener} was added more than once to the same event |
2 | 212 |
* source for the specified property, it will be notified one less time |
213 |
* after being removed. |
|
35667 | 214 |
* If {@code propertyName} is null, no exception is thrown and no |
2 | 215 |
* action is taken. |
35667 | 216 |
* If {@code listener} is null, or was never added for the specified |
2 | 217 |
* property, no exception is thrown and no action is taken. |
218 |
* |
|
219 |
* @param propertyName The name of the property that was listened on. |
|
220 |
* @param listener The PropertyChangeListener to be removed |
|
25130
adfaa02ea516
8044855: Add missing @since tag under java.beans.*
henryjen
parents:
19213
diff
changeset
|
221 |
* @since 1.2 |
2 | 222 |
*/ |
223 |
public void removePropertyChangeListener( |
|
224 |
String propertyName, |
|
225 |
PropertyChangeListener listener) { |
|
226 |
if (listener == null || propertyName == null) { |
|
227 |
return; |
|
228 |
} |
|
229 |
listener = this.map.extract(listener); |
|
230 |
if (listener != null) { |
|
231 |
this.map.remove(propertyName, listener); |
|
232 |
} |
|
233 |
} |
|
234 |
||
235 |
/** |
|
236 |
* Returns an array of all the listeners which have been associated |
|
237 |
* with the named property. |
|
238 |
* |
|
239 |
* @param propertyName The name of the property being listened to |
|
35667 | 240 |
* @return all of the {@code PropertyChangeListeners} associated with |
2 | 241 |
* the named property. If no such listeners have been added, |
35667 | 242 |
* or if {@code propertyName} is null, an empty array is |
2 | 243 |
* returned. |
244 |
* @since 1.4 |
|
245 |
*/ |
|
246 |
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { |
|
247 |
return this.map.getListeners(propertyName); |
|
248 |
} |
|
249 |
||
250 |
/** |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
251 |
* Reports a bound property update to listeners |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
252 |
* that have been registered to track updates of |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
253 |
* all properties or a property with the specified name. |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
254 |
* <p> |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
255 |
* No event is fired if old and new values are equal and non-null. |
2 | 256 |
* <p> |
257 |
* This is merely a convenience wrapper around the more general |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
258 |
* {@link #firePropertyChange(PropertyChangeEvent)} method. |
2 | 259 |
* |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
260 |
* @param propertyName the programmatic name of the property that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
261 |
* @param oldValue the old value of the property |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
262 |
* @param newValue the new value of the property |
2 | 263 |
*/ |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
264 |
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
265 |
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
266 |
firePropertyChange(new PropertyChangeEvent(this.source, propertyName, oldValue, newValue)); |
2 | 267 |
} |
268 |
} |
|
269 |
||
270 |
/** |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
271 |
* Reports an integer bound property update to listeners |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
272 |
* that have been registered to track updates of |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
273 |
* all properties or a property with the specified name. |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
274 |
* <p> |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
275 |
* No event is fired if old and new values are equal. |
2 | 276 |
* <p> |
277 |
* This is merely a convenience wrapper around the more general |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
278 |
* {@link #firePropertyChange(String, Object, Object)} method. |
2 | 279 |
* |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
280 |
* @param propertyName the programmatic name of the property that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
281 |
* @param oldValue the old value of the property |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
282 |
* @param newValue the new value of the property |
25130
adfaa02ea516
8044855: Add missing @since tag under java.beans.*
henryjen
parents:
19213
diff
changeset
|
283 |
* @since 1.2 |
2 | 284 |
*/ |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
285 |
public void firePropertyChange(String propertyName, int oldValue, int newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
286 |
if (oldValue != newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
287 |
firePropertyChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue)); |
2 | 288 |
} |
289 |
} |
|
290 |
||
291 |
/** |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
292 |
* Reports a boolean bound property update to listeners |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
293 |
* that have been registered to track updates of |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
294 |
* all properties or a property with the specified name. |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
295 |
* <p> |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
296 |
* No event is fired if old and new values are equal. |
2 | 297 |
* <p> |
298 |
* This is merely a convenience wrapper around the more general |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
299 |
* {@link #firePropertyChange(String, Object, Object)} method. |
2 | 300 |
* |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
301 |
* @param propertyName the programmatic name of the property that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
302 |
* @param oldValue the old value of the property |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
303 |
* @param newValue the new value of the property |
25130
adfaa02ea516
8044855: Add missing @since tag under java.beans.*
henryjen
parents:
19213
diff
changeset
|
304 |
* @since 1.2 |
2 | 305 |
*/ |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
306 |
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
307 |
if (oldValue != newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
308 |
firePropertyChange(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue)); |
2 | 309 |
} |
310 |
} |
|
311 |
||
312 |
/** |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
313 |
* Fires a property change event to listeners |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
314 |
* that have been registered to track updates of |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
315 |
* all properties or a property with the specified name. |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
316 |
* <p> |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
317 |
* No event is fired if the given event's old and new values are equal and non-null. |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
318 |
* |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
319 |
* @param event the {@code PropertyChangeEvent} to be fired |
25130
adfaa02ea516
8044855: Add missing @since tag under java.beans.*
henryjen
parents:
19213
diff
changeset
|
320 |
* @since 1.2 |
2 | 321 |
*/ |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
322 |
public void firePropertyChange(PropertyChangeEvent event) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
323 |
Object oldValue = event.getOldValue(); |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
324 |
Object newValue = event.getNewValue(); |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
325 |
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
326 |
String name = event.getPropertyName(); |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
327 |
|
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
328 |
PropertyChangeListener[] common = this.map.get(null); |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
329 |
PropertyChangeListener[] named = (name != null) |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
330 |
? this.map.get(name) |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
331 |
: null; |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
332 |
|
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
333 |
fire(common, event); |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
334 |
fire(named, event); |
2 | 335 |
} |
336 |
} |
|
337 |
||
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
338 |
private static void fire(PropertyChangeListener[] listeners, PropertyChangeEvent event) { |
2 | 339 |
if (listeners != null) { |
340 |
for (PropertyChangeListener listener : listeners) { |
|
341 |
listener.propertyChange(event); |
|
342 |
} |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
/** |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
347 |
* Reports a bound indexed property update to listeners |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
348 |
* that have been registered to track updates of |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
349 |
* all properties or a property with the specified name. |
2 | 350 |
* <p> |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
351 |
* No event is fired if old and new values are equal and non-null. |
2 | 352 |
* <p> |
353 |
* This is merely a convenience wrapper around the more general |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
354 |
* {@link #firePropertyChange(PropertyChangeEvent)} method. |
2 | 355 |
* |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
356 |
* @param propertyName the programmatic name of the property that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
357 |
* @param index the index of the property element that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
358 |
* @param oldValue the old value of the property |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
359 |
* @param newValue the new value of the property |
2 | 360 |
* @since 1.5 |
361 |
*/ |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
362 |
public void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
363 |
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
364 |
firePropertyChange(new IndexedPropertyChangeEvent(source, propertyName, oldValue, newValue, index)); |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
365 |
} |
2 | 366 |
} |
367 |
||
368 |
/** |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
369 |
* Reports an integer bound indexed property update to listeners |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
370 |
* that have been registered to track updates of |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
371 |
* all properties or a property with the specified name. |
2 | 372 |
* <p> |
373 |
* No event is fired if old and new values are equal. |
|
374 |
* <p> |
|
375 |
* This is merely a convenience wrapper around the more general |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
376 |
* {@link #fireIndexedPropertyChange(String, int, Object, Object)} method. |
2 | 377 |
* |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
378 |
* @param propertyName the programmatic name of the property that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
379 |
* @param index the index of the property element that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
380 |
* @param oldValue the old value of the property |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
381 |
* @param newValue the new value of the property |
2 | 382 |
* @since 1.5 |
383 |
*/ |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
384 |
public void fireIndexedPropertyChange(String propertyName, int index, int oldValue, int newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
385 |
if (oldValue != newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
386 |
fireIndexedPropertyChange(propertyName, index, Integer.valueOf(oldValue), Integer.valueOf(newValue)); |
2 | 387 |
} |
388 |
} |
|
389 |
||
390 |
/** |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
391 |
* Reports a boolean bound indexed property update to listeners |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
392 |
* that have been registered to track updates of |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
393 |
* all properties or a property with the specified name. |
2 | 394 |
* <p> |
395 |
* No event is fired if old and new values are equal. |
|
396 |
* <p> |
|
397 |
* This is merely a convenience wrapper around the more general |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
398 |
* {@link #fireIndexedPropertyChange(String, int, Object, Object)} method. |
2 | 399 |
* |
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
400 |
* @param propertyName the programmatic name of the property that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
401 |
* @param index the index of the property element that was changed |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
402 |
* @param oldValue the old value of the property |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
403 |
* @param newValue the new value of the property |
2 | 404 |
* @since 1.5 |
405 |
*/ |
|
1292
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
406 |
public void fireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
407 |
if (oldValue != newValue) { |
e91af84fbe9f
6630275: The spec on VetoableChangeSupport.fireVetoableChange should be updated
malenkov
parents:
2
diff
changeset
|
408 |
fireIndexedPropertyChange(propertyName, index, Boolean.valueOf(oldValue), Boolean.valueOf(newValue)); |
2 | 409 |
} |
410 |
} |
|
411 |
||
412 |
/** |
|
413 |
* Check if there are any listeners for a specific property, including |
|
35667 | 414 |
* those registered on all properties. If {@code propertyName} |
2 | 415 |
* is null, only check for listeners registered on all properties. |
416 |
* |
|
417 |
* @param propertyName the property name. |
|
418 |
* @return true if there are one or more listeners for the given property |
|
25130
adfaa02ea516
8044855: Add missing @since tag under java.beans.*
henryjen
parents:
19213
diff
changeset
|
419 |
* @since 1.2 |
2 | 420 |
*/ |
421 |
public boolean hasListeners(String propertyName) { |
|
422 |
return this.map.hasListeners(propertyName); |
|
423 |
} |
|
424 |
||
425 |
/** |
|
35667 | 426 |
* @serialData Null terminated list of {@code PropertyChangeListeners}. |
2 | 427 |
* <p> |
428 |
* At serialization time we skip non-serializable listeners and |
|
429 |
* only serialize the serializable listeners. |
|
430 |
*/ |
|
431 |
private void writeObject(ObjectOutputStream s) throws IOException { |
|
432 |
Hashtable<String, PropertyChangeSupport> children = null; |
|
433 |
PropertyChangeListener[] listeners = null; |
|
434 |
synchronized (this.map) { |
|
435 |
for (Entry<String, PropertyChangeListener[]> entry : this.map.getEntries()) { |
|
436 |
String property = entry.getKey(); |
|
437 |
if (property == null) { |
|
438 |
listeners = entry.getValue(); |
|
439 |
} else { |
|
440 |
if (children == null) { |
|
11120
f8576c769572
7116954: Misc warnings in java.beans/java.beans.context
mcimadamore
parents:
5506
diff
changeset
|
441 |
children = new Hashtable<>(); |
2 | 442 |
} |
443 |
PropertyChangeSupport pcs = new PropertyChangeSupport(this.source); |
|
444 |
pcs.map.set(null, entry.getValue()); |
|
445 |
children.put(property, pcs); |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
ObjectOutputStream.PutField fields = s.putFields(); |
|
450 |
fields.put("children", children); |
|
451 |
fields.put("source", this.source); |
|
452 |
fields.put("propertyChangeSupportSerializedDataVersion", 2); |
|
453 |
s.writeFields(); |
|
454 |
||
455 |
if (listeners != null) { |
|
456 |
for (PropertyChangeListener l : listeners) { |
|
457 |
if (l instanceof Serializable) { |
|
458 |
s.writeObject(l); |
|
459 |
} |
|
460 |
} |
|
461 |
} |
|
462 |
s.writeObject(null); |
|
463 |
} |
|
464 |
||
465 |
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { |
|
466 |
this.map = new PropertyChangeListenerMap(); |
|
467 |
||
468 |
ObjectInputStream.GetField fields = s.readFields(); |
|
469 |
||
11120
f8576c769572
7116954: Misc warnings in java.beans/java.beans.context
mcimadamore
parents:
5506
diff
changeset
|
470 |
@SuppressWarnings("unchecked") |
2 | 471 |
Hashtable<String, PropertyChangeSupport> children = (Hashtable<String, PropertyChangeSupport>) fields.get("children", null); |
472 |
this.source = fields.get("source", null); |
|
473 |
fields.get("propertyChangeSupportSerializedDataVersion", 2); |
|
474 |
||
475 |
Object listenerOrNull; |
|
476 |
while (null != (listenerOrNull = s.readObject())) { |
|
477 |
this.map.add(null, (PropertyChangeListener)listenerOrNull); |
|
478 |
} |
|
479 |
if (children != null) { |
|
480 |
for (Entry<String, PropertyChangeSupport> entry : children.entrySet()) { |
|
481 |
for (PropertyChangeListener listener : entry.getValue().getPropertyChangeListeners()) { |
|
482 |
this.map.add(entry.getKey(), listener); |
|
483 |
} |
|
484 |
} |
|
485 |
} |
|
486 |
} |
|
487 |
||
488 |
/** |
|
489 |
* The object to be provided as the "source" for any generated events. |
|
490 |
*/ |
|
491 |
private Object source; |
|
492 |
||
493 |
/** |
|
494 |
* @serialField children Hashtable |
|
495 |
* @serialField source Object |
|
496 |
* @serialField propertyChangeSupportSerializedDataVersion int |
|
497 |
*/ |
|
498 |
private static final ObjectStreamField[] serialPersistentFields = { |
|
499 |
new ObjectStreamField("children", Hashtable.class), |
|
500 |
new ObjectStreamField("source", Object.class), |
|
501 |
new ObjectStreamField("propertyChangeSupportSerializedDataVersion", Integer.TYPE) |
|
502 |
}; |
|
503 |
||
504 |
/** |
|
505 |
* Serialization version ID, so we're compatible with JDK 1.1 |
|
506 |
*/ |
|
507 |
static final long serialVersionUID = 6401253773779951803L; |
|
508 |
||
509 |
/** |
|
510 |
* This is a {@link ChangeListenerMap ChangeListenerMap} implementation |
|
511 |
* that works with {@link PropertyChangeListener PropertyChangeListener} objects. |
|
512 |
*/ |
|
513 |
private static final class PropertyChangeListenerMap extends ChangeListenerMap<PropertyChangeListener> { |
|
514 |
private static final PropertyChangeListener[] EMPTY = {}; |
|
515 |
||
516 |
/** |
|
517 |
* Creates an array of {@link PropertyChangeListener PropertyChangeListener} objects. |
|
518 |
* This method uses the same instance of the empty array |
|
519 |
* when {@code length} equals {@code 0}. |
|
520 |
* |
|
521 |
* @param length the array length |
|
522 |
* @return an array with specified length |
|
523 |
*/ |
|
524 |
@Override |
|
525 |
protected PropertyChangeListener[] newArray(int length) { |
|
526 |
return (0 < length) |
|
527 |
? new PropertyChangeListener[length] |
|
528 |
: EMPTY; |
|
529 |
} |
|
530 |
||
531 |
/** |
|
532 |
* Creates a {@link PropertyChangeListenerProxy PropertyChangeListenerProxy} |
|
533 |
* object for the specified property. |
|
534 |
* |
|
535 |
* @param name the name of the property to listen on |
|
536 |
* @param listener the listener to process events |
|
537 |
* @return a {@code PropertyChangeListenerProxy} object |
|
538 |
*/ |
|
539 |
@Override |
|
540 |
protected PropertyChangeListener newProxy(String name, PropertyChangeListener listener) { |
|
541 |
return new PropertyChangeListenerProxy(name, listener); |
|
542 |
} |
|
12032
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
543 |
|
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
544 |
/** |
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
545 |
* {@inheritDoc} |
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
546 |
*/ |
26004
7507a1b93f67
6521783: Unnecessary final modifier for a method in a final class
serb
parents:
25130
diff
changeset
|
547 |
public PropertyChangeListener extract(PropertyChangeListener listener) { |
12032
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
548 |
while (listener instanceof PropertyChangeListenerProxy) { |
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
549 |
listener = ((PropertyChangeListenerProxy) listener).getListener(); |
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
550 |
} |
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
551 |
return listener; |
49ac5a2b1d5c
7148143: PropertyChangeSupport.addPropertyChangeListener can throw ClassCastException
malenkov
parents:
11120
diff
changeset
|
552 |
} |
2 | 553 |
} |
554 |
} |