Originally taken from the Velocity tree so we can be self-sufficient.
MethodKey
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | ClassMap.MethodCache
This is the cache to store and look up the method information. |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | fieldCache
cache of fields. |
| private final ClassMap. | methodCache
cache of methods. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private static Map | Returns: the map of fields (may be the empty map, can not be null)the class to introspect clazz)Creates a map of all public fields of a given class. |
| private static ClassMap. | Returns: a newly allocated & filled up cachethe class to cache classToReflect, Log the Log log)Populate the Map of direct hits. |
| pack-priv Field | |
| pack-priv Method | Returns: A Method object representing the method to invoke or null.the method key key)Find a Method using the method name and parameter objects. |
| pack-priv Method[] | |
| pack-priv String[] | |
| pack-priv String[] | |
| private static void | populateMethodCacheWith(ClassMap.
the cache to fill cache,the class to populate the cache from clazz, Log the Log log)Recurses up class hierarchy to get all super classes. |
| private static void | populateMethodCacheWithInterface(ClassMap.
the cache to fill cache,the interface to populate the cache from iface, Log the Log log)Recurses up interface hierarchy to get all super interfaces. |
| fieldCache | back to summary |
|---|---|
| private final Map<String, Field> fieldCache cache of fields. | |
| methodCache | back to summary |
|---|---|
| private final ClassMap. cache of methods. | |
| ClassMap | back to summary |
|---|---|
| pack-priv ClassMap(Class<?> aClass, Log log) Standard constructor. | |
| createFieldCache | back to summary |
|---|---|
| private static Map Creates a map of all public fields of a given class. | |
| createMethodCache | back to summary |
|---|---|
| private static ClassMap. Populate the Map of direct hits. These are taken from all the public methods that our class, its parents and their implemented interfaces provide.
| |
| findField | back to summary |
|---|---|
| pack-priv Field findField(final Class<?> clazz, final String fname) Find a Field using its name. The clazz parameter must be this ClassMap key. | |
| findMethod | back to summary |
|---|---|
| pack-priv Method findMethod(final MethodKey key) throws AmbiguousException Find a Method using the method name and parameter objects.
| |
| get | back to summary |
|---|---|
| pack-priv Method[] get(final String methodName) Gets all the methods with a given name from this map. | |
| getFieldNames | back to summary |
|---|---|
| pack-priv String[] getFieldNames() Gets the field names cached by this map.
| |
| getMethodNames | back to summary |
|---|---|
| pack-priv String[] getMethodNames() Gets the methods names cached by this map.
| |
| populateMethodCacheWith | back to summary |
|---|---|
| private static void populateMethodCacheWith(ClassMap. Recurses up class hierarchy to get all super classes.
| |
| populateMethodCacheWithInterface | back to summary |
|---|---|
| private static void populateMethodCacheWithInterface(ClassMap. Recurses up interface hierarchy to get all super interfaces.
| |
It stores the association between: - a key made of a method name & an array of argument types. - a method.
Since the invocation of the associated method is dynamic, there is no need (nor way) to differentiate between foo(int,int) & foo(Integer,Integer) since in practise, only the latter form will be used through a call. This of course, applies to all 8 primitive types.
| Modifier and Type | Field and Description |
|---|---|
| private static final Method | CACHE_MISS
The cache miss marker method. |
| private final MethodMap | methodMap
Map of methods that are searchable according to method parameters to find a match. |
| private final Map | methods
The method cache. |
| private static final int | PRIMITIVE_SIZE
The initial size of the primitive conversion map. |
| private static final Map | PRIMITIVE_TYPES
The primitive type to class conversion map. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public static Method | Returns: itself as a methodA method that returns itself used as a marker for cache miss, allows the underlying cache map to be strongly typed. |
| pack-priv Method | |
| pack-priv Method[] | |
| pack-priv String[] | |
| pack-priv static Class | Returns: the equivalent object classa may-be primitive type class parm)Converts a primitive type to its corresponding class. |
| pack-priv void |
| CACHE_MISS | back to summary |
|---|---|
| private static final Method CACHE_MISS The cache miss marker method. | |
| methodMap | back to summary |
|---|---|
| private final MethodMap methodMap Map of methods that are searchable according to method parameters to find a match. | |
| methods | back to summary |
|---|---|
| private final Map<MethodKey, Method> methods The method cache. Cache of Methods, or CACHE_MISS, keyed by method name and actual arguments used to find it. | |
| PRIMITIVE_SIZE | back to summary |
|---|---|
| private static final int PRIMITIVE_SIZE The initial size of the primitive conversion map. | |
| PRIMITIVE_TYPES | back to summary |
|---|---|
| private static final Map<Class<?>, Class<?>> PRIMITIVE_TYPES The primitive type to class conversion map. | |
| MethodCache | back to summary |
|---|---|
| pack-priv MethodCache() | |
| cacheMiss | back to summary |
|---|---|
| public static Method cacheMiss() A method that returns itself used as a marker for cache miss, allows the underlying cache map to be strongly typed.
| |
| get | back to summary |
|---|---|
| pack-priv Method get(final MethodKey methodKey) throws AmbiguousException Find a Method using the method name and parameter objects. Look in the methodMap for an entry. If found, it'll either be a CACHE_MISS, in which case we simply give up, or it'll be a Method, in which case, we return it. If nothing is found, then we must actually go and introspect the method from the MethodMap.
| |
| get | back to summary |
|---|---|
| pack-priv Method[] get(final String methodName) Gets all the methods with a given name from this map. | |
| names | back to summary |
|---|---|
| pack-priv String[] names() Gets all the method names from this map.
| |
| primitiveClass | back to summary |
|---|---|
| pack-priv static Class Converts a primitive type to its corresponding class. If the argument type is primitive then we want to convert our primitive type signature to the corresponding Object type so introspection for methods with primitive types will work correctly. | |
| put | back to summary |
|---|---|
| pack-priv void put(Method method) Adds a method to the map.
| |