jdk/src/share/classes/java/beans/PropertyDescriptor.java
changeset 5947 0e6f2837eeca
parent 5506 202f599c92aa
child 6657 15dbb366c6a3
equal deleted inserted replaced
5769:2a390122edff 5947:0e6f2837eeca
   110             throw new IntrospectionException("Method not found: " + writeMethodName);
   110             throw new IntrospectionException("Method not found: " + writeMethodName);
   111         }
   111         }
   112         // If this class or one of its base classes allow PropertyChangeListener,
   112         // If this class or one of its base classes allow PropertyChangeListener,
   113         // then we assume that any properties we discover are "bound".
   113         // then we assume that any properties we discover are "bound".
   114         // See Introspector.getTargetPropertyInfo() method.
   114         // See Introspector.getTargetPropertyInfo() method.
   115         String name = "addPropertyChangeListener";
   115         this.bound = null != Introspector.findInstanceMethod(beanClass, "addPropertyChangeListener", PropertyChangeListener.class);
   116         Class[] args = {PropertyChangeListener.class};
       
   117         this.bound = (null != Introspector.findMethod(beanClass, name, args.length, args));
       
   118     }
   116     }
   119 
   117 
   120     /**
   118     /**
   121      * This constructor takes the name of a simple property, and Method
   119      * This constructor takes the name of a simple property, and Method
   122      * objects for reading and writing the property.
   120      * objects for reading and writing the property.
   223             // Since there can be multiple write methods but only one getter
   221             // Since there can be multiple write methods but only one getter
   224             // method, find the getter method first so that you know what the
   222             // method, find the getter method first so that you know what the
   225             // property type is.  For booleans, there can be "is" and "get"
   223             // property type is.  For booleans, there can be "is" and "get"
   226             // methods.  If an "is" method exists, this is the official
   224             // methods.  If an "is" method exists, this is the official
   227             // reader method so look for this one first.
   225             // reader method so look for this one first.
   228             readMethod = Introspector.findMethod(cls, readMethodName, 0);
   226             readMethod = Introspector.findInstanceMethod(cls, readMethodName);
   229             if (readMethod == null) {
   227             if (readMethod == null) {
   230                 readMethodName = Introspector.GET_PREFIX + getBaseName();
   228                 readMethodName = Introspector.GET_PREFIX + getBaseName();
   231                 readMethod = Introspector.findMethod(cls, readMethodName, 0);
   229                 readMethod = Introspector.findInstanceMethod(cls, readMethodName);
   232             }
   230             }
   233             try {
   231             try {
   234                 setReadMethod(readMethod);
   232                 setReadMethod(readMethod);
   235             } catch (IntrospectionException ex) {
   233             } catch (IntrospectionException ex) {
   236                 // fall
   234                 // fall
   291 
   289 
   292             if (writeMethodName == null) {
   290             if (writeMethodName == null) {
   293                 writeMethodName = Introspector.SET_PREFIX + getBaseName();
   291                 writeMethodName = Introspector.SET_PREFIX + getBaseName();
   294             }
   292             }
   295 
   293 
   296             writeMethod = Introspector.findMethod(cls, writeMethodName, 1,
   294             writeMethod = Introspector.findInstanceMethod(cls, writeMethodName, type);
   297                           (type == null) ? null : new Class[] { type });
       
   298             if (writeMethod != null) {
   295             if (writeMethod != null) {
   299                 if (!writeMethod.getReturnType().equals(void.class)) {
   296                 if (!writeMethod.getReturnType().equals(void.class)) {
   300                     writeMethod = null;
   297                     writeMethod = null;
   301                 }
   298                 }
   302             }
   299             }