You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/11/21 17:41:37 UTC

svn commit: r345931 - /directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/util/StringTools.java

Author: elecharny
Date: Mon Nov 21 08:41:33 2005
New Revision: 345931

URL: http://svn.apache.org/viewcvs?rev=345931&view=rev
Log:
- Check that the string to be trimmed is not null or empty. In these
cases, an empty string is returned.

Modified:
    directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/util/StringTools.java

Modified: directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/util/StringTools.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/util/StringTools.java?rev=345931&r1=345930&r2=345931&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/util/StringTools.java (original)
+++ directory/shared/ldap/trunk/common/src/main/java/org/apache/ldap/common/util/StringTools.java Mon Nov 21 08:41:33 2005
@@ -45,6 +45,11 @@
      */
     public static String trimConsecutiveToOne( String str, char ch )
     {
+        if ( ( null == str ) || ( str.length() == 0 ) )
+        {
+            return "";
+        }
+
         char[] buffer = str.toCharArray();
         char[] newbuf = new char[buffer.length];
         int pos = 0;
@@ -117,9 +122,9 @@
      */
     public static String deepTrim( String str, boolean toLowerCase )
     {
-        if ( null == str )
+        if ( ( null == str ) || ( str.length() == 0 ) )
         {
-            return null ;
+            return "";
         }
 
         char ch ;