|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.velocity.util.introspection.MethodMap
Inner Class Summary | |
static class |
MethodMap.AmbiguousException
simple distinguishable exception, used when we run across ambiguous overloading |
Field Summary | |
private static int |
INCOMPARABLE
|
private static int |
LESS_SPECIFIC
|
(package private) java.util.Map |
methodByNameMap
Keep track of all methods with the same name. |
private static int |
MORE_SPECIFIC
|
Constructor Summary | |
MethodMap()
|
Method Summary | |
void |
add(java.lang.reflect.Method method)
Add a method to a list of methods by name. |
java.lang.reflect.Method |
find(java.lang.String methodName,
java.lang.Object[] args)
Find a method. |
java.util.List |
get(java.lang.String key)
Return a list of methods with the same name. |
private static java.util.LinkedList |
getApplicables(java.util.List methods,
java.lang.Class[] classes)
Returns all methods that are applicable to actual argument types. |
private static java.lang.reflect.Method |
getMostSpecific(java.util.List methods,
java.lang.Class[] classes)
|
private static boolean |
isApplicable(java.lang.reflect.Method method,
java.lang.Class[] classes)
Returns true if the supplied method is applicable to actual argument types. |
private static boolean |
isMethodInvocationConvertible(java.lang.Class formal,
java.lang.Class actual)
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). |
private static boolean |
isStrictMethodInvocationConvertible(java.lang.Class formal,
java.lang.Class actual)
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. |
private static int |
moreSpecific(java.lang.Class[] c1,
java.lang.Class[] c2)
Determines which method signature (represented by a class array) is more specific. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static final int MORE_SPECIFIC
private static final int LESS_SPECIFIC
private static final int INCOMPARABLE
java.util.Map methodByNameMap
Constructor Detail |
public MethodMap()
Method Detail |
public void add(java.lang.reflect.Method method)
public java.util.List get(java.lang.String key)
String
- keypublic java.lang.reflect.Method find(java.lang.String methodName, java.lang.Object[] args) throws MethodMap.AmbiguousException
Find a method. Attempts to find the most specific applicable method using the algorithm described in the JLS section 15.12.2 (with the exception that it can't distinguish a primitive type argument from an object type argument, since in reflection primitive type arguments are represented by their object counterparts, so for an argument of type (say) java.lang.Integer, it will not be able to decide between a method that takes int and a method that takes java.lang.Integer as a parameter.
This turns out to be a relatively rare case where this is needed - however, functionality like this is needed.
methodName
- name of methodargs
- the actual arguments with which the method is calledMethodMap.AmbiguousException
- if there is more than one maximally
specific applicable methodprivate static java.lang.reflect.Method getMostSpecific(java.util.List methods, java.lang.Class[] classes) throws MethodMap.AmbiguousException
private static int moreSpecific(java.lang.Class[] c1, java.lang.Class[] c2)
c1
- first signature to comparec2
- second signature to compareprivate static java.util.LinkedList getApplicables(java.util.List methods, java.lang.Class[] classes)
methods
- list of all candidate methodsclasses
- the actual types of the argumentsprivate static boolean isApplicable(java.lang.reflect.Method method, java.lang.Class[] classes)
private static boolean isMethodInvocationConvertible(java.lang.Class formal, java.lang.Class actual)
formal
- the formal parameter type to which the actual
parameter type should be convertibleactual
- the actual parameter type.private static boolean isStrictMethodInvocationConvertible(java.lang.Class formal, java.lang.Class actual)
formal
- the formal parameter type to which the actual
parameter type should be convertibleactual
- the actual parameter type.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |