Corrected speiling mistake spotted by Jeff Varszegi.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0cc87fe88d
commit
f9ad966250
|
@ -82,7 +82,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
* @author Gregor Raýman
|
||||
* @author Jan Sorensen
|
||||
* @author Robert Burrell Donkin
|
||||
* @version $Id: MethodUtils.java,v 1.5 2002/11/20 21:45:47 rdonkin Exp $
|
||||
* @version $Id: MethodUtils.java,v 1.6 2002/11/20 22:31:40 rdonkin Exp $
|
||||
*/
|
||||
public class MethodUtils {
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class MethodUtils {
|
|||
Method[] methods = acls.getDeclaredMethods();
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
if (methods[i].getName().equals(methodName) &&
|
||||
ReflectionUtils.isCompatable(paramTypes, methods[i].getParameterTypes())) {
|
||||
ReflectionUtils.isCompatible(paramTypes, methods[i].getParameterTypes())) {
|
||||
if (Modifier.isPublic(methods[i].getModifiers())) {
|
||||
methods[i].setAccessible(true);
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ public class MethodUtils {
|
|||
log("Param=" + parameterTypes[n].getName());
|
||||
log("Method=" + methodsParams[n].getName());
|
||||
}
|
||||
if (!ReflectionUtils.isCompatable(parameterTypes[n], methodsParams[n])) {
|
||||
if (!ReflectionUtils.isCompatible(parameterTypes[n], methodsParams[n])) {
|
||||
if (debug) {
|
||||
log(methodsParams[n] + " is not assignable from "
|
||||
+ parameterTypes[n]);
|
||||
|
|
|
@ -69,7 +69,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
* reflection.
|
||||
*
|
||||
* @author <a href="mailto:scolebourne@apache.org">Stephen Colebourne</a>
|
||||
* @version $Id: ReflectionUtils.java,v 1.3 2002/11/20 21:45:47 rdonkin Exp $
|
||||
* @version $Id: ReflectionUtils.java,v 1.4 2002/11/20 22:31:40 rdonkin Exp $
|
||||
*/
|
||||
public class ReflectionUtils {
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class ReflectionUtils {
|
|||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks if the requested Class array is compatable with the specified
|
||||
* Checks if the requested Class array is compatible with the specified
|
||||
* parameter array.
|
||||
* Primitive classes are handled correctly .
|
||||
* <p>
|
||||
|
@ -204,9 +204,9 @@ public class ReflectionUtils {
|
|||
*
|
||||
* @param requestedTypes the class array requested
|
||||
* @param paramTypes the actual class array for the method
|
||||
* @return true if the parameters are compatable
|
||||
* @return true if the parameters are compatible
|
||||
*/
|
||||
public static boolean isCompatable(Class[] requestedTypes, Class[] paramTypes) {
|
||||
public static boolean isCompatible(Class[] requestedTypes, Class[] paramTypes) {
|
||||
if (ArrayUtils.isSameLength(requestedTypes, paramTypes) == false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ public class ReflectionUtils {
|
|||
paramTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
|
||||
}
|
||||
for (int i = 0; i < requestedTypes.length; i++) {
|
||||
if (isCompatable(requestedTypes[i], paramTypes[i]) == false) {
|
||||
if (isCompatible(requestedTypes[i], paramTypes[i]) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ public class ReflectionUtils {
|
|||
*
|
||||
* @return true if the assignement is compatible.
|
||||
*/
|
||||
public static boolean isCompatable(Class requestedType, Class parameterType) {
|
||||
public static boolean isCompatible(Class requestedType, Class parameterType) {
|
||||
// try plain assignment
|
||||
if (ClassUtils.isAssignable(requestedType, parameterType)) {
|
||||
return true;
|
||||
|
|
|
@ -206,83 +206,83 @@ public class ReflectionUtilsTestCase extends TestCase {
|
|||
public void testWidening() throws Exception
|
||||
{
|
||||
// test byte conversions
|
||||
assertEquals("byte -> char", ReflectionUtils.isCompatable(Byte.class, char.class), false);
|
||||
assertEquals("byte -> byte", ReflectionUtils.isCompatable(Byte.class, byte.class), true);
|
||||
assertEquals("byte -> short", ReflectionUtils.isCompatable(Byte.class, short.class), true);
|
||||
assertEquals("byte -> int", ReflectionUtils.isCompatable(Byte.class, int.class), true);
|
||||
assertEquals("byte -> long", ReflectionUtils.isCompatable(Byte.class, long.class), true);
|
||||
assertEquals("byte -> float", ReflectionUtils.isCompatable(Byte.class, float.class), true);
|
||||
assertEquals("byte -> double", ReflectionUtils.isCompatable(Byte.class, double.class), true);
|
||||
assertEquals("byte -> boolean", ReflectionUtils.isCompatable(Byte.class, boolean.class), false);
|
||||
assertEquals("byte -> char", ReflectionUtils.isCompatible(Byte.class, char.class), false);
|
||||
assertEquals("byte -> byte", ReflectionUtils.isCompatible(Byte.class, byte.class), true);
|
||||
assertEquals("byte -> short", ReflectionUtils.isCompatible(Byte.class, short.class), true);
|
||||
assertEquals("byte -> int", ReflectionUtils.isCompatible(Byte.class, int.class), true);
|
||||
assertEquals("byte -> long", ReflectionUtils.isCompatible(Byte.class, long.class), true);
|
||||
assertEquals("byte -> float", ReflectionUtils.isCompatible(Byte.class, float.class), true);
|
||||
assertEquals("byte -> double", ReflectionUtils.isCompatible(Byte.class, double.class), true);
|
||||
assertEquals("byte -> boolean", ReflectionUtils.isCompatible(Byte.class, boolean.class), false);
|
||||
|
||||
// test short conversions
|
||||
assertEquals("short -> char", ReflectionUtils.isCompatable(Short.class, char.class), false);
|
||||
assertEquals("short -> byte", ReflectionUtils.isCompatable(Short.class, byte.class), false);
|
||||
assertEquals("short -> short", ReflectionUtils.isCompatable(Short.class, short.class), true);
|
||||
assertEquals("short -> int", ReflectionUtils.isCompatable(Short.class, int.class), true);
|
||||
assertEquals("short -> long", ReflectionUtils.isCompatable(Short.class, long.class), true);
|
||||
assertEquals("short -> float", ReflectionUtils.isCompatable(Short.class, float.class), true);
|
||||
assertEquals("short -> double", ReflectionUtils.isCompatable(Short.class, double.class), true);
|
||||
assertEquals("short -> boolean", ReflectionUtils.isCompatable(Short.class, boolean.class), false);
|
||||
assertEquals("short -> char", ReflectionUtils.isCompatible(Short.class, char.class), false);
|
||||
assertEquals("short -> byte", ReflectionUtils.isCompatible(Short.class, byte.class), false);
|
||||
assertEquals("short -> short", ReflectionUtils.isCompatible(Short.class, short.class), true);
|
||||
assertEquals("short -> int", ReflectionUtils.isCompatible(Short.class, int.class), true);
|
||||
assertEquals("short -> long", ReflectionUtils.isCompatible(Short.class, long.class), true);
|
||||
assertEquals("short -> float", ReflectionUtils.isCompatible(Short.class, float.class), true);
|
||||
assertEquals("short -> double", ReflectionUtils.isCompatible(Short.class, double.class), true);
|
||||
assertEquals("short -> boolean", ReflectionUtils.isCompatible(Short.class, boolean.class), false);
|
||||
|
||||
// test char conversions
|
||||
assertEquals("char -> char", ReflectionUtils.isCompatable(Character.class, char.class), true);
|
||||
assertEquals("char -> byte", ReflectionUtils.isCompatable(Character.class, byte.class), false);
|
||||
assertEquals("char -> short", ReflectionUtils.isCompatable(Character.class, short.class), false);
|
||||
assertEquals("char -> int", ReflectionUtils.isCompatable(Character.class, int.class), true);
|
||||
assertEquals("char -> long", ReflectionUtils.isCompatable(Character.class, long.class), true);
|
||||
assertEquals("char -> float", ReflectionUtils.isCompatable(Character.class, float.class), true);
|
||||
assertEquals("char -> double", ReflectionUtils.isCompatable(Character.class, double.class), true);
|
||||
assertEquals("char -> boolean", ReflectionUtils.isCompatable(Character.class, boolean.class), false);
|
||||
assertEquals("char -> char", ReflectionUtils.isCompatible(Character.class, char.class), true);
|
||||
assertEquals("char -> byte", ReflectionUtils.isCompatible(Character.class, byte.class), false);
|
||||
assertEquals("char -> short", ReflectionUtils.isCompatible(Character.class, short.class), false);
|
||||
assertEquals("char -> int", ReflectionUtils.isCompatible(Character.class, int.class), true);
|
||||
assertEquals("char -> long", ReflectionUtils.isCompatible(Character.class, long.class), true);
|
||||
assertEquals("char -> float", ReflectionUtils.isCompatible(Character.class, float.class), true);
|
||||
assertEquals("char -> double", ReflectionUtils.isCompatible(Character.class, double.class), true);
|
||||
assertEquals("char -> boolean", ReflectionUtils.isCompatible(Character.class, boolean.class), false);
|
||||
|
||||
// test int conversions
|
||||
assertEquals("int -> char", ReflectionUtils.isCompatable(Integer.class, char.class), false);
|
||||
assertEquals("int -> byte", ReflectionUtils.isCompatable(Integer.class, byte.class), false);
|
||||
assertEquals("int -> short", ReflectionUtils.isCompatable(Integer.class, short.class), false);
|
||||
assertEquals("int -> int", ReflectionUtils.isCompatable(Integer.class, int.class), true);
|
||||
assertEquals("int -> long", ReflectionUtils.isCompatable(Integer.class, long.class), true);
|
||||
assertEquals("int -> float", ReflectionUtils.isCompatable(Integer.class, float.class), true);
|
||||
assertEquals("int -> double", ReflectionUtils.isCompatable(Integer.class, double.class), true);
|
||||
assertEquals("int -> boolean", ReflectionUtils.isCompatable(Integer.class, boolean.class), false);
|
||||
assertEquals("int -> char", ReflectionUtils.isCompatible(Integer.class, char.class), false);
|
||||
assertEquals("int -> byte", ReflectionUtils.isCompatible(Integer.class, byte.class), false);
|
||||
assertEquals("int -> short", ReflectionUtils.isCompatible(Integer.class, short.class), false);
|
||||
assertEquals("int -> int", ReflectionUtils.isCompatible(Integer.class, int.class), true);
|
||||
assertEquals("int -> long", ReflectionUtils.isCompatible(Integer.class, long.class), true);
|
||||
assertEquals("int -> float", ReflectionUtils.isCompatible(Integer.class, float.class), true);
|
||||
assertEquals("int -> double", ReflectionUtils.isCompatible(Integer.class, double.class), true);
|
||||
assertEquals("int -> boolean", ReflectionUtils.isCompatible(Integer.class, boolean.class), false);
|
||||
|
||||
// test long conversions
|
||||
assertEquals("long -> char", ReflectionUtils.isCompatable(Long.class, char.class), false);
|
||||
assertEquals("long -> byte", ReflectionUtils.isCompatable(Long.class, byte.class), false);
|
||||
assertEquals("long -> short", ReflectionUtils.isCompatable(Long.class, short.class), false);
|
||||
assertEquals("long -> int", ReflectionUtils.isCompatable(Long.class, int.class), false);
|
||||
assertEquals("long -> long", ReflectionUtils.isCompatable(Long.class, long.class), true);
|
||||
assertEquals("long -> float", ReflectionUtils.isCompatable(Long.class, float.class), true);
|
||||
assertEquals("long -> double", ReflectionUtils.isCompatable(Long.class, double.class), true);
|
||||
assertEquals("long -> boolean", ReflectionUtils.isCompatable(Long.class, boolean.class), false);
|
||||
assertEquals("long -> char", ReflectionUtils.isCompatible(Long.class, char.class), false);
|
||||
assertEquals("long -> byte", ReflectionUtils.isCompatible(Long.class, byte.class), false);
|
||||
assertEquals("long -> short", ReflectionUtils.isCompatible(Long.class, short.class), false);
|
||||
assertEquals("long -> int", ReflectionUtils.isCompatible(Long.class, int.class), false);
|
||||
assertEquals("long -> long", ReflectionUtils.isCompatible(Long.class, long.class), true);
|
||||
assertEquals("long -> float", ReflectionUtils.isCompatible(Long.class, float.class), true);
|
||||
assertEquals("long -> double", ReflectionUtils.isCompatible(Long.class, double.class), true);
|
||||
assertEquals("long -> boolean", ReflectionUtils.isCompatible(Long.class, boolean.class), false);
|
||||
|
||||
// test float conversions
|
||||
assertEquals("float -> char", ReflectionUtils.isCompatable(Float.class, char.class), false);
|
||||
assertEquals("float -> byte", ReflectionUtils.isCompatable(Float.class, byte.class), false);
|
||||
assertEquals("float -> short", ReflectionUtils.isCompatable(Float.class, short.class), false);
|
||||
assertEquals("float -> int", ReflectionUtils.isCompatable(Float.class, int.class), false);
|
||||
assertEquals("float -> long", ReflectionUtils.isCompatable(Float.class, long.class), false);
|
||||
assertEquals("float -> float", ReflectionUtils.isCompatable(Float.class, float.class), true);
|
||||
assertEquals("float -> double", ReflectionUtils.isCompatable(Float.class, double.class), true);
|
||||
assertEquals("float -> boolean", ReflectionUtils.isCompatable(Float.class, boolean.class), false);
|
||||
assertEquals("float -> char", ReflectionUtils.isCompatible(Float.class, char.class), false);
|
||||
assertEquals("float -> byte", ReflectionUtils.isCompatible(Float.class, byte.class), false);
|
||||
assertEquals("float -> short", ReflectionUtils.isCompatible(Float.class, short.class), false);
|
||||
assertEquals("float -> int", ReflectionUtils.isCompatible(Float.class, int.class), false);
|
||||
assertEquals("float -> long", ReflectionUtils.isCompatible(Float.class, long.class), false);
|
||||
assertEquals("float -> float", ReflectionUtils.isCompatible(Float.class, float.class), true);
|
||||
assertEquals("float -> double", ReflectionUtils.isCompatible(Float.class, double.class), true);
|
||||
assertEquals("float -> boolean", ReflectionUtils.isCompatible(Float.class, boolean.class), false);
|
||||
|
||||
// test float conversions
|
||||
assertEquals("double -> char", ReflectionUtils.isCompatable(Double.class, char.class), false);
|
||||
assertEquals("double -> byte", ReflectionUtils.isCompatable(Double.class, byte.class), false);
|
||||
assertEquals("double -> short", ReflectionUtils.isCompatable(Double.class, short.class), false);
|
||||
assertEquals("double -> int", ReflectionUtils.isCompatable(Double.class, int.class), false);
|
||||
assertEquals("double -> long", ReflectionUtils.isCompatable(Double.class, long.class), false);
|
||||
assertEquals("double -> float", ReflectionUtils.isCompatable(Double.class, float.class), false);
|
||||
assertEquals("double -> double", ReflectionUtils.isCompatable(Double.class, double.class), true);
|
||||
assertEquals("double -> boolean", ReflectionUtils.isCompatable(Double.class, boolean.class), false);
|
||||
assertEquals("double -> char", ReflectionUtils.isCompatible(Double.class, char.class), false);
|
||||
assertEquals("double -> byte", ReflectionUtils.isCompatible(Double.class, byte.class), false);
|
||||
assertEquals("double -> short", ReflectionUtils.isCompatible(Double.class, short.class), false);
|
||||
assertEquals("double -> int", ReflectionUtils.isCompatible(Double.class, int.class), false);
|
||||
assertEquals("double -> long", ReflectionUtils.isCompatible(Double.class, long.class), false);
|
||||
assertEquals("double -> float", ReflectionUtils.isCompatible(Double.class, float.class), false);
|
||||
assertEquals("double -> double", ReflectionUtils.isCompatible(Double.class, double.class), true);
|
||||
assertEquals("double -> boolean", ReflectionUtils.isCompatible(Double.class, boolean.class), false);
|
||||
|
||||
// test float conversions
|
||||
assertEquals("boolean -> char", ReflectionUtils.isCompatable(Boolean.class, char.class), false);
|
||||
assertEquals("boolean -> byte", ReflectionUtils.isCompatable(Boolean.class, byte.class), false);
|
||||
assertEquals("boolean -> short", ReflectionUtils.isCompatable(Boolean.class, short.class), false);
|
||||
assertEquals("boolean -> int", ReflectionUtils.isCompatable(Boolean.class, int.class), false);
|
||||
assertEquals("boolean -> long", ReflectionUtils.isCompatable(Boolean.class, long.class), false);
|
||||
assertEquals("boolean -> float", ReflectionUtils.isCompatable(Boolean.class, float.class), false);
|
||||
assertEquals("boolean -> double", ReflectionUtils.isCompatable(Boolean.class, double.class), false);
|
||||
assertEquals("boolean -> boolean", ReflectionUtils.isCompatable(Boolean.class, boolean.class), true);
|
||||
assertEquals("boolean -> char", ReflectionUtils.isCompatible(Boolean.class, char.class), false);
|
||||
assertEquals("boolean -> byte", ReflectionUtils.isCompatible(Boolean.class, byte.class), false);
|
||||
assertEquals("boolean -> short", ReflectionUtils.isCompatible(Boolean.class, short.class), false);
|
||||
assertEquals("boolean -> int", ReflectionUtils.isCompatible(Boolean.class, int.class), false);
|
||||
assertEquals("boolean -> long", ReflectionUtils.isCompatible(Boolean.class, long.class), false);
|
||||
assertEquals("boolean -> float", ReflectionUtils.isCompatible(Boolean.class, float.class), false);
|
||||
assertEquals("boolean -> double", ReflectionUtils.isCompatible(Boolean.class, double.class), false);
|
||||
assertEquals("boolean -> boolean", ReflectionUtils.isCompatible(Boolean.class, boolean.class), true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue