harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r480567 - in /harmony/enhanced/classlib/trunk/modules/beans/src/main/java: java/beans/IndexedPropertyDescriptor.java org/apache/harmony/beans/internal/nls/messages.properties
Date Wed, 29 Nov 2006 13:29:06 GMT
Author: ayza
Date: Wed Nov 29 05:29:05 2006
New Revision: 480567

URL: http://svn.apache.org/viewvc?view=rev&rev=480567
Log:
Several parameter checks were added in order to enable tests from IndexedPropertyDescriptorTest

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java?view=diff&rev=480567&r1=480566&r2=480567
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Wed Nov 29 05:29:05 2006
@@ -30,6 +30,12 @@
             String getterName, String setterName, String indexedGetterName,
             String indexedSetterName) throws IntrospectionException {
         super(propertyName, beanClass, getterName, setterName);
+
+        // RI behaves like this
+        if (indexedGetterName == null && indexedSetterName == null &&
+                (getterName != null || setterName != null)) {
+            throw new IntrospectionException(Messages.getString("beans.50"));
+        }
         setIndexedReadMethod(beanClass, indexedGetterName);
         setIndexedWriteMethod(beanClass, indexedSetterName);
     }
@@ -37,6 +43,12 @@
     public IndexedPropertyDescriptor(String propertyName, Method getter, Method setter,
             Method indexedGetter, Method indexedSetter) throws IntrospectionException {
         super(propertyName, getter, setter);
+        
+        // we need this in order to be compatible with RI
+        if (indexedGetter == null && indexedSetter == null &&
+                (getter != null || setter != null)) {
+            throw new IntrospectionException(Messages.getString("beans.50"));
+        }
         setIndexedReadMethod(indexedGetter);
         setIndexedWriteMethod(indexedSetter);
     }
@@ -48,6 +60,7 @@
         String setterName;
         String indexedGetterName;
         String indexedSetterName;
+
         // array getter
         getterName = createDefaultMethodName(propertyName, "get"); //$NON-NLS-1$
         if (hasMethod(beanClass, getterName)) {
@@ -69,9 +82,14 @@
             setIndexedWriteMethod(beanClass, indexedSetterName);
         }
         // RI seems to behave a bit differently
-        if (indexedGetter == null && indexedSetter == null && getReadMethod()
== null
-                && getWriteMethod() == null) {
-            throw new IntrospectionException(Messages.getString("beans.01", propertyName));
//$NON-NLS-1$
+        if (indexedGetter == null && indexedSetter == null &&
+                getReadMethod() == null && getWriteMethod() == null) {
+            throw new IntrospectionException(
+                    Messages.getString("beans.01", propertyName)); //$NON-NLS-1$
+        }
+        if (indexedGetter == null && indexedSetter == null) {
+            // not an indexed property indeed
+            throw new IntrospectionException(Messages.getString("beans.50"));
         }
     }
 
@@ -81,6 +99,7 @@
             Class<?>[] parameterTypes;
             Class<?> returnType;
             Class<?> indexedPropertyType;
+
             if (!Modifier.isPublic(modifiers)) {
                 throw new IntrospectionException(Messages.getString("beans.21")); //$NON-NLS-1$
             }
@@ -107,6 +126,7 @@
             Class<?> firstParameterType;
             Class<?> secondParameterType;
             Class<?> propType;
+
             if (!Modifier.isPublic(modifiers)) {
                 throw new IntrospectionException(Messages.getString("beans.25")); //$NON-NLS-1$
             }
@@ -162,10 +182,12 @@
 
     public Class<?> getIndexedPropertyType() {
         Class<?> result = null;
+
         if (indexedGetter != null) {
             result = indexedGetter.getReturnType();
         } else if (indexedSetter != null) {
             Class<?>[] parameterTypes = indexedSetter.getParameterTypes();
+
             result = parameterTypes[1];
         }
         return result;
@@ -174,12 +196,13 @@
     private void setIndexedReadMethod(Class<?> beanClass, String indexedGetterName)
{
         Method[] getters = findMethods(beanClass, indexedGetterName);
         boolean result = false;
+
         for (Method element : getters) {
             try {
                 setIndexedReadMethod(element);
                 result = true;
-            } catch (IntrospectionException ie) {
-            }
+            } catch (IntrospectionException ie) {}
+
             if (result) {
                 break;
             }
@@ -189,12 +212,13 @@
     private void setIndexedWriteMethod(Class<?> beanClass, String indexedSetterName)
{
         Method[] setters = findMethods(beanClass, indexedSetterName);
         boolean result = false;
+
         for (Method element : setters) {
             try {
                 setIndexedWriteMethod(element);
                 result = true;
-            } catch (IntrospectionException ie) {
-            }
+            } catch (IntrospectionException ie) {}
+
             if (result) {
                 break;
             }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties?view=diff&rev=480567&r1=480566&r2=480567
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties
Wed Nov 29 05:29:05 2006
@@ -95,3 +95,5 @@
 beans.4D=Invalid method call
 beans.4E=stopClass is not ancestor of beanClass
 beans.4F=search path is null
+beans.50=not an indexed property
+



Mime
View raw message