commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r829283 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/mutable/ test/org/apache/commons/lang/mutable/
Date Sat, 24 Oct 2009 00:00:49 GMT
Author: bayard
Date: Sat Oct 24 00:00:47 2009
New Revision: 829283

URL: http://svn.apache.org/viewvc?rev=829283&view=rev
Log:
Patch from Michael Rudolf in LANG-522 applied with additional String constructor tests added

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableByte.java Sat
Oct 24 00:00:47 2009
@@ -66,6 +66,19 @@
         this.value = value.byteValue();
     }
 
+    /**
+     * Constructs a new MutableByte parsing the given string.
+     * 
+     * @param value
+     *                  the string to parse.
+     * @throws NumberFormatException
+     *                  if the string cannot be parsed into a byte
+     */
+    public MutableByte(String value) throws NumberFormatException {
+        super();
+        this.value = Byte.parseByte(value);
+    }
+
     //-----------------------------------------------------------------------
     /**
      * Gets the value as a Byte instance.

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableDouble.java
Sat Oct 24 00:00:47 2009
@@ -66,6 +66,19 @@
         this.value = value.doubleValue();
     }
 
+    /**
+     * Constructs a new MutableDouble parsing the given string.
+     * 
+     * @param value
+     *                  the string to parse.
+     * @throws NumberFormatException
+     *                  if the string cannot be parsed into a double
+     */
+    public MutableDouble(String value) throws NumberFormatException {
+        super();
+        this.value = Double.parseDouble(value);
+    }
+
     //-----------------------------------------------------------------------
     /**
      * Gets the value as a Double instance.

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableFloat.java Sat
Oct 24 00:00:47 2009
@@ -66,6 +66,19 @@
         this.value = value.floatValue();
     }
 
+    /**
+     * Constructs a new MutableFloat parsing the given string.
+     * 
+     * @param value
+     *                  the string to parse.
+     * @throws NumberFormatException
+     *                  if the string cannot be parsed into a float
+     */
+    public MutableFloat(String value) throws NumberFormatException {
+        super();
+        this.value = Float.parseFloat(value);
+    }
+
     //-----------------------------------------------------------------------
     /**
      * Gets the value as a Float instance.

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableInt.java Sat
Oct 24 00:00:47 2009
@@ -66,6 +66,19 @@
         this.value = value.intValue();
     }
 
+    /**
+     * Constructs a new MutableInt parsing the given string.
+     * 
+     * @param value
+     *                  the string to parse.
+     * @throws NumberFormatException
+     *                  if the string cannot be parsed into an int
+     */
+    public MutableInt(String value) throws NumberFormatException {
+        super();
+        this.value = Integer.parseInt(value);
+    }
+
     //-----------------------------------------------------------------------
     /**
      * Gets the value as a Integer instance.

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableLong.java Sat
Oct 24 00:00:47 2009
@@ -66,6 +66,19 @@
         this.value = value.longValue();
     }
 
+    /**
+     * Constructs a new MutableLong parsing the given string.
+     * 
+     * @param value
+     *                  the string to parse.
+     * @throws NumberFormatException
+     *                  if the string cannot be parsed into a long
+     */
+    public MutableLong(String value) throws NumberFormatException {
+        super();
+        this.value = Long.parseLong(value);
+    }
+
     //-----------------------------------------------------------------------
     /**
      * Gets the value as a Long instance.

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/mutable/MutableShort.java Sat
Oct 24 00:00:47 2009
@@ -66,6 +66,19 @@
         this.value = value.shortValue();
     }
 
+    /**
+     * Constructs a new MutableShort parsing the given string.
+     * 
+     * @param value
+     *                  the string to parse.
+     * @throws NumberFormatException
+     *                  if the string cannot be parsed into a short
+     */
+    public MutableShort(String value) throws NumberFormatException {
+        super();
+        this.value = Short.parseShort(value);
+    }
+
     //-----------------------------------------------------------------------
     /**
      * Gets the value as a Short instance.

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableByteTest.java
Sat Oct 24 00:00:47 2009
@@ -49,8 +49,11 @@
         
         assertEquals((byte) 2, new MutableByte(Byte.valueOf((byte) 2)).byteValue());
         assertEquals((byte) 3, new MutableByte(new MutableByte((byte) 3)).byteValue());
+
+        assertEquals((byte) 2, new MutableByte("2").byteValue());
+
         try {
-            new MutableByte(null);
+            new MutableByte((Number)null);
             fail();
         } catch (NullPointerException ex) {}
     }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableDoubleTest.java
Sat Oct 24 00:00:47 2009
@@ -49,8 +49,11 @@
         
         assertEquals(2d, new MutableDouble(new Double(2d)).doubleValue(), 0.0001d);
         assertEquals(3d, new MutableDouble(new MutableDouble(3d)).doubleValue(), 0.0001d);
+        
+        assertEquals(2d, new MutableDouble("2.0").doubleValue(), 0.0001d);
+
         try {
-            new MutableDouble(null);
+            new MutableDouble((Number)null);
             fail();
         } catch (NullPointerException ex) {}
     }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableFloatTest.java
Sat Oct 24 00:00:47 2009
@@ -49,8 +49,11 @@
         
         assertEquals(2f, new MutableFloat(new Float(2f)).floatValue(), 0.0001f);
         assertEquals(3f, new MutableFloat(new MutableFloat(3f)).floatValue(), 0.0001f);
+
+        assertEquals(2f, new MutableDouble("2.0").floatValue(), 0.0001f);
+
         try {
-            new MutableFloat(null);
+            new MutableFloat((Number)null);
             fail();
         } catch (NullPointerException ex) {}
     }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableIntTest.java
Sat Oct 24 00:00:47 2009
@@ -49,8 +49,11 @@
         
         assertEquals(2, new MutableInt(new Integer(2)).intValue());
         assertEquals(3, new MutableInt(new MutableLong(3)).intValue());
+
+        assertEquals(2, new MutableInt("2").intValue());
+
         try {
-            new MutableInt(null);
+            new MutableInt((Number)null);
             fail();
         } catch (NullPointerException ex) {}
     }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableLongTest.java
Sat Oct 24 00:00:47 2009
@@ -49,8 +49,11 @@
         
         assertEquals(2, new MutableLong(new Long(2)).longValue());
         assertEquals(3, new MutableLong(new MutableLong(3)).longValue());
+
+        assertEquals(2, new MutableLong("2").longValue());
+
         try {
-            new MutableLong(null);
+            new MutableLong((Number)null);
             fail();
         } catch (NullPointerException ex) {}
     }

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java?rev=829283&r1=829282&r2=829283&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
(original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/mutable/MutableShortTest.java
Sat Oct 24 00:00:47 2009
@@ -49,8 +49,11 @@
         
         assertEquals((short) 2, new MutableShort(new Short((short) 2)).shortValue());
         assertEquals((short) 3, new MutableShort(new MutableShort((short) 3)).shortValue());
+
+        assertEquals((short) 2, new MutableShort("2").shortValue());
+
         try {
-            new MutableShort(null);
+            new MutableShort((Number)null);
             fail();
         } catch (NullPointerException ex) {}
     }



Mime
View raw message