directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r414270 - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Date Wed, 14 Jun 2006 14:29:37 GMT
Author: elecharny
Date: Wed Jun 14 07:29:37 2006
New Revision: 414270

URL: http://svn.apache.org/viewvc?rev=414270&view=rev
Log:
Rollback the tests to avoid conflict with optim branch

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

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=414270&r1=414269&r2=414270&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Wed Jun 14 07:29:37 2006
@@ -1673,7 +1673,26 @@
      */
     public static String trim( String str )
     {
-    	return ( isEmpty( str ) ? "" : str.trim() );
+        if ( isEmpty( str ) )
+        {
+            return "";
+        }
+
+        char[] array = str.toCharArray();
+        int start = 0;
+        int end = array.length;
+
+        while ( ( start < end ) && ( array[start] == ' ' ) )
+        {
+            start++;
+        }
+
+        while ( ( end > start ) && ( array[end - 1] == ' ' ) )
+        {
+            end--;
+        }
+
+        return new String( array, start, ( end - start ) );
     }
 
 
@@ -1749,15 +1768,15 @@
             return "";
         }
 
+        char[] array = str.toCharArray();
         int start = 0;
-        int end = str.length();
-        
-        while ( ( start < end ) && ( str.charAt( start ) == ' ' ) )
+
+        while ( ( start < array.length ) && ( array[start] == ' ' ) )
         {
             start++;
         }
 
-        return ( start == 0 ? str : str.substring( start ) );
+        return new String( array, start, array.length - start );
     }
 
 
@@ -1859,15 +1878,16 @@
             return "";
         }
 
-        int length = str.length();
-        int end = length;
-        
-        while ( ( end > 0 ) && ( str.charAt( end - 1 ) == ' ' ) )
+        char[] array = str.toCharArray();
+        int start = 0;
+        int end = array.length;
+
+        while ( ( start < end ) && ( array[start] == ' ' ) )
         {
-            end--;
+            start++;
         }
 
-        return ( end == length ? str : str.substring( 0, end ) );
+        return new String( array, start, ( end - start ) );
     }
 
 



Mime
View raw message