harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r638256 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/PropertyDescriptor.java main/java/org/apache/harmony/beans/BeansUtils.java test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java
Date Tue, 18 Mar 2008 08:07:16 GMT
Author: tonywu
Date: Tue Mar 18 01:07:13 2008
New Revision: 638256

URL: http://svn.apache.org/viewvc?rev=638256&view=rev
Log:
The get/set method should be created as locale independent

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java?rev=638256&r1=638255&r2=638256&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
Tue Mar 18 01:07:13 2008
@@ -218,7 +218,7 @@
     String createDefaultMethodName(String propertyName, String prefix) {
         String result = null;
         if (propertyName != null) {
-            String bos = propertyName.substring(0, 1).toUpperCase();
+            String bos = BeansUtils.toASCIIUpperCase(propertyName.substring(0, 1));
             String eos = propertyName.substring(1, propertyName.length());
             result = prefix + bos + eos;
         }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java?rev=638256&r1=638255&r2=638256&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/BeansUtils.java
Tue Mar 18 01:07:13 2008
@@ -26,4 +26,32 @@
     public static final int getHashCode(boolean b) {
         return b?1:0;
     }
+    
+    public static String toASCIILowerCase(String s) {
+        int len = s.length();
+        StringBuilder buffer = new StringBuilder(len);
+        for (int i = 0; i < len; i++) {
+            char c = s.charAt(i);
+            if ('A' <= c && c <= 'Z') {
+                buffer.append((char) (c + ('a' - 'A')));
+            } else {
+                buffer.append(c);
+            }
+        }
+        return buffer.toString();
+    }
+    
+    public static String toASCIIUpperCase(String s) {
+        int len = s.length();
+        StringBuilder buffer = new StringBuilder(len);
+        for (int i = 0; i < len; i++) {
+            char c = s.charAt(i);
+            if ('a' <= c && c <= 'z') {
+                buffer.append((char) (c - ('a' - 'A')));
+            } else {
+                buffer.append(c);
+            }
+        }
+        return buffer.toString();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java?rev=638256&r1=638255&r2=638256&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyDescriptorTest.java
Tue Mar 18 01:07:13 2008
@@ -23,6 +23,7 @@
 import java.beans.PropertyEditorSupport;
 import java.io.Serializable;
 import java.lang.reflect.Method;
+import java.util.Locale;
 
 import junit.framework.TestCase;
 
@@ -1221,5 +1222,27 @@
         PropertyDescriptor pd2 = new PropertyDescriptor("a",MockBean.class);
         assertEquals(pd1, pd2);
         assertEquals(pd1.hashCode(), pd2.hashCode());
+    }
+    
+    private class MockBeanForTR {
+        int i;
+
+        public int getI() {
+            return i;
+        }
+
+        public void setI(int i) {
+            this.i = i;
+        }
+    }
+    
+    public void testByLocale() throws IntrospectionException{
+        Locale backup = Locale.getDefault();
+        Locale.setDefault(new Locale("TR"));
+        try {
+            assertNotNull(new PropertyDescriptor("i", MockBeanForTR.class));
+        } finally {
+            Locale.setDefault(backup);
+        }
     }
 }



Mime
View raw message