classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] gnu.java.beans.IntrospectionIncubator - fix for bug #10938


From: Robert Schuster
Subject: [cp-patches] gnu.java.beans.IntrospectionIncubator - fix for bug #10938
Date: Mon, 08 Nov 2004 01:13:52 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.3) Gecko/20040930

hi,
this fixes the regression that was introduced with my prior patch for this class.

bug report:
https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=10938

*writing mauve test*

cu
Robert
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.2758
diff -u -r1.2758 ChangeLog
--- ChangeLog   7 Nov 2004 23:07:44 -0000       1.2758
+++ ChangeLog   8 Nov 2004 00:03:29 -0000
@@ -1,3 +1,11 @@
+2004-11-07  Robert Schuster <address@hidden>
+
+       Fixed regression:
+       * gnu/java/beans/IntrospectionIncubator.java:
+       (addMethod): corrected classification of normal and property methods
+       (capitalize): added documentation
+       (DoubleKey): [class] added documentation
+
 2004-11-07  Mark Wielaard  <address@hidden>
 
        * java/awt/image/LookupOp.java: Comments and indentation fixes.
Index: gnu/java/beans/IntrospectionIncubator.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/beans/IntrospectionIncubator.java,v
retrieving revision 1.13
diff -u -r1.13 IntrospectionIncubator.java
--- gnu/java/beans/IntrospectionIncubator.java  6 Nov 2004 22:19:05 -0000       
1.13
+++ gnu/java/beans/IntrospectionIncubator.java  8 Nov 2004 00:03:30 -0000
@@ -58,8 +58,10 @@
 /**
  ** IntrospectionIncubator takes in a bunch of Methods, and
  ** Introspects only those Methods you give it. 
- ** Note that non-public and static methods are silently
- ** discarded.
+ ** 
+ ** Non-public are silently discarded but it allows static method
+ ** because they are valid in <code>MethodDescriptor</code>
+ ** instances.
  **
  ** @author John Keiser
  ** @author Robert Schuster
@@ -81,15 +83,21 @@
 
        /* Paving the way for automatic Introspection */
        public void addMethod(Method method) {
-               if(Modifier.isPublic(method.getModifiers()) &&
-                       !Modifier.isStatic(method.getModifiers())) {
+               if(Modifier.isPublic(method.getModifiers())) {
                        String name = 
ClassHelper.getTruncatedName(method.getName());
                        Class retType = method.getReturnType();
                        Class[] params = method.getParameterTypes();
                        boolean isVoid = retType.equals(java.lang.Void.TYPE);
                        Class methodClass = method.getDeclaringClass();
                        if(propertyStopClass == null || 
(propertyStopClass.isAssignableFrom(methodClass) && 
!propertyStopClass.equals(methodClass))) {
-                               if(name.startsWith("is")
+                               /* At this point a method may be regarded as a 
property's read or write method if its name
+                                * starts with "is", "get" or "set". However, 
if a method is static it cannot be part
+                                * of a property.
+                                */
+                               if(Modifier.isStatic(method.getModifiers())) {
+                                       // files method as other because it is 
static
+                                       otherMethods.addElement(method);
+                               } else if(name.startsWith("is")
                                   && retType.equals(java.lang.Boolean.TYPE)
                                   && params.length == 0) {
                                        addToPropertyHash(name,method,IS);
@@ -293,7 +301,6 @@
                methods[funcType] = method;
        }
 
-
        void addToListenerHash(String name, Method method, int funcType) {
                String newName;
                Class type;
@@ -321,6 +328,16 @@
                methods[funcType] = method;
        }
 
+       /** Transforms a part of a method name into its corresponding
+        * property name. E.g. "Value" becomes "value".
+        * 
+        * Implementation notes:
+        * If "" is the argument, it is returned without changes.
+        * If <code>null</code> is the argument, <code>null</code> is returned.
+        * 
+        * @param name Part of a method name.
+        * @return Corresponding property name.
+        */
        static String capitalize(String name) {
                try {
                        if(Character.isUpperCase(name.charAt(0))) {
@@ -338,6 +355,14 @@
        }
 }
 
+/** This class is a hashmap key that consists of a <code>Class</code> and a
+ * <code>String</code> element.
+ * 
+ * It is used to combine a property's or event's type with its name.
+ * 
+ * @author John Keiser
+ * @author Robert Schuster
+ */ 
 class DoubleKey {
        Class type;
        String name;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]