Fix formatting to lang standards

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@360513 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2006-01-01 18:30:30 +00:00
parent 42f9084b3b
commit 0eeb7c904c

View File

@ -518,9 +518,12 @@ public static boolean isInnerClass(Class cls) {
return cls.getName().indexOf(INNER_CLASS_SEPARATOR_CHAR) >= 0;
}
// Class loading
// ----------------------------------------------------------------------
/**
* Returns the class represented by <code>className</code> using the <code>classLoader</code>. This implementation
* supports names like "<code>java.lang.String[]</code>" as well as "<code>[Ljava.lang.String;</code>".
* Returns the class represented by <code>className</code> using the
* <code>classLoader</code>. This implementation supports names like
* "<code>java.lang.String[]</code>" as well as "<code>[Ljava.lang.String;</code>".
*
* @param classLoader the class loader to use to load the class
* @param className the class name
@ -528,21 +531,22 @@ public static boolean isInnerClass(Class cls) {
* @return the class represented by <code>className</code> using the <code>classLoader</code>
* @throws ClassNotFoundException if the class is not found
*/
public static Class getClass( ClassLoader classLoader, String className, boolean initialize )
throws ClassNotFoundException {
public static Class getClass(
ClassLoader classLoader, String className, boolean initialize) throws ClassNotFoundException {
Class clazz;
if (abbreviationMap.containsKey(className)) {
clazz = Class.forName( "[" + abbreviationMap.get( className ), initialize, classLoader ).getComponentType();
}
else {
String clsName = "[" + abbreviationMap.get(className);
clazz = Class.forName(clsName, initialize, classLoader).getComponentType();
} else {
clazz = Class.forName(toProperClassName(className), initialize, classLoader);
}
return clazz;
}
/**
* Returns the (initialized) class represented by <code>className</code> using the <code>classLoader</code>. This
* implementation supports names like "<code>java.lang.String[]</code>" as well as
* Returns the (initialized) class represented by <code>className</code>
* using the <code>classLoader</code>. This implementation supports names
* like "<code>java.lang.String[]</code>" as well as
* "<code>[Ljava.lang.String;</code>".
*
* @param classLoader the class loader to use to load the class
@ -555,8 +559,9 @@ public static Class getClass( ClassLoader classLoader, String className ) throws
}
/**
* Returns the (initialized )class represented by <code>className</code> using the current thread's context class
* loader. This implementation supports names like "<code>java.lang.String[]</code>" as well as
* Returns the (initialized )class represented by <code>className</code>
* using the current thread's context class loader. This implementation
* supports names like "<code>java.lang.String[]</code>" as well as
* "<code>[Ljava.lang.String;</code>".
*
* @param className the class name
@ -564,13 +569,13 @@ public static Class getClass( ClassLoader classLoader, String className ) throws
* @throws ClassNotFoundException if the class is not found
*/
public static Class getClass(String className) throws ClassNotFoundException {
return getClass( Thread.currentThread().getContextClassLoader() == null ? ClassUtils.class.getClassLoader() :
Thread.currentThread().getContextClassLoader(), className, true );
return getClass(className, true);
}
/**
* Returns the class represented by <code>className</code> using the current thread's context class loader. This
* implementation supports names like "<code>java.lang.String[]</code>" as well as
* Returns the class represented by <code>className</code> using the
* current thread's context class loader. This implementation supports
* names like "<code>java.lang.String[]</code>" as well as
* "<code>[Ljava.lang.String;</code>".
*
* @param className the class name
@ -579,31 +584,36 @@ public static Class getClass( String className ) throws ClassNotFoundException {
* @throws ClassNotFoundException if the class is not found
*/
public static Class getClass(String className, boolean initialize) throws ClassNotFoundException {
return getClass( Thread.currentThread().getContextClassLoader() == null ? ClassUtils.class.getClassLoader() :
Thread.currentThread().getContextClassLoader(), className, initialize );
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
ClassLoader loader = contextCL == null ? ClassUtils.class.getClassLoader() : contextCL;
return getClass(loader, className, initialize );
}
/**
* Converts a class name to a JLS stle class name.
*
* @param className the class name
* @return the converted name
*/
private static String toProperClassName(String className) {
className = StringUtils.deleteWhitespace(className);
if (className == null) {
throw new NullArgumentException("className");
}
else if( className.endsWith( "[]" ) ) {
final StringBuffer classNameBuffer = new StringBuffer();
} else if (className.endsWith("[]")) {
StringBuffer classNameBuffer = new StringBuffer();
while (className.endsWith("[]")) {
className = className.substring(0, className.length() - 2);
classNameBuffer.append("[");
}
final String abbreviation = ( String ) abbreviationMap.get( className );
String abbreviation = (String) abbreviationMap.get(className);
if (abbreviation != null) {
classNameBuffer.append(abbreviation);
}
else {
} else {
classNameBuffer.append("L").append(className).append(";");
}
className = classNameBuffer.toString();
}
return className;
}
}