Author: rahul Date: Sat Aug 8 03:03:14 2009 New Revision: 802289 URL: http://svn.apache.org/viewvc?rev=802289&view=rev Log: Class outline was really hard to read, reordering couple of methods. No functional change.
Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/util/introspection/MethodKey.java Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/util/introspection/MethodKey.java URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/util/introspection/MethodKey.java?rev=802289&r1=802288&r2=802289&view=diff ============================================================================== --- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/util/introspection/MethodKey.java (original) +++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl/util/introspection/MethodKey.java Sat Aug 8 03:03:14 2009 @@ -62,14 +62,6 @@ private static final int HASH = 37; /** - * Creates a key from a method. - * @param aMethod the method to generate the key from. - */ - MethodKey(Method aMethod) { - this(aMethod.getName(), aMethod.getParameterTypes()); - } - - /** * Creates a key from a method name and a set of arguments. * @param aMethod the method to generate the key from * @param args the intended method arguments @@ -97,6 +89,14 @@ } /** + * Creates a key from a method. + * @param aMethod the method to generate the key from. + */ + MethodKey(Method aMethod) { + this(aMethod.getName(), aMethod.getParameterTypes()); + } + + /** * Creates a key from a method name and a set of parameters. * @param aMethod the method to generate the key from * @param args the intended method parameters @@ -201,6 +201,148 @@ } /** + * Determines whether a type represented by a class object is + * convertible to another type represented by a class object using a + * method invocation conversion, treating object types of primitive + * types as if they were primitive types (that is, a Boolean actual + * parameter type matches boolean primitive formal type). This behavior + * is because this method is used to determine applicable methods for + * an actual parameter list, and primitive types are represented by + * their object duals in reflective method calls. + * + * @param formal the formal parameter type to which the actual + * parameter type should be convertible + * @param actual the actual parameter type. + * @param possibleVarArg whether or not we're dealing with the last parameter + * in the method declaration + * @return true if either formal type is assignable from actual type, + * or formal is a primitive type and actual is its corresponding object + * type or an object type of a primitive type that can be converted to + * the formal type. + */ + public static boolean isInvocationConvertible(Class<?> formal, + Class<?> actual, + boolean possibleVarArg) { + /* if it's a null, it means the arg was null */ + if (actual == null && !formal.isPrimitive()) { + return true; + } + + /* Check for identity or widening reference conversion */ + if (actual != null && formal.isAssignableFrom(actual)) { + return true; + } + + // CSOFF: NeedBraces + /* Check for boxing with widening primitive conversion. Note that + * actual parameters are never primitives. */ + if (formal.isPrimitive()) { + if (formal == Boolean.TYPE && actual == Boolean.class) + return true; + if (formal == Character.TYPE && actual == Character.class) + return true; + if (formal == Byte.TYPE && actual == Byte.class) + return true; + if (formal == Short.TYPE + && (actual == Short.class || actual == Byte.class)) + return true; + if (formal == Integer.TYPE + && (actual == Integer.class || actual == Short.class + || actual == Byte.class)) + return true; + if (formal == Long.TYPE + && (actual == Long.class || actual == Integer.class + || actual == Short.class || actual == Byte.class)) + return true; + if (formal == Float.TYPE + && (actual == Float.class || actual == Long.class + || actual == Integer.class || actual == Short.class + || actual == Byte.class)) + return true; + if (formal == Double.TYPE + && (actual == Double.class || actual == Float.class + || actual == Long.class || actual == Integer.class + || actual == Short.class || actual == Byte.class)) + return true; + } + // CSON: NeedBraces + + /* Check for vararg conversion. */ + if (possibleVarArg && formal.isArray()) { + if (actual != null && actual.isArray()) { + actual = actual.getComponentType(); + } + return isInvocationConvertible(formal.getComponentType(), + actual, false); + } + return false; + } + + /** + * Determines whether a type represented by a class object is + * convertible to another type represented by a class object using a + * method invocation conversion, without matching object and primitive + * types. This method is used to determine the more specific type when + * comparing signatures of methods. + * + * @param formal the formal parameter type to which the actual + * parameter type should be convertible + * @param actual the actual parameter type. + * @param possibleVarArg whether or not we're dealing with the last parameter + * in the method declaration + * @return true if either formal type is assignable from actual type, + * or formal and actual are both primitive types and actual can be + * subject to widening conversion to formal. + */ + public static boolean isStrictInvocationConvertible(Class<?> formal, + Class<?> actual, + boolean possibleVarArg) { + /* we shouldn't get a null into, but if so */ + if (actual == null && !formal.isPrimitive()) { + return true; + } + + /* Check for identity or widening reference conversion */ + if (formal.isAssignableFrom(actual)) { + return true; + } + + // CSOFF: NeedBraces + /* Check for widening primitive conversion. */ + if (formal.isPrimitive()) { + if (formal == Short.TYPE && (actual == Byte.TYPE)) + return true; + if (formal == Integer.TYPE + && (actual == Short.TYPE || actual == Byte.TYPE)) + return true; + if (formal == Long.TYPE + && (actual == Integer.TYPE || actual == Short.TYPE + || actual == Byte.TYPE)) + return true; + if (formal == Float.TYPE + && (actual == Long.TYPE || actual == Integer.TYPE + || actual == Short.TYPE || actual == Byte.TYPE)) + return true; + if (formal == Double.TYPE + && (actual == Float.TYPE || actual == Long.TYPE + || actual == Integer.TYPE || actual == Short.TYPE + || actual == Byte.TYPE)) + return true; + } + // CSON: NeedBraces + + /* Check for vararg conversion. */ + if (possibleVarArg && formal.isArray()) { + if (actual != null && actual.isArray()) { + actual = actual.getComponentType(); + } + return isStrictInvocationConvertible(formal.getComponentType(), + actual, false); + } + return false; + } + + /** * whether a method/ctor is more specific than a previously compared one. */ private static final int MORE_SPECIFIC = 0; @@ -478,147 +620,6 @@ } } - /** - * Determines whether a type represented by a class object is - * convertible to another type represented by a class object using a - * method invocation conversion, treating object types of primitive - * types as if they were primitive types (that is, a Boolean actual - * parameter type matches boolean primitive formal type). This behavior - * is because this method is used to determine applicable methods for - * an actual parameter list, and primitive types are represented by - * their object duals in reflective method calls. - * - * @param formal the formal parameter type to which the actual - * parameter type should be convertible - * @param actual the actual parameter type. - * @param possibleVarArg whether or not we're dealing with the last parameter - * in the method declaration - * @return true if either formal type is assignable from actual type, - * or formal is a primitive type and actual is its corresponding object - * type or an object type of a primitive type that can be converted to - * the formal type. - */ - public static boolean isInvocationConvertible(Class<?> formal, - Class<?> actual, - boolean possibleVarArg) { - /* if it's a null, it means the arg was null */ - if (actual == null && !formal.isPrimitive()) { - return true; - } - - /* Check for identity or widening reference conversion */ - if (actual != null && formal.isAssignableFrom(actual)) { - return true; - } - - // CSOFF: NeedBraces - /* Check for boxing with widening primitive conversion. Note that - * actual parameters are never primitives. */ - if (formal.isPrimitive()) { - if (formal == Boolean.TYPE && actual == Boolean.class) - return true; - if (formal == Character.TYPE && actual == Character.class) - return true; - if (formal == Byte.TYPE && actual == Byte.class) - return true; - if (formal == Short.TYPE - && (actual == Short.class || actual == Byte.class)) - return true; - if (formal == Integer.TYPE - && (actual == Integer.class || actual == Short.class - || actual == Byte.class)) - return true; - if (formal == Long.TYPE - && (actual == Long.class || actual == Integer.class - || actual == Short.class || actual == Byte.class)) - return true; - if (formal == Float.TYPE - && (actual == Float.class || actual == Long.class - || actual == Integer.class || actual == Short.class - || actual == Byte.class)) - return true; - if (formal == Double.TYPE - && (actual == Double.class || actual == Float.class - || actual == Long.class || actual == Integer.class - || actual == Short.class || actual == Byte.class)) - return true; - } - // CSON: NeedBraces - - /* Check for vararg conversion. */ - if (possibleVarArg && formal.isArray()) { - if (actual != null && actual.isArray()) { - actual = actual.getComponentType(); - } - return isInvocationConvertible(formal.getComponentType(), - actual, false); - } - return false; - } - - /** - * Determines whether a type represented by a class object is - * convertible to another type represented by a class object using a - * method invocation conversion, without matching object and primitive - * types. This method is used to determine the more specific type when - * comparing signatures of methods. - * - * @param formal the formal parameter type to which the actual - * parameter type should be convertible - * @param actual the actual parameter type. - * @param possibleVarArg whether or not we're dealing with the last parameter - * in the method declaration - * @return true if either formal type is assignable from actual type, - * or formal and actual are both primitive types and actual can be - * subject to widening conversion to formal. - */ - public static boolean isStrictInvocationConvertible(Class<?> formal, - Class<?> actual, - boolean possibleVarArg) { - /* we shouldn't get a null into, but if so */ - if (actual == null && !formal.isPrimitive()) { - return true; - } - - /* Check for identity or widening reference conversion */ - if (formal.isAssignableFrom(actual)) { - return true; - } - - // CSOFF: NeedBraces - /* Check for widening primitive conversion. */ - if (formal.isPrimitive()) { - if (formal == Short.TYPE && (actual == Byte.TYPE)) - return true; - if (formal == Integer.TYPE - && (actual == Short.TYPE || actual == Byte.TYPE)) - return true; - if (formal == Long.TYPE - && (actual == Integer.TYPE || actual == Short.TYPE - || actual == Byte.TYPE)) - return true; - if (formal == Float.TYPE - && (actual == Long.TYPE || actual == Integer.TYPE - || actual == Short.TYPE || actual == Byte.TYPE)) - return true; - if (formal == Double.TYPE - && (actual == Float.TYPE || actual == Long.TYPE - || actual == Integer.TYPE || actual == Short.TYPE - || actual == Byte.TYPE)) - return true; - } - // CSON: NeedBraces - - /* Check for vararg conversion. */ - if (possibleVarArg && formal.isArray()) { - if (actual != null && actual.isArray()) { - actual = actual.getComponentType(); - } - return isStrictInvocationConvertible(formal.getComponentType(), - actual, false); - } - return false; - } /** * The parameter matching service for methods.