comments, a spelling correction, some ws
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@752469 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
67bca7a1e8
commit
9ec9d423fa
|
@ -5,9 +5,9 @@
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
* (the "License"); you may not use this file except in compliance with
|
* (the "License"); you may not use this file except in compliance with
|
||||||
* the License. You may obtain a copy of the License at
|
* the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -31,9 +31,9 @@ import java.util.Map;
|
||||||
* <p>This class handles invalid <code>null</code> inputs as best it can.
|
* <p>This class handles invalid <code>null</code> inputs as best it can.
|
||||||
* Each method documents its behaviour in more detail.</p>
|
* Each method documents its behaviour in more detail.</p>
|
||||||
*
|
*
|
||||||
* <p>The notion of a <code>canonical name</code> includes the human
|
* <p>The notion of a <code>canonical name</code> includes the human
|
||||||
* readable name for the type, for example <code>int[]</code>. The
|
* readable name for the type, for example <code>int[]</code>. The
|
||||||
* non-canonical method variants work with the JVM names, such as
|
* non-canonical method variants work with the JVM names, such as
|
||||||
* <code>[I</code>. </p>
|
* <code>[I</code>. </p>
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
|
@ -105,10 +105,10 @@ public class ClassUtils {
|
||||||
* Maps an abbreviation used in array class names to corresponding primitive class name.
|
* Maps an abbreviation used in array class names to corresponding primitive class name.
|
||||||
*/
|
*/
|
||||||
private static Map reverseAbbreviationMap = new HashMap();
|
private static Map reverseAbbreviationMap = new HashMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add primitive type abbreviation to maps of abbreviations.
|
* Add primitive type abbreviation to maps of abbreviations.
|
||||||
*
|
*
|
||||||
* @param primitive Canonical name of primitive type
|
* @param primitive Canonical name of primitive type
|
||||||
* @param abbreviation Corresponding abbreviation of primitive type
|
* @param abbreviation Corresponding abbreviation of primitive type
|
||||||
*/
|
*/
|
||||||
|
@ -116,7 +116,7 @@ public class ClassUtils {
|
||||||
abbreviationMap.put(primitive, abbreviation);
|
abbreviationMap.put(primitive, abbreviation);
|
||||||
reverseAbbreviationMap.put(abbreviation, primitive);
|
reverseAbbreviationMap.put(abbreviation, primitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feed abbreviation maps
|
* Feed abbreviation maps
|
||||||
*/
|
*/
|
||||||
|
@ -397,6 +397,7 @@ public class ClassUtils {
|
||||||
* @param toClassArray the array of Classes to try to assign into, may be <code>null</code>
|
* @param toClassArray the array of Classes to try to assign into, may be <code>null</code>
|
||||||
* @return <code>true</code> if assignment possible
|
* @return <code>true</code> if assignment possible
|
||||||
*/
|
*/
|
||||||
|
//TODO when we bump the major version we should default autoboxing to true on platforms >= 1.5
|
||||||
public static boolean isAssignable(Class[] classArray, Class[] toClassArray) {
|
public static boolean isAssignable(Class[] classArray, Class[] toClassArray) {
|
||||||
return isAssignable(classArray, toClassArray, false);
|
return isAssignable(classArray, toClassArray, false);
|
||||||
}
|
}
|
||||||
|
@ -477,6 +478,7 @@ public class ClassUtils {
|
||||||
* @param toClass the Class to try to assign into, returns false if null
|
* @param toClass the Class to try to assign into, returns false if null
|
||||||
* @return <code>true</code> if assignment possible
|
* @return <code>true</code> if assignment possible
|
||||||
*/
|
*/
|
||||||
|
//TODO when we bump the major version we should default autoboxing to true on platforms >= 1.5
|
||||||
public static boolean isAssignable(Class cls, Class toClass) {
|
public static boolean isAssignable(Class cls, Class toClass) {
|
||||||
return isAssignable(cls, toClass, false);
|
return isAssignable(cls, toClass, false);
|
||||||
}
|
}
|
||||||
|
@ -661,7 +663,7 @@ public class ClassUtils {
|
||||||
* @see #wrapperToPrimitive(Class)
|
* @see #wrapperToPrimitive(Class)
|
||||||
* @since 2.4
|
* @since 2.4
|
||||||
*/
|
*/
|
||||||
public static Class[] wrappersToPrimitives(Class[] classes) {
|
public static Class[] wrappersToPrimitives(Class[] classes) {
|
||||||
if (classes == null) {
|
if (classes == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -767,10 +769,10 @@ public class ClassUtils {
|
||||||
// Public method
|
// Public method
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* <p>Returns the desired Method much like <code>Class.getMethod</code>, however
|
* <p>Returns the desired Method much like <code>Class.getMethod</code>, however
|
||||||
* it ensures that the returned Method is from a public class or interface and not
|
* it ensures that the returned Method is from a public class or interface and not
|
||||||
* from an anonymous inner class. This means that the Method is invokable and
|
* from an anonymous inner class. This means that the Method is invokable and
|
||||||
* doesn't fall foul of Java bug
|
* doesn't fall foul of Java bug
|
||||||
* <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957">4071957</a>).
|
* <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957">4071957</a>).
|
||||||
*
|
*
|
||||||
* <code><pre>Set set = Collections.unmodifiableSet(...);
|
* <code><pre>Set set = Collections.unmodifiableSet(...);
|
||||||
|
@ -787,18 +789,18 @@ public class ClassUtils {
|
||||||
* @throws NoSuchMethodException if the method is not found in the given class
|
* @throws NoSuchMethodException if the method is not found in the given class
|
||||||
* or if the metothod doen't conform with the requirements
|
* or if the metothod doen't conform with the requirements
|
||||||
*/
|
*/
|
||||||
public static Method getPublicMethod(Class cls, String methodName, Class parameterTypes[])
|
public static Method getPublicMethod(Class cls, String methodName, Class parameterTypes[])
|
||||||
throws SecurityException, NoSuchMethodException {
|
throws SecurityException, NoSuchMethodException {
|
||||||
|
|
||||||
Method declaredMethod = cls.getMethod(methodName, parameterTypes);
|
Method declaredMethod = cls.getMethod(methodName, parameterTypes);
|
||||||
if (Modifier.isPublic(declaredMethod.getDeclaringClass().getModifiers())) {
|
if (Modifier.isPublic(declaredMethod.getDeclaringClass().getModifiers())) {
|
||||||
return declaredMethod;
|
return declaredMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
List candidateClasses = new ArrayList();
|
List candidateClasses = new ArrayList();
|
||||||
candidateClasses.addAll(getAllInterfaces(cls));
|
candidateClasses.addAll(getAllInterfaces(cls));
|
||||||
candidateClasses.addAll(getAllSuperclasses(cls));
|
candidateClasses.addAll(getAllSuperclasses(cls));
|
||||||
|
|
||||||
for (Iterator it = candidateClasses.iterator(); it.hasNext(); ) {
|
for (Iterator it = candidateClasses.iterator(); it.hasNext(); ) {
|
||||||
Class candidateClass = (Class) it.next();
|
Class candidateClass = (Class) it.next();
|
||||||
if (!Modifier.isPublic(candidateClass.getModifiers())) {
|
if (!Modifier.isPublic(candidateClass.getModifiers())) {
|
||||||
|
@ -814,7 +816,7 @@ public class ClassUtils {
|
||||||
return candidateMethod;
|
return candidateMethod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NoSuchMethodException("Can't find a public method for " +
|
throw new NoSuchMethodException("Can't find a public method for " +
|
||||||
methodName + " " + ArrayUtils.toString(parameterTypes));
|
methodName + " " + ArrayUtils.toString(parameterTypes));
|
||||||
}
|
}
|
||||||
|
@ -969,7 +971,7 @@ public class ClassUtils {
|
||||||
* <li><code>getCanonicalName("java.lang.String") = "java.lang.String"</code></li>
|
* <li><code>getCanonicalName("java.lang.String") = "java.lang.String"</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param className the name of class
|
* @param className the name of class
|
||||||
* @return canonical form of class name
|
* @return canonical form of class name
|
||||||
* @since 2.4
|
* @since 2.4
|
||||||
|
|
Loading…
Reference in New Issue