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) {
|
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 @SuppressWarnings("deprecation")
481 Object tmp = cls.newInstance();
482 editor = tmp;
483 } else {
484 editor = ctor.newInstance(new Object[] { bean });
485 }
486 } catch (Exception ex) {
487 // Fall through
488 }
489 }
490 return (PropertyEditor)editor;
491 }
492
493
494 /**
495 * Compares this {@code PropertyDescriptor} against the specified object.
496 * Returns true if the objects are the same. Two {@code PropertyDescriptor}s
497 * are the same if the read, write, property types, property editor and
498 * flags are equivalent.
499 *
500 * @since 1.4
501 */
502 public boolean equals(Object obj) {
|