commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r594394 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java
Date Tue, 13 Nov 2007 02:33:33 GMT
Author: bayard
Date: Mon Nov 12 18:33:13 2007
New Revision: 594394

URL: http://svn.apache.org/viewvc?rev=594394&view=rev
Log:
Attaching Johann's fix to LANG-322 (via Ben's patch)

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java?rev=594394&r1=594393&r2=594394&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java Mon Nov 12
18:33:13 2007
@@ -161,16 +161,15 @@
         if (className.length() == 0) {
             return StringUtils.EMPTY;
         }
-        char[] chars = className.toCharArray();
-        int lastDot = 0;
-        for (int i = 0; i < chars.length; i++) {
-            if (chars[i] == PACKAGE_SEPARATOR_CHAR) {
-                lastDot = i + 1;
-            } else if (chars[i] == INNER_CLASS_SEPARATOR_CHAR) {  // handle inner classes
-                chars[i] = PACKAGE_SEPARATOR_CHAR;
-            }
+
+        int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
+        int innerIdx = className.indexOf(
+                INNER_CLASS_SEPARATOR_CHAR, lastDotIdx == -1 ? 0 : lastDotIdx + 1);
+        String out = className.substring(lastDotIdx + 1);
+        if (innerIdx != -1) {
+            out = out.replace(INNER_CLASS_SEPARATOR_CHAR, PACKAGE_SEPARATOR_CHAR);
         }
-        return new String(chars, lastDot, chars.length - lastDot);
+        return out;
     }
 
     // Package name



Mime
View raw message