harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r536484 - in /harmony/enhanced/classlib/trunk/modules/beans: make/ src/main/java/java/beans/ src/main/java/org/apache/harmony/beans/editors/ src/test/java/org/apache/harmony/beans/tests/java/beans/
Date Wed, 09 May 2007 10:37:04 GMT
Author: pyang
Date: Wed May  9 03:37:02 2007
New Revision: 536484

URL: http://svn.apache.org/viewvc?view=rev&rev=536484
Log:
Fix bugs in PropertyEditorManager and default editors to enable PropertyEditorManagerTest

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ByteEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/DoubleEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/FloatEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/IntEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/LongEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ShortEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/StringEditor.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common Wed May  9 03:37:02
2007
@@ -1,6 +1,5 @@
 org/apache/harmony/beans/tests/java/beans/EncoderTest.java
 org/apache/harmony/beans/tests/java/beans/PropertyChangeSupportTest.java
-org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
 org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java
 org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
 org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyEditorManager.java
Wed May  9 03:37:02 2007
@@ -74,7 +74,7 @@
                             .toUpperCase()
                             + shortEditorClassName.substring(1);
                 }
-
+                
                 for (String element : path) {
                     editorClassName = element + "." + shortEditorClassName; //$NON-NLS-1$
 
@@ -104,7 +104,9 @@
         if (sm != null) {
             sm.checkPropertiesAccess();
         }
-
+        if(apath == null){
+            apath = new String[0];
+        }
         path = apath;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/BooleanEditor.java
Wed May  9 03:37:02 2007
@@ -19,7 +19,7 @@
 
 import java.beans.PropertyEditorSupport;
 
-public class BooleanEditor extends PropertyEditorSupport {
+public final class BooleanEditor extends PropertyEditorSupport {
 
     public BooleanEditor(Object source) {
         super(source);
@@ -30,13 +30,15 @@
     }
 
     @Override
-    public String getAsText() {
-        return getValueAsString();
-    }
-
-    @Override
     public void setAsText(String text) throws IllegalArgumentException {
-        setValue(new Boolean(text));
+        if(text == null){
+            throw new NullPointerException();
+        }
+        if(text.equalsIgnoreCase("true") || text.equalsIgnoreCase("false")){
+            setValue(new Boolean(text));
+        }else{
+            throw new IllegalArgumentException(text);
+        }
     }
 
     @Override
@@ -46,7 +48,7 @@
 
     @Override
     public String[] getTags() {
-        return new String[] { "true", "false" }; //$NON-NLS-1$ //$NON-NLS-2$
+        return new String[] { "True", "False" }; //$NON-NLS-1$ //$NON-NLS-2$
     }
 
     @Override

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ByteEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ByteEditor.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ByteEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ByteEditor.java
Wed May  9 03:37:02 2007
@@ -19,8 +19,8 @@
 
 import java.beans.PropertyEditorSupport;
 
-public class ByteEditor extends PropertyEditorSupport {
-
+public final class ByteEditor extends PropertyEditorSupport {
+    
     public ByteEditor(Object source) {
         super(source);
     }
@@ -30,22 +30,13 @@
     }
 
     @Override
-    public String getAsText() {
-        return getValueAsText();
-    }
-
-    @Override
     public void setAsText(String text) throws IllegalArgumentException {
-        try {
-            setValue(new Byte(text));
-        } catch (NumberFormatException nfe) {
-            throw new IllegalArgumentException(nfe.toString());
-        }
+        setValue(new Byte(text));
     }
 
     @Override
     public String getJavaInitializationString() {
-        return getValueAsText();
+        return new StringBuilder("((byte)").append(getValue()).append(")").toString();
     }
 
     @Override
@@ -58,15 +49,5 @@
         if (value instanceof Byte) {
             super.setValue(value);
         }
-    }
-
-    private String getValueAsText() {
-        String result = null;
-        Object value = getValue();
-        if (value != null) {
-            Byte bValue = (Byte) value;
-            result = bValue.toString();
-        }
-        return result;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/DoubleEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/DoubleEditor.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/DoubleEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/DoubleEditor.java
Wed May  9 03:37:02 2007
@@ -19,7 +19,7 @@
 
 import java.beans.PropertyEditorSupport;
 
-public class DoubleEditor extends PropertyEditorSupport {
+public final class DoubleEditor extends PropertyEditorSupport {
 
     public DoubleEditor(Object source) {
         super(source);
@@ -30,22 +30,13 @@
     }
 
     @Override
-    public String getAsText() {
-        return getValueAsText();
-    }
-
-    @Override
     public void setAsText(String text) throws IllegalArgumentException {
-        try {
-            setValue(new Double(text));
-        } catch (NumberFormatException nfe) {
-            throw new IllegalArgumentException(nfe.toString());
-        }
+        setValue(new Double(text));
     }
 
     @Override
     public String getJavaInitializationString() {
-        return getValueAsText();
+        return getValue().toString();
     }
 
     @Override
@@ -58,15 +49,5 @@
         if (value instanceof Double) {
             super.setValue(value);
         }
-    }
-
-    private String getValueAsText() {
-        String result = null;
-        Object value = getValue();
-        if (value != null) {
-            Double dValue = (Double) value;
-            result = dValue.toString();
-        }
-        return result;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/FloatEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/FloatEditor.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/FloatEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/FloatEditor.java
Wed May  9 03:37:02 2007
@@ -19,7 +19,7 @@
 
 import java.beans.PropertyEditorSupport;
 
-public class FloatEditor extends PropertyEditorSupport {
+public final class FloatEditor extends PropertyEditorSupport {
 
     public FloatEditor(Object source) {
         super(source);
@@ -30,22 +30,13 @@
     }
 
     @Override
-    public String getAsText() {
-        return getValueAsText();
-    }
-
-    @Override
     public void setAsText(String text) throws IllegalArgumentException {
-        try {
-            setValue(new Float(text));
-        } catch (NumberFormatException nfe) {
-            throw new IllegalArgumentException(nfe.toString());
-        }
+        setValue(new Float(text));
     }
 
     @Override
     public String getJavaInitializationString() {
-        return getValueAsText();
+        return getValue()+"F";
     }
 
     @Override
@@ -58,15 +49,5 @@
         if (value instanceof Float) {
             super.setValue(value);
         }
-    }
-
-    private String getValueAsText() {
-        String result = null;
-        Object value = getValue();
-        if (value != null) {
-            Float fValue = (Float) value;
-            result = fValue.toString();
-        }
-        return result;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/IntEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/IntEditor.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/IntEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/IntEditor.java
Wed May  9 03:37:02 2007
@@ -19,7 +19,7 @@
 
 import java.beans.PropertyEditorSupport;
 
-public class IntEditor extends PropertyEditorSupport {
+public final class IntEditor extends PropertyEditorSupport {
 
     public IntEditor(Object source) {
         super(source);
@@ -30,17 +30,8 @@
     }
 
     @Override
-    public String getAsText() {
-        return getValueAsText();
-    }
-
-    @Override
     public void setAsText(String text) throws IllegalArgumentException {
-        try {
-            setValue(new Integer(text));
-        } catch (NumberFormatException nfe) {
-            throw new IllegalArgumentException(nfe.toString());
-        }
+        setValue(new Integer(text));
     }
 
     @Override

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/LongEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/LongEditor.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/LongEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/LongEditor.java
Wed May  9 03:37:02 2007
@@ -19,7 +19,7 @@
 
 import java.beans.PropertyEditorSupport;
 
-public class LongEditor extends PropertyEditorSupport {
+public final class LongEditor extends PropertyEditorSupport {
 
     public LongEditor(Object source) {
         super(source);
@@ -30,22 +30,13 @@
     }
 
     @Override
-    public String getAsText() {
-        return getValueAsText();
-    }
-
-    @Override
     public void setAsText(String text) throws IllegalArgumentException {
-        try {
-            setValue(new Long(text));
-        } catch (NumberFormatException nfe) {
-            throw new IllegalArgumentException(nfe.toString());
-        }
+        setValue(new Long(text));
     }
 
     @Override
     public String getJavaInitializationString() {
-        return getValueAsText();
+        return getValue()+"L";
     }
 
     @Override
@@ -58,15 +49,5 @@
         if (value instanceof Long) {
             super.setValue(value);
         }
-    }
-
-    private String getValueAsText() {
-        String result = null;
-        Object value = getValue();
-        if (value != null) {
-            Long lValue = (Long) value;
-            result = lValue.toString();
-        }
-        return result;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ShortEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ShortEditor.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ShortEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/ShortEditor.java
Wed May  9 03:37:02 2007
@@ -19,7 +19,7 @@
 
 import java.beans.PropertyEditorSupport;
 
-public class ShortEditor extends PropertyEditorSupport {
+public final class ShortEditor extends PropertyEditorSupport {
 
     public ShortEditor(Object source) {
         super(source);
@@ -30,22 +30,13 @@
     }
 
     @Override
-    public String getAsText() {
-        return getValueAsText();
-    }
-
-    @Override
     public void setAsText(String text) throws IllegalArgumentException {
-        try {
-            setValue(new Short(text));
-        } catch (NumberFormatException nfe) {
-            throw new IllegalArgumentException(nfe.toString());
-        }
+        setValue(new Short(text));
     }
 
     @Override
     public String getJavaInitializationString() {
-        return getValueAsText();
+        return new StringBuilder().append("((short)").append(getValue()).append(")").toString();
     }
 
     @Override
@@ -58,15 +49,5 @@
         if (value instanceof Short) {
             super.setValue(value);
         }
-    }
-
-    private String getValueAsText() {
-        String result = null;
-        Object value = getValue();
-        if (value != null) {
-            Short sValue = (Short) value;
-            result = sValue.toString();
-        }
-        return result;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/StringEditor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/StringEditor.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/StringEditor.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/editors/StringEditor.java
Wed May  9 03:37:02 2007
@@ -19,7 +19,7 @@
 
 import java.beans.PropertyEditorSupport;
 
-public class StringEditor extends PropertyEditorSupport {
+public final class StringEditor extends PropertyEditorSupport {
 
     public StringEditor(Object source) {
         super(source);
@@ -32,5 +32,12 @@
     @Override
     public void setAsText(String text) {
         setValue(text);
+    }
+    
+
+    @Override
+    public String getJavaInitializationString() {
+        Object value = getValue(); 
+        return value==null?"\"null\"":"\""+value+"\"";
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java?view=diff&rev=536484&r1=536483&r2=536484
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
Wed May  9 03:37:02 2007
@@ -112,7 +112,7 @@
     public void testGetEditorSearchPath_default() {
         String[] path = PropertyEditorManager.getEditorSearchPath();
         assertEquals(1, path.length);
-        assertEquals("org.apache.harmony.beans.editors", path[0]);
+        assertTrue(path[0].endsWith("beans.editors"));
     }
 
     public void testGetEditorSearchPath() {
@@ -200,14 +200,19 @@
         PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
         try {
             editor.setAsText(null);
-            fail("Should throw a Exception");
-        } catch (Exception e) {
+            fail("Should throw a NPException");
+        } catch (NullPointerException e) {
         }
     }
 
     public void testBoolEditor_setAsText_Invalid() {
         PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
         try {
+            editor.setAsText("yes");
+            fail("Should throw a IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+        }
+        try {
             editor.setAsText("***true***");
             fail("Should throw a IllegalArgumentException");
         } catch (IllegalArgumentException e) {
@@ -421,7 +426,7 @@
 
         editor.setAsText(null);
         assertEquals("null", editor.getAsText());
-        assertEquals("null", editor.getJavaInitializationString());
+        assertEquals("\"null\"", editor.getJavaInitializationString());
         assertNull(editor.getValue());
     }
 
@@ -430,7 +435,7 @@
         String str = "\n\t\\a\"";
         editor.setAsText(str);
         assertEquals(str, editor.getAsText());
-        assertEquals("\"\\n\\u0009\\\\a\\\"\"", editor
+        assertEquals("\"\n\t\\a\"\"", editor
                 .getJavaInitializationString());
     }
 



Mime
View raw message