Class MethodMap
java.lang.Object
org.apache.velocity.util.introspection.MethodMap
- Version:
- $Id$
- Author:
- Jason van Zyl, Bob McWhirter, Christoph Reck, Geir Magnusson Jr., Attila Szegedi, Claude Brisson
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Simple distinguishable exception, used when we run across ambiguous overloading. -
Constructor Summary
ConstructorDescriptionDefault constructorMethodMap
(TypeConversionHandler conversionHandler) Constructor with provided conversion handler -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a method to a list of methods by name.Find a method.Return a list of methods with the same name.static Method
getAccessibleMethodDeclaration
(Method method) Once we identified a best match of a specific call, walk up the chain of inheritance to find the first method which we are allowed to call through reflection.
-
Constructor Details
-
MethodMap
public MethodMap()Default constructor -
MethodMap
Constructor with provided conversion handler- Parameters:
conversionHandler
- conversion handler- Since:
- 2.0
-
-
Method Details
-
add
Add a method to a list of methods by name. For a particular class we are keeping track of all the methods with the same name.- Parameters:
method
-
-
get
Return a list of methods with the same name.- Parameters:
key
-- Returns:
- List list of methods
-
find
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.
- Parameters:
methodName
- name of methodargs
- the actual arguments with which the method is called- Returns:
- the most specific applicable method, or null if no method is applicable.
- Throws:
MethodMap.AmbiguousException
- if there is more than one maximally specific applicable method
-
getAccessibleMethodDeclaration
Once we identified a best match of a specific call, walk up the chain of inheritance to find the first method which we are allowed to call through reflection. This is needed to avoid IllegalAccessException, when a public API method is implemented by a class which is not exported.- Parameters:
method
-- Returns:
-