Attaching Johann's fix to LANG-322 (via Ben's patch)

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@594394 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2007-11-13 02:33:13 +00:00
parent da6569b4a6
commit 62a9fa6811
1 changed files with 8 additions and 9 deletions

View File

@ -161,16 +161,15 @@ public class ClassUtils {
if (className.length() == 0) { if (className.length() == 0) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
char[] chars = className.toCharArray();
int lastDot = 0; int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
for (int i = 0; i < chars.length; i++) { int innerIdx = className.indexOf(
if (chars[i] == PACKAGE_SEPARATOR_CHAR) { INNER_CLASS_SEPARATOR_CHAR, lastDotIdx == -1 ? 0 : lastDotIdx + 1);
lastDot = i + 1; String out = className.substring(lastDotIdx + 1);
} else if (chars[i] == INNER_CLASS_SEPARATOR_CHAR) { // handle inner classes if (innerIdx != -1) {
chars[i] = PACKAGE_SEPARATOR_CHAR; out = out.replace(INNER_CLASS_SEPARATOR_CHAR, PACKAGE_SEPARATOR_CHAR);
} }
} return out;
return new String(chars, lastDot, chars.length - lastDot);
} }
// Package name // Package name