commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r1531643 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/StringUtils.java test/java/org/apache/commons/lang3/StringUtilsTest.java
Date Sun, 13 Oct 2013 09:02:07 GMT
Author: bayard
Date: Sun Oct 13 09:02:07 2013
New Revision: 1531643

URL: http://svn.apache.org/r1531643
Log:
Adding 00A0 to the list of whitespace characters per LANG-910

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

Modified: commons/proper/lang/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1531643&r1=1531642&r2=1531643&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/changes/changes.xml (original)
+++ commons/proper/lang/trunk/src/changes/changes.xml Sun Oct 13 09:02:07 2013
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.2" date="TBA" description="Next release">
+    <action issue="LANG-910" type="update" due-to="Timur Yarosh">StringUtils.normalizeSpace
now handles non-breaking spaces (Unicode 00A0)</action>
     <action issue="LANG-804" type="update" dev="britter" due-to="Allon Mureinik">Redundant
check for zero in HashCodeBuilder ctor</action>
     <action issue="LANG-893" type="add" dev="oheger" due-to="Woonsan Ko">StrSubstitutor
now supports default values for variables</action>
     <action issue="LANG-913" type="add" dev="britter" due-to="Allon Mureinik">Adding
.gitignore to commons-lang</action>

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=1531643&r1=1531642&r2=1531643&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
Oct 13 09:02:07 2013
@@ -178,7 +178,7 @@ public class StringUtils {
      * single space, thus matching the same would likely cause a great
      * many noop replacements.
      */
-    private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?: \\s|[\\s&&[^
]])\\s*");
+    private static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?: |\\u00A0|\\s|[\\s&&[^
]])\\s*");
 
     /**
      * <p>{@code StringUtils} instances should NOT be constructed in

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=1531643&r1=1531642&r2=1531643&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 Oct 13 09:02:07 2013
@@ -47,11 +47,13 @@ public class StringUtilsTest {
     
     static final String WHITESPACE;
     static final String NON_WHITESPACE;
+    static final String HARD_SPACE;
     static final String TRIMMABLE;
     static final String NON_TRIMMABLE;
     static {
         String ws = "";
         String nws = "";
+        String hs = String.valueOf(((char) 160));
         String tr = "";
         String ntr = "";
         for (int i = 0; i < Character.MAX_VALUE; i++) {
@@ -69,6 +71,7 @@ public class StringUtilsTest {
         }
         WHITESPACE = ws;
         NON_WHITESPACE = nws;
+        HARD_SPACE = hs;
         TRIMMABLE = tr;
         NON_TRIMMABLE = ntr;
     }
@@ -2119,14 +2122,14 @@ public class StringUtilsTest {
         assertEquals("", StringUtils.getCommonPrefix("xyz", "abcde"));
         assertEquals("i am a ", StringUtils.getCommonPrefix("i am a machine", "i am a robot"));
     }
-        
+
     @Test
     public void testNormalizeSpace() {
         assertEquals(null, StringUtils.normalizeSpace(null));
         assertEquals("", StringUtils.normalizeSpace(""));
         assertEquals("", StringUtils.normalizeSpace(" "));
         assertEquals("", StringUtils.normalizeSpace("\t"));
-        assertEquals("", StringUtils.normalizeSpace("\n"));        
+        assertEquals("", StringUtils.normalizeSpace("\n"));
         assertEquals("", StringUtils.normalizeSpace("\u0009"));
         assertEquals("", StringUtils.normalizeSpace("\u000B"));
         assertEquals("", StringUtils.normalizeSpace("\u000C"));
@@ -2139,6 +2142,7 @@ public class StringUtilsTest {
         assertEquals("a", StringUtils.normalizeSpace("  a  "));
         assertEquals("a b c", StringUtils.normalizeSpace("  a  b   c  "));
         assertEquals("a b c", StringUtils.normalizeSpace("a\t\f\r  b\u000B   c\n"));
+        assertEquals("a   b c", StringUtils.normalizeSpace("a\t\f\r  " + HARD_SPACE + HARD_SPACE
+ "b\u000B   c\n"));
     }
 
     @Test



Mime
View raw message