commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r987957 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/ test/java/org/apache/commons/lang3/
Date Sun, 22 Aug 2010 22:57:51 GMT
Author: bayard
Date: Sun Aug 22 22:57:51 2010
New Revision: 987957

URL: http://svn.apache.org/viewvc?rev=987957&view=rev
Log:
Removing the CharSequenceUtils.length method in favour of the StringUtils.length method

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java?rev=987957&r1=987956&r2=987957&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
Sun Aug 22 22:57:51 2010
@@ -25,20 +25,6 @@ package org.apache.commons.lang3;
 public class CharSequenceUtils {
 
     /**
-     * Gets a CharSequence length or <code>0</code> if the CharSequence is
-     * <code>null</code>.
-     *
-     * @param cs
-     *            a CharSequence or <code>null</code>
-     * @return CharSequence length or <code>0</code> if the CharSequence is
-     *         <code>null</code>.
-     * @since 3.0
-     */
-    public static int length(CharSequence cs) {
-        return cs == null ? 0 : cs.length();
-    }
-
-    /**
      * Returns a new <code>CharSequence</code> that is a subsequence of this
      * sequence starting with the <code>char</code> value at the specified
      * index. The length (in <code>char</code>s) of the returned sequence is

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java?rev=987957&r1=987956&r2=987957&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java Sun
Aug 22 22:57:51 2010
@@ -4755,12 +4755,10 @@ public class StringUtils {
      * @return CharSequence length or <code>0</code> if the CharSequence is
      *         <code>null</code>.
      * @since 2.4
-     * @deprecated See {@link CharSequenceUtils#length(CharSequence)}
      * @since 3.0 Changed signature from length(String) to length(CharSequence)
      */
-    @Deprecated
     public static int length(CharSequence cs) {
-        return CharSequenceUtils.length(cs);
+        return cs == null ? 0 : cs.length();
     }
 
     // Centering

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java?rev=987957&r1=987956&r2=987957&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java
Sun Aug 22 22:57:51 2010
@@ -29,35 +29,6 @@ import junit.framework.TestCase;
  */
 public class CharSequenceUtilsTest extends TestCase {
 
-    public void testLength_CharBuffer() {
-        Assert.assertEquals(0, CharSequenceUtils.length(CharBuffer.wrap("")));
-        Assert.assertEquals(1, CharSequenceUtils.length(CharBuffer.wrap("A")));
-        Assert.assertEquals(1, CharSequenceUtils.length(CharBuffer.wrap(" ")));
-        Assert.assertEquals(8, CharSequenceUtils.length(CharBuffer.wrap("ABCDEFGH")));
-    }
-
-    public void testLength_String() {
-        Assert.assertEquals(0, CharSequenceUtils.length(null));
-        Assert.assertEquals(0, CharSequenceUtils.length(""));
-        Assert.assertEquals(1, CharSequenceUtils.length("A"));
-        Assert.assertEquals(1, CharSequenceUtils.length(" "));
-        Assert.assertEquals(8, CharSequenceUtils.length("ABCDEFGH"));
-    }
-
-    public void testLength_StringBuffer() {
-        Assert.assertEquals(0, CharSequenceUtils.length(new StringBuffer("")));
-        Assert.assertEquals(1, CharSequenceUtils.length(new StringBuffer("A")));
-        Assert.assertEquals(1, CharSequenceUtils.length(new StringBuffer(" ")));
-        Assert.assertEquals(8, CharSequenceUtils.length(new StringBuffer("ABCDEFGH")));
-    }
-
-    public void testLength_StringBuilder() {
-        Assert.assertEquals(0, CharSequenceUtils.length(new StringBuilder("")));
-        Assert.assertEquals(1, CharSequenceUtils.length(new StringBuilder("A")));
-        Assert.assertEquals(1, CharSequenceUtils.length(new StringBuilder(" ")));
-        Assert.assertEquals(8, CharSequenceUtils.length(new StringBuilder("ABCDEFGH")));
-    }
-
     public void testSubSequence() {
         //
         // null input

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java?rev=987957&r1=987956&r2=987957&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
Sun Aug 22 22:57:51 2010
@@ -1329,7 +1329,6 @@ public class StringUtilsTest extends Tes
         assertEquals("  abc", StringUtils.leftPad("abc", 5, ""));
     }
 
-    @SuppressWarnings("deprecation")
     public void testLengthString() {
         assertEquals(0, StringUtils.length(null));
         assertEquals(0, StringUtils.length(""));
@@ -1339,7 +1338,6 @@ public class StringUtilsTest extends Tes
         assertEquals(8, StringUtils.length("ABCDEFGH"));
     }
 
-    @SuppressWarnings("deprecation")
     public void testLengthStringBuffer() {
         assertEquals(0, StringUtils.length(new StringBuffer("")));
         assertEquals(0, StringUtils.length(new StringBuffer(StringUtils.EMPTY)));
@@ -1348,7 +1346,6 @@ public class StringUtilsTest extends Tes
         assertEquals(8, StringUtils.length(new StringBuffer("ABCDEFGH")));
     }
 
-    @SuppressWarnings("deprecation")
     public void testLengthStringBuilder() {
         assertEquals(0, StringUtils.length(new StringBuilder("")));
         assertEquals(0, StringUtils.length(new StringBuilder(StringUtils.EMPTY)));
@@ -1357,6 +1354,13 @@ public class StringUtilsTest extends Tes
         assertEquals(8, StringUtils.length(new StringBuilder("ABCDEFGH")));
     }
     
+    public void testLength_CharBuffer() {
+        assertEquals(0, StringUtils.length(CharBuffer.wrap("")));
+        assertEquals(1, StringUtils.length(CharBuffer.wrap("A")));
+        assertEquals(1, StringUtils.length(CharBuffer.wrap(" ")));
+        assertEquals(8, StringUtils.length(CharBuffer.wrap("ABCDEFGH")));
+    }
+
     //-----------------------------------------------------------------------
     public void testCenter_StringInt() {
         assertEquals(null, StringUtils.center(null, -1));



Mime
View raw message