author | lana |
Tue, 01 Jun 2010 14:17:38 -0700 | |
changeset 5597 | ab490f66d2cf |
parent 5506 | 202f599c92aa |
child 5947 | 0e6f2837eeca |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1996, 2010, 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 |
||
26 |
package java.beans; |
|
27 |
||
28 |
import java.lang.ref.Reference; |
|
29 |
import java.lang.reflect.Method; |
|
30 |
||
31 |
/** |
|
32 |
* An IndexedPropertyDescriptor describes a property that acts like an |
|
33 |
* array and has an indexed read and/or indexed write method to access |
|
34 |
* specific elements of the array. |
|
35 |
* <p> |
|
36 |
* An indexed property may also provide simple non-indexed read and write |
|
37 |
* methods. If these are present, they read and write arrays of the type |
|
38 |
* returned by the indexed read method. |
|
39 |
*/ |
|
40 |
||
41 |
public class IndexedPropertyDescriptor extends PropertyDescriptor { |
|
42 |
||
43 |
private Reference<Class> indexedPropertyTypeRef; |
|
44 |
private Reference<Method> indexedReadMethodRef; |
|
45 |
private Reference<Method> indexedWriteMethodRef; |
|
46 |
||
47 |
private String indexedReadMethodName; |
|
48 |
private String indexedWriteMethodName; |
|
49 |
||
50 |
/** |
|
51 |
* This constructor constructs an IndexedPropertyDescriptor for a property |
|
52 |
* that follows the standard Java conventions by having getFoo and setFoo |
|
53 |
* accessor methods, for both indexed access and array access. |
|
54 |
* <p> |
|
55 |
* Thus if the argument name is "fred", it will assume that there |
|
56 |
* is an indexed reader method "getFred", a non-indexed (array) reader |
|
57 |
* method also called "getFred", an indexed writer method "setFred", |
|
58 |
* and finally a non-indexed writer method "setFred". |
|
59 |
* |
|
60 |
* @param propertyName The programmatic name of the property. |
|
61 |
* @param beanClass The Class object for the target bean. |
|
62 |
* @exception IntrospectionException if an exception occurs during |
|
63 |
* introspection. |
|
64 |
*/ |
|
65 |
public IndexedPropertyDescriptor(String propertyName, Class<?> beanClass) |
|
66 |
throws IntrospectionException { |
|
67 |
this(propertyName, beanClass, |
|
68 |
Introspector.GET_PREFIX + NameGenerator.capitalize(propertyName), |
|
69 |
Introspector.SET_PREFIX + NameGenerator.capitalize(propertyName), |
|
70 |
Introspector.GET_PREFIX + NameGenerator.capitalize(propertyName), |
|
71 |
Introspector.SET_PREFIX + NameGenerator.capitalize(propertyName)); |
|
72 |
} |
|
73 |
||
74 |
/** |
|
75 |
* This constructor takes the name of a simple property, and method |
|
76 |
* names for reading and writing the property, both indexed |
|
77 |
* and non-indexed. |
|
78 |
* |
|
79 |
* @param propertyName The programmatic name of the property. |
|
80 |
* @param beanClass The Class object for the target bean. |
|
81 |
* @param readMethodName The name of the method used for reading the property |
|
82 |
* values as an array. May be null if the property is write-only |
|
83 |
* or must be indexed. |
|
84 |
* @param writeMethodName The name of the method used for writing the property |
|
85 |
* values as an array. May be null if the property is read-only |
|
86 |
* or must be indexed. |
|
87 |
* @param indexedReadMethodName The name of the method used for reading |
|
88 |
* an indexed property value. |
|
89 |
* May be null if the property is write-only. |
|
90 |
* @param indexedWriteMethodName The name of the method used for writing |
|
91 |
* an indexed property value. |
|
92 |
* May be null if the property is read-only. |
|
93 |
* @exception IntrospectionException if an exception occurs during |
|
94 |
* introspection. |
|
95 |
*/ |
|
96 |
public IndexedPropertyDescriptor(String propertyName, Class<?> beanClass, |
|
97 |
String readMethodName, String writeMethodName, |
|
98 |
String indexedReadMethodName, String indexedWriteMethodName) |
|
99 |
throws IntrospectionException { |
|
100 |
super(propertyName, beanClass, readMethodName, writeMethodName); |
|
101 |
||
102 |
this.indexedReadMethodName = indexedReadMethodName; |
|
103 |
if (indexedReadMethodName != null && getIndexedReadMethod() == null) { |
|
104 |
throw new IntrospectionException("Method not found: " + indexedReadMethodName); |
|
105 |
} |
|
106 |
||
107 |
this.indexedWriteMethodName = indexedWriteMethodName; |
|
108 |
if (indexedWriteMethodName != null && getIndexedWriteMethod() == null) { |
|
109 |
throw new IntrospectionException("Method not found: " + indexedWriteMethodName); |
|
110 |
} |
|
111 |
// Implemented only for type checking. |
|
112 |
findIndexedPropertyType(getIndexedReadMethod(), getIndexedWriteMethod()); |
|
113 |
} |
|
114 |
||
115 |
/** |
|
116 |
* This constructor takes the name of a simple property, and Method |
|
117 |
* objects for reading and writing the property. |
|
118 |
* |
|
4960
99ac74ca2f2f
4498236: RFE: Provide a toString method for PropertyChangeEvent and other classes
malenkov
parents:
4392
diff
changeset
|
119 |
* @param propertyName The programmatic name of the property. |
2 | 120 |
* @param readMethod The method used for reading the property values as an array. |
121 |
* May be null if the property is write-only or must be indexed. |
|
122 |
* @param writeMethod The method used for writing the property values as an array. |
|
123 |
* May be null if the property is read-only or must be indexed. |
|
124 |
* @param indexedReadMethod The method used for reading an indexed property value. |
|
125 |
* May be null if the property is write-only. |
|
126 |
* @param indexedWriteMethod The method used for writing an indexed property value. |
|
127 |
* May be null if the property is read-only. |
|
128 |
* @exception IntrospectionException if an exception occurs during |
|
129 |
* introspection. |
|
130 |
*/ |
|
131 |
public IndexedPropertyDescriptor(String propertyName, Method readMethod, Method writeMethod, |
|
132 |
Method indexedReadMethod, Method indexedWriteMethod) |
|
133 |
throws IntrospectionException { |
|
134 |
super(propertyName, readMethod, writeMethod); |
|
135 |
||
136 |
setIndexedReadMethod0(indexedReadMethod); |
|
137 |
setIndexedWriteMethod0(indexedWriteMethod); |
|
138 |
||
139 |
// Type checking |
|
140 |
setIndexedPropertyType(findIndexedPropertyType(indexedReadMethod, indexedWriteMethod)); |
|
141 |
} |
|
142 |
||
143 |
/** |
|
144 |
* Creates <code>PropertyDescriptor</code> for the specified bean |
|
145 |
* with the specified name and methods to read/write the property value. |
|
146 |
* |
|
147 |
* @param bean the type of the target bean |
|
148 |
* @param base the base name of the property (the rest of the method name) |
|
149 |
* @param read the method used for reading the property value |
|
150 |
* @param write the method used for writing the property value |
|
151 |
* @param readIndexed the method used for reading an indexed property value |
|
152 |
* @param writeIndexed the method used for writing an indexed property value |
|
153 |
* @exception IntrospectionException if an exception occurs during introspection |
|
154 |
* |
|
155 |
* @since 1.7 |
|
156 |
*/ |
|
157 |
IndexedPropertyDescriptor(Class<?> bean, String base, Method read, Method write, Method readIndexed, Method writeIndexed) throws IntrospectionException { |
|
158 |
super(bean, base, read, write); |
|
159 |
||
160 |
setIndexedReadMethod0(readIndexed); |
|
161 |
setIndexedWriteMethod0(writeIndexed); |
|
162 |
||
163 |
// Type checking |
|
164 |
setIndexedPropertyType(findIndexedPropertyType(readIndexed, writeIndexed)); |
|
165 |
} |
|
166 |
||
167 |
/** |
|
168 |
* Gets the method that should be used to read an indexed |
|
169 |
* property value. |
|
170 |
* |
|
171 |
* @return The method that should be used to read an indexed |
|
172 |
* property value. |
|
173 |
* May return null if the property isn't indexed or is write-only. |
|
174 |
*/ |
|
175 |
public synchronized Method getIndexedReadMethod() { |
|
176 |
Method indexedReadMethod = getIndexedReadMethod0(); |
|
177 |
if (indexedReadMethod == null) { |
|
178 |
Class cls = getClass0(); |
|
179 |
if (cls == null || |
|
180 |
(indexedReadMethodName == null && indexedReadMethodRef == null)) { |
|
181 |
// the Indexed readMethod was explicitly set to null. |
|
182 |
return null; |
|
183 |
} |
|
184 |
if (indexedReadMethodName == null) { |
|
185 |
Class type = getIndexedPropertyType0(); |
|
186 |
if (type == boolean.class || type == null) { |
|
187 |
indexedReadMethodName = Introspector.IS_PREFIX + getBaseName(); |
|
188 |
} else { |
|
189 |
indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
Class[] args = { int.class }; |
|
194 |
||
195 |
indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, |
|
196 |
1, args); |
|
197 |
if (indexedReadMethod == null) { |
|
198 |
// no "is" method, so look for a "get" method. |
|
199 |
indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); |
|
200 |
indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, |
|
201 |
1, args); |
|
202 |
} |
|
203 |
setIndexedReadMethod0(indexedReadMethod); |
|
204 |
} |
|
205 |
return indexedReadMethod; |
|
206 |
} |
|
207 |
||
208 |
/** |
|
209 |
* Sets the method that should be used to read an indexed property value. |
|
210 |
* |
|
211 |
* @param readMethod The new indexed read method. |
|
212 |
*/ |
|
213 |
public synchronized void setIndexedReadMethod(Method readMethod) |
|
214 |
throws IntrospectionException { |
|
215 |
||
216 |
// the indexed property type is set by the reader. |
|
217 |
setIndexedPropertyType(findIndexedPropertyType(readMethod, |
|
218 |
getIndexedWriteMethod0())); |
|
219 |
setIndexedReadMethod0(readMethod); |
|
220 |
} |
|
221 |
||
222 |
private void setIndexedReadMethod0(Method readMethod) { |
|
223 |
if (readMethod == null) { |
|
224 |
indexedReadMethodName = null; |
|
225 |
indexedReadMethodRef = null; |
|
226 |
return; |
|
227 |
} |
|
228 |
setClass0(readMethod.getDeclaringClass()); |
|
229 |
||
230 |
indexedReadMethodName = readMethod.getName(); |
|
231 |
this.indexedReadMethodRef = getSoftReference(readMethod); |
|
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
232 |
setTransient(readMethod.getAnnotation(Transient.class)); |
2 | 233 |
} |
234 |
||
235 |
||
236 |
/** |
|
237 |
* Gets the method that should be used to write an indexed property value. |
|
238 |
* |
|
239 |
* @return The method that should be used to write an indexed |
|
240 |
* property value. |
|
241 |
* May return null if the property isn't indexed or is read-only. |
|
242 |
*/ |
|
243 |
public synchronized Method getIndexedWriteMethod() { |
|
244 |
Method indexedWriteMethod = getIndexedWriteMethod0(); |
|
245 |
if (indexedWriteMethod == null) { |
|
246 |
Class cls = getClass0(); |
|
247 |
if (cls == null || |
|
248 |
(indexedWriteMethodName == null && indexedWriteMethodRef == null)) { |
|
249 |
// the Indexed writeMethod was explicitly set to null. |
|
250 |
return null; |
|
251 |
} |
|
252 |
||
253 |
// We need the indexed type to ensure that we get the correct method. |
|
254 |
// Cannot use the getIndexedPropertyType method since that could |
|
255 |
// result in an infinite loop. |
|
256 |
Class type = getIndexedPropertyType0(); |
|
257 |
if (type == null) { |
|
258 |
try { |
|
259 |
type = findIndexedPropertyType(getIndexedReadMethod(), null); |
|
260 |
setIndexedPropertyType(type); |
|
261 |
} catch (IntrospectionException ex) { |
|
262 |
// Set iprop type to be the classic type |
|
263 |
Class propType = getPropertyType(); |
|
264 |
if (propType.isArray()) { |
|
265 |
type = propType.getComponentType(); |
|
266 |
} |
|
267 |
} |
|
268 |
} |
|
269 |
||
270 |
if (indexedWriteMethodName == null) { |
|
271 |
indexedWriteMethodName = Introspector.SET_PREFIX + getBaseName(); |
|
272 |
} |
|
273 |
indexedWriteMethod = Introspector.findMethod(cls, indexedWriteMethodName, |
|
274 |
2, (type == null) ? null : new Class[] { int.class, type }); |
|
3241
6fd229e009e7
6723447: Introspector doesn't check return type for indexed property setters
malenkov
parents:
466
diff
changeset
|
275 |
if (indexedWriteMethod != null) { |
6fd229e009e7
6723447: Introspector doesn't check return type for indexed property setters
malenkov
parents:
466
diff
changeset
|
276 |
if (!indexedWriteMethod.getReturnType().equals(void.class)) { |
6fd229e009e7
6723447: Introspector doesn't check return type for indexed property setters
malenkov
parents:
466
diff
changeset
|
277 |
indexedWriteMethod = null; |
6fd229e009e7
6723447: Introspector doesn't check return type for indexed property setters
malenkov
parents:
466
diff
changeset
|
278 |
} |
6fd229e009e7
6723447: Introspector doesn't check return type for indexed property setters
malenkov
parents:
466
diff
changeset
|
279 |
} |
2 | 280 |
setIndexedWriteMethod0(indexedWriteMethod); |
281 |
} |
|
282 |
return indexedWriteMethod; |
|
283 |
} |
|
284 |
||
285 |
/** |
|
286 |
* Sets the method that should be used to write an indexed property value. |
|
287 |
* |
|
288 |
* @param writeMethod The new indexed write method. |
|
289 |
*/ |
|
290 |
public synchronized void setIndexedWriteMethod(Method writeMethod) |
|
291 |
throws IntrospectionException { |
|
292 |
||
293 |
// If the indexed property type has not been set, then set it. |
|
294 |
Class type = findIndexedPropertyType(getIndexedReadMethod(), |
|
295 |
writeMethod); |
|
296 |
setIndexedPropertyType(type); |
|
297 |
setIndexedWriteMethod0(writeMethod); |
|
298 |
} |
|
299 |
||
300 |
private void setIndexedWriteMethod0(Method writeMethod) { |
|
301 |
if (writeMethod == null) { |
|
302 |
indexedWriteMethodName = null; |
|
303 |
indexedWriteMethodRef = null; |
|
304 |
return; |
|
305 |
} |
|
306 |
setClass0(writeMethod.getDeclaringClass()); |
|
307 |
||
308 |
indexedWriteMethodName = writeMethod.getName(); |
|
309 |
this.indexedWriteMethodRef = getSoftReference(writeMethod); |
|
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
310 |
setTransient(writeMethod.getAnnotation(Transient.class)); |
2 | 311 |
} |
312 |
||
313 |
/** |
|
4392
4a92100685fa
4638075: DOC: Doc for java.beans.PropertyDescriptor.getPropertyType() is incorrect.
malenkov
parents:
3241
diff
changeset
|
314 |
* Returns the Java type info for the indexed property. |
4a92100685fa
4638075: DOC: Doc for java.beans.PropertyDescriptor.getPropertyType() is incorrect.
malenkov
parents:
3241
diff
changeset
|
315 |
* Note that the {@code Class} object may describe |
4a92100685fa
4638075: DOC: Doc for java.beans.PropertyDescriptor.getPropertyType() is incorrect.
malenkov
parents:
3241
diff
changeset
|
316 |
* primitive Java types such as {@code int}. |
4a92100685fa
4638075: DOC: Doc for java.beans.PropertyDescriptor.getPropertyType() is incorrect.
malenkov
parents:
3241
diff
changeset
|
317 |
* This type is returned by the indexed read method |
4a92100685fa
4638075: DOC: Doc for java.beans.PropertyDescriptor.getPropertyType() is incorrect.
malenkov
parents:
3241
diff
changeset
|
318 |
* or is used as the parameter type of the indexed write method. |
2 | 319 |
* |
4392
4a92100685fa
4638075: DOC: Doc for java.beans.PropertyDescriptor.getPropertyType() is incorrect.
malenkov
parents:
3241
diff
changeset
|
320 |
* @return the {@code Class} object that represents the Java type info, |
4a92100685fa
4638075: DOC: Doc for java.beans.PropertyDescriptor.getPropertyType() is incorrect.
malenkov
parents:
3241
diff
changeset
|
321 |
* or {@code null} if the type cannot be determined |
2 | 322 |
*/ |
323 |
public synchronized Class<?> getIndexedPropertyType() { |
|
324 |
Class type = getIndexedPropertyType0(); |
|
325 |
if (type == null) { |
|
326 |
try { |
|
327 |
type = findIndexedPropertyType(getIndexedReadMethod(), |
|
328 |
getIndexedWriteMethod()); |
|
329 |
setIndexedPropertyType(type); |
|
330 |
} catch (IntrospectionException ex) { |
|
331 |
// fall |
|
332 |
} |
|
333 |
} |
|
334 |
return type; |
|
335 |
} |
|
336 |
||
337 |
// Private methods which set get/set the Reference objects |
|
338 |
||
339 |
private void setIndexedPropertyType(Class type) { |
|
340 |
this.indexedPropertyTypeRef = getWeakReference(type); |
|
341 |
} |
|
342 |
||
343 |
private Class getIndexedPropertyType0() { |
|
344 |
return (this.indexedPropertyTypeRef != null) |
|
345 |
? this.indexedPropertyTypeRef.get() |
|
346 |
: null; |
|
347 |
} |
|
348 |
||
349 |
private Method getIndexedReadMethod0() { |
|
350 |
return (this.indexedReadMethodRef != null) |
|
351 |
? this.indexedReadMethodRef.get() |
|
352 |
: null; |
|
353 |
} |
|
354 |
||
355 |
private Method getIndexedWriteMethod0() { |
|
356 |
return (this.indexedWriteMethodRef != null) |
|
357 |
? this.indexedWriteMethodRef.get() |
|
358 |
: null; |
|
359 |
} |
|
360 |
||
361 |
private Class findIndexedPropertyType(Method indexedReadMethod, |
|
362 |
Method indexedWriteMethod) |
|
363 |
throws IntrospectionException { |
|
364 |
Class indexedPropertyType = null; |
|
365 |
||
366 |
if (indexedReadMethod != null) { |
|
367 |
Class params[] = getParameterTypes(getClass0(), indexedReadMethod); |
|
368 |
if (params.length != 1) { |
|
369 |
throw new IntrospectionException("bad indexed read method arg count"); |
|
370 |
} |
|
371 |
if (params[0] != Integer.TYPE) { |
|
372 |
throw new IntrospectionException("non int index to indexed read method"); |
|
373 |
} |
|
374 |
indexedPropertyType = getReturnType(getClass0(), indexedReadMethod); |
|
375 |
if (indexedPropertyType == Void.TYPE) { |
|
376 |
throw new IntrospectionException("indexed read method returns void"); |
|
377 |
} |
|
378 |
} |
|
379 |
if (indexedWriteMethod != null) { |
|
380 |
Class params[] = getParameterTypes(getClass0(), indexedWriteMethod); |
|
381 |
if (params.length != 2) { |
|
382 |
throw new IntrospectionException("bad indexed write method arg count"); |
|
383 |
} |
|
384 |
if (params[0] != Integer.TYPE) { |
|
385 |
throw new IntrospectionException("non int index to indexed write method"); |
|
386 |
} |
|
387 |
if (indexedPropertyType != null && indexedPropertyType != params[1]) { |
|
388 |
throw new IntrospectionException( |
|
389 |
"type mismatch between indexed read and indexed write methods: " |
|
390 |
+ getName()); |
|
391 |
} |
|
392 |
indexedPropertyType = params[1]; |
|
393 |
} |
|
394 |
Class propertyType = getPropertyType(); |
|
395 |
if (propertyType != null && (!propertyType.isArray() || |
|
396 |
propertyType.getComponentType() != indexedPropertyType)) { |
|
397 |
throw new IntrospectionException("type mismatch between indexed and non-indexed methods: " |
|
398 |
+ getName()); |
|
399 |
} |
|
400 |
return indexedPropertyType; |
|
401 |
} |
|
402 |
||
403 |
/** |
|
404 |
* Compares this <code>PropertyDescriptor</code> against the specified object. |
|
405 |
* Returns true if the objects are the same. Two <code>PropertyDescriptor</code>s |
|
406 |
* are the same if the read, write, property types, property editor and |
|
407 |
* flags are equivalent. |
|
408 |
* |
|
409 |
* @since 1.4 |
|
410 |
*/ |
|
411 |
public boolean equals(Object obj) { |
|
412 |
// Note: This would be identical to PropertyDescriptor but they don't |
|
413 |
// share the same fields. |
|
414 |
if (this == obj) { |
|
415 |
return true; |
|
416 |
} |
|
417 |
||
418 |
if (obj != null && obj instanceof IndexedPropertyDescriptor) { |
|
419 |
IndexedPropertyDescriptor other = (IndexedPropertyDescriptor)obj; |
|
420 |
Method otherIndexedReadMethod = other.getIndexedReadMethod(); |
|
421 |
Method otherIndexedWriteMethod = other.getIndexedWriteMethod(); |
|
422 |
||
423 |
if (!compareMethods(getIndexedReadMethod(), otherIndexedReadMethod)) { |
|
424 |
return false; |
|
425 |
} |
|
426 |
||
427 |
if (!compareMethods(getIndexedWriteMethod(), otherIndexedWriteMethod)) { |
|
428 |
return false; |
|
429 |
} |
|
430 |
||
431 |
if (getIndexedPropertyType() != other.getIndexedPropertyType()) { |
|
432 |
return false; |
|
433 |
} |
|
434 |
return super.equals(obj); |
|
435 |
} |
|
436 |
return false; |
|
437 |
} |
|
438 |
||
439 |
/** |
|
440 |
* Package-private constructor. |
|
441 |
* Merge two property descriptors. Where they conflict, give the |
|
442 |
* second argument (y) priority over the first argumnnt (x). |
|
443 |
* |
|
444 |
* @param x The first (lower priority) PropertyDescriptor |
|
445 |
* @param y The second (higher priority) PropertyDescriptor |
|
446 |
*/ |
|
447 |
||
448 |
IndexedPropertyDescriptor(PropertyDescriptor x, PropertyDescriptor y) { |
|
449 |
super(x,y); |
|
450 |
if (x instanceof IndexedPropertyDescriptor) { |
|
451 |
IndexedPropertyDescriptor ix = (IndexedPropertyDescriptor)x; |
|
452 |
try { |
|
453 |
Method xr = ix.getIndexedReadMethod(); |
|
454 |
if (xr != null) { |
|
455 |
setIndexedReadMethod(xr); |
|
456 |
} |
|
457 |
||
458 |
Method xw = ix.getIndexedWriteMethod(); |
|
459 |
if (xw != null) { |
|
460 |
setIndexedWriteMethod(xw); |
|
461 |
} |
|
462 |
} catch (IntrospectionException ex) { |
|
463 |
// Should not happen |
|
464 |
throw new AssertionError(ex); |
|
465 |
} |
|
466 |
} |
|
467 |
if (y instanceof IndexedPropertyDescriptor) { |
|
468 |
IndexedPropertyDescriptor iy = (IndexedPropertyDescriptor)y; |
|
469 |
try { |
|
470 |
Method yr = iy.getIndexedReadMethod(); |
|
471 |
if (yr != null && yr.getDeclaringClass() == getClass0()) { |
|
472 |
setIndexedReadMethod(yr); |
|
473 |
} |
|
474 |
||
475 |
Method yw = iy.getIndexedWriteMethod(); |
|
476 |
if (yw != null && yw.getDeclaringClass() == getClass0()) { |
|
477 |
setIndexedWriteMethod(yw); |
|
478 |
} |
|
479 |
} catch (IntrospectionException ex) { |
|
480 |
// Should not happen |
|
481 |
throw new AssertionError(ex); |
|
482 |
} |
|
483 |
} |
|
484 |
} |
|
485 |
||
486 |
/* |
|
487 |
* Package-private dup constructor |
|
488 |
* This must isolate the new object from any changes to the old object. |
|
489 |
*/ |
|
490 |
IndexedPropertyDescriptor(IndexedPropertyDescriptor old) { |
|
491 |
super(old); |
|
492 |
indexedReadMethodRef = old.indexedReadMethodRef; |
|
493 |
indexedWriteMethodRef = old.indexedWriteMethodRef; |
|
494 |
indexedPropertyTypeRef = old.indexedPropertyTypeRef; |
|
495 |
indexedWriteMethodName = old.indexedWriteMethodName; |
|
496 |
indexedReadMethodName = old.indexedReadMethodName; |
|
497 |
} |
|
498 |
||
499 |
/** |
|
500 |
* Returns a hash code value for the object. |
|
501 |
* See {@link java.lang.Object#hashCode} for a complete description. |
|
502 |
* |
|
503 |
* @return a hash code value for this object. |
|
504 |
* @since 1.5 |
|
505 |
*/ |
|
506 |
public int hashCode() { |
|
507 |
int result = super.hashCode(); |
|
508 |
||
509 |
result = 37 * result + ((indexedWriteMethodName == null) ? 0 : |
|
510 |
indexedWriteMethodName.hashCode()); |
|
511 |
result = 37 * result + ((indexedReadMethodName == null) ? 0 : |
|
512 |
indexedReadMethodName.hashCode()); |
|
513 |
result = 37 * result + ((getIndexedPropertyType() == null) ? 0 : |
|
514 |
getIndexedPropertyType().hashCode()); |
|
515 |
||
516 |
return result; |
|
517 |
} |
|
518 |
||
4960
99ac74ca2f2f
4498236: RFE: Provide a toString method for PropertyChangeEvent and other classes
malenkov
parents:
4392
diff
changeset
|
519 |
void appendTo(StringBuilder sb) { |
99ac74ca2f2f
4498236: RFE: Provide a toString method for PropertyChangeEvent and other classes
malenkov
parents:
4392
diff
changeset
|
520 |
super.appendTo(sb); |
99ac74ca2f2f
4498236: RFE: Provide a toString method for PropertyChangeEvent and other classes
malenkov
parents:
4392
diff
changeset
|
521 |
appendTo(sb, "indexedPropertyType", this.indexedPropertyTypeRef); |
99ac74ca2f2f
4498236: RFE: Provide a toString method for PropertyChangeEvent and other classes
malenkov
parents:
4392
diff
changeset
|
522 |
appendTo(sb, "indexedReadMethod", this.indexedReadMethodRef); |
99ac74ca2f2f
4498236: RFE: Provide a toString method for PropertyChangeEvent and other classes
malenkov
parents:
4392
diff
changeset
|
523 |
appendTo(sb, "indexedWriteMethod", this.indexedWriteMethodRef); |
2 | 524 |
} |
525 |
} |