final class ClassMap
extends java.lang.Object
Originally taken from the Velocity tree so we can be self-sufficient.
MethodKey
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ClassMap.MethodCache
This is the cache to store and look up the method information.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.reflect.Field> |
fieldCache
cache of fields.
|
private ClassMap.MethodCache |
methodCache
cache of methods.
|
Constructor and Description |
---|
ClassMap(java.lang.Class<?> aClass,
org.apache.commons.logging.Log log)
Standard constructor.
|
Modifier and Type | Method and Description |
---|---|
private static java.util.Map<java.lang.String,java.lang.reflect.Field> |
createFieldCache(java.lang.Class<?> clazz)
Creates a map of all public fields of a given class.
|
private static ClassMap.MethodCache |
createMethodCache(java.lang.Class<?> classToReflect,
org.apache.commons.logging.Log log)
Populate the Map of direct hits.
|
(package private) java.lang.reflect.Field |
findField(java.lang.Class<?> clazz,
java.lang.String fname)
Find a Field using its name.
|
(package private) java.lang.reflect.Method |
findMethod(MethodKey key)
Find a Method using the method name and parameter objects.
|
(package private) java.lang.reflect.Method[] |
get(java.lang.String methodName)
Gets all the methods with a given name from this map.
|
(package private) java.lang.String[] |
getFieldNames()
Gets the field names cached by this map.
|
(package private) java.lang.String[] |
getMethodNames()
Gets the methods names cached by this map.
|
private static void |
populateMethodCacheWith(ClassMap.MethodCache cache,
java.lang.Class<?> clazz,
org.apache.commons.logging.Log log)
Recurses up class hierarchy to get all super classes.
|
private static void |
populateMethodCacheWithInterface(ClassMap.MethodCache cache,
java.lang.Class<?> iface,
org.apache.commons.logging.Log log)
Recurses up interface hierarchy to get all super interfaces.
|
private final ClassMap.MethodCache methodCache
private final java.util.Map<java.lang.String,java.lang.reflect.Field> fieldCache
ClassMap(java.lang.Class<?> aClass, org.apache.commons.logging.Log log)
aClass
- the class to deconstruct.log
- the logger.java.lang.reflect.Field findField(java.lang.Class<?> clazz, java.lang.String fname)
The clazz parameter must be this ClassMap key.
clazz
- the class to introspectfname
- the field namejava.lang.String[] getFieldNames()
private static java.util.Map<java.lang.String,java.lang.reflect.Field> createFieldCache(java.lang.Class<?> clazz)
clazz
- the class to introspectjava.lang.String[] getMethodNames()
java.lang.reflect.Method[] get(java.lang.String methodName)
methodName
- the seeked methods namejava.lang.reflect.Method findMethod(MethodKey key) throws MethodKey.AmbiguousException
key
- the method keyMethodKey.AmbiguousException
- When more than one method is a match for the parameters.private static ClassMap.MethodCache createMethodCache(java.lang.Class<?> classToReflect, org.apache.commons.logging.Log log)
classToReflect
- the class to cachelog
- the Logprivate static void populateMethodCacheWithInterface(ClassMap.MethodCache cache, java.lang.Class<?> iface, org.apache.commons.logging.Log log)
cache
- the cache to filliface
- the interface to populate the cache fromlog
- the Logprivate static void populateMethodCacheWith(ClassMap.MethodCache cache, java.lang.Class<?> clazz, org.apache.commons.logging.Log log)
cache
- the cache to fillclazz
- the class to populate the cache fromlog
- the Log