< prev index next >

src/java.desktop/share/classes/java/beans/PropertyDescriptor.java

Print this page




 453      * property editor class.
 454      * <p>
 455      * If the property editor class has a public constructor that takes an
 456      * Object argument then it will be invoked using the bean parameter
 457      * as the argument. Otherwise, the default constructor will be invoked.
 458      *
 459      * @param bean the source object
 460      * @return a property editor instance or null if a property editor has
 461      *         not been defined or cannot be created
 462      * @since 1.5
 463      */
 464     public PropertyEditor createPropertyEditor(Object bean) {
 465         Object editor = null;
 466 
 467         final Class<?> cls = getPropertyEditorClass();
 468         if (cls != null && PropertyEditor.class.isAssignableFrom(cls)
 469                 && ReflectUtil.isPackageAccessible(cls)) {
 470             Constructor<?> ctor = null;
 471             if (bean != null) {
 472                 try {
 473                     ctor = cls.getConstructor(new Class<?>[] { Object.class });
 474                 } catch (Exception ex) {
 475                     // Fall through
 476                 }
 477             }
 478             try {
 479                 if (ctor == null) {
 480                     editor = cls.newInstance();
 481                 } else {
 482                     editor = ctor.newInstance(new Object[] { bean });
 483                 }
 484             } catch (Exception ex) {
 485                 // Fall through
 486             }
 487         }
 488         return (PropertyEditor)editor;
 489     }
 490 
 491 
 492     /**
 493      * Compares this {@code PropertyDescriptor} against the specified object.
 494      * Returns true if the objects are the same. Two {@code PropertyDescriptor}s
 495      * are the same if the read, write, property types, property editor and
 496      * flags  are equivalent.
 497      *
 498      * @since 1.4
 499      */
 500     public boolean equals(Object obj) {




 453      * property editor class.
 454      * <p>
 455      * If the property editor class has a public constructor that takes an
 456      * Object argument then it will be invoked using the bean parameter
 457      * as the argument. Otherwise, the default constructor will be invoked.
 458      *
 459      * @param bean the source object
 460      * @return a property editor instance or null if a property editor has
 461      *         not been defined or cannot be created
 462      * @since 1.5
 463      */
 464     public PropertyEditor createPropertyEditor(Object bean) {
 465         Object editor = null;
 466 
 467         final Class<?> cls = getPropertyEditorClass();
 468         if (cls != null && PropertyEditor.class.isAssignableFrom(cls)
 469                 && ReflectUtil.isPackageAccessible(cls)) {
 470             Constructor<?> ctor = null;
 471             if (bean != null) {
 472                 try {
 473                     ctor = cls.getDeclaredConstructor(new Class<?>[] { Object.class });
 474                 } catch (Exception ex) {
 475                     // Fall through
 476                 }
 477             }
 478             try {
 479                 if (ctor == null) {
 480                     editor = cls.getDeclaredConstructor().newInstance();
 481                 } else {
 482                     editor = ctor.newInstance(new Object[] { bean });
 483                 }
 484             } catch (Exception ex) {
 485                 // Fall through
 486             }
 487         }
 488         return (PropertyEditor)editor;
 489     }
 490 
 491 
 492     /**
 493      * Compares this {@code PropertyDescriptor} against the specified object.
 494      * Returns true if the objects are the same. Two {@code PropertyDescriptor}s
 495      * are the same if the read, write, property types, property editor and
 496      * flags  are equivalent.
 497      *
 498      * @since 1.4
 499      */
 500     public boolean equals(Object obj) {


< prev index next >