Top Description Inners Fields Constructors Methods
org.apache.commons.jexl2.internal.introspection

public Class IntrospectorBase

extends Object
Class Inheritance
Imports
java.lang.reflect.Method, .Constructor, .Field, java.util.Map, .HashMap, .Iterator, .LinkedList, .List, org.apache.commons.logging.Log

This basic function of this class is to return a Method object for a particular class given the name of a method and the parameters to the method in the form of an Object[]

The first time the Introspector sees a class it creates a class method map for the class in question. Basically the class method map is a Hastable where Method objects are keyed by a concatenation of the method name and the names of classes that make up the parameters. For example, a method with the following signature: public void method(String a, StringBuffer b) would be mapped by the key: "method" + "java.lang.String" + "java.lang.StringBuffer" This mapping is performed for all the methods in a class and stored.

Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
IntrospectorBase.CacheMiss

A Constructor get cache-miss.

Field Summary

Modifier and TypeField and Description
private final Map<Class<?>, ClassMap>
classMethodMaps

Holds the method maps for the classes we know about, keyed by Class.

private final Map<String, Class<?>>
constructibleClasses

Holds the set of classes we have introspected.

private final Map<MethodKey, Constructor<?>>
constructorsMap

Holds the map of classes ctors we know about as well as unknown ones.

private static final Constructor<?>
CTOR_MISS

The cache-miss marker for the constructors map.

private ClassLoader
loader

The class loader used to solve constructors if needed.

protected final Log
rlog

the logger.

Constructor Summary

AccessConstructor and Description
public
IntrospectorBase(Log
the logger to use
log
)

Create the introspector.

Method Summary

Modifier and TypeMethod and Description
public Class<?>

Returns:

the class instance or null if it could not be found
getClassByName
(String
the class name
className
)

Gets a class by name through this introspector class loader.

public Constructor<?>

Returns:

The desired constructor object or null if no unambiguous constructor could be found through introspection.
getConstructor
(final MethodKey
Key of the constructor being searched for
key
)

Gets the constructor defined by the MethodKey.

public Constructor<?>

Returns:

The desired constructor object or null if no unambiguous constructor could be found through introspection.
getConstructor
(final Class<?>
the class we want to instantiate
c
,
final MethodKey
Key of the constructor being searched for
key
)

Gets the constructor defined by the MethodKey.

public Field

Returns:

the desired field or null if it does not exist or is not accessible
getField
(Class<?>
Class in which the field search is taking place
c
,
String
Name of the field being searched for
key
)

Gets the field named by key for the class c.

public String[]

Returns:

the class field names
getFieldNames
(Class<?>
the class
c
)

Gets the array of accessible field names known for a given class.

private ClassMap

Returns:

the class map
getMap
(Class<?>
the class
c
)

Gets the ClassMap for a given class.

public Method

Returns:

The desired method object
getMethod
(Class<?>
Class in which the method search is taking place
c
,
MethodKey
Key of the method being searched for
key
)

Gets the method defined by the MethodKey for the class c.

public String[]

Returns:

the class method names
getMethodNames
(Class<?>
the class
c
)

Gets the array of accessible methods names known for a given class.

public Method[]

Returns:

the array of methods (null or not empty)
getMethods
(Class<?>
the class
c
,
String
the method name
methodName
)

Gets the array of accessible method known for a given class.

private static boolean

Returns:

true if clazz was loaded through the loader, false otherwise
isLoadedBy
(ClassLoader
the class loader
loader
,
Class<?>
the class to check
clazz
)

Checks whether a class is loaded through a given class loader or one of its ascendants.

public void
setLoader(ClassLoader
the class loader; if null, use this instance class loader
cloader
)

Sets the class loader used to solve constructors.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classMethodMapsback to summary
private final Map<Class<?>, ClassMap> classMethodMaps

Holds the method maps for the classes we know about, keyed by Class.

constructibleClassesback to summary
private final Map<String, Class<?>> constructibleClasses

Holds the set of classes we have introspected.

constructorsMapback to summary
private final Map<MethodKey, Constructor<?>> constructorsMap

Holds the map of classes ctors we know about as well as unknown ones.

CTOR_MISSback to summary
private static final Constructor<?> CTOR_MISS

The cache-miss marker for the constructors map.

loaderback to summary
private ClassLoader loader

The class loader used to solve constructors if needed.

rlogback to summary
protected final Log rlog

the logger.

Constructor Detail

IntrospectorBaseback to summary
public IntrospectorBase(Log log)

Create the introspector.

Parameters
log:Log

the logger to use

Method Detail

getClassByNameback to summary
public Class<?> getClassByName(String className)

Gets a class by name through this introspector class loader.

Parameters
className:String

the class name

Returns:Class<?>

the class instance or null if it could not be found

getConstructorback to summary
public Constructor<?> getConstructor(final MethodKey key)

Gets the constructor defined by the MethodKey.

Parameters
key:MethodKey

Key of the constructor being searched for

Returns:Constructor<?>

The desired constructor object or null if no unambiguous constructor could be found through introspection.

getConstructorback to summary
public Constructor<?> getConstructor(final Class<?> c, final MethodKey key)

Gets the constructor defined by the MethodKey.

Parameters
c:Class<?>

the class we want to instantiate

key:MethodKey

Key of the constructor being searched for

Returns:Constructor<?>

The desired constructor object or null if no unambiguous constructor could be found through introspection.

getFieldback to summary
public Field getField(Class<?> c, String key)

Gets the field named by key for the class c.

Parameters
c:Class<?>

Class in which the field search is taking place

key:String

Name of the field being searched for

Returns:Field

the desired field or null if it does not exist or is not accessible

getFieldNamesback to summary
public String[] getFieldNames(Class<?> c)

Gets the array of accessible field names known for a given class.

Parameters
c:Class<?>

the class

Returns:String[]

the class field names

getMapback to summary
private ClassMap getMap(Class<?> c)

Gets the ClassMap for a given class.

Parameters
c:Class<?>

the class

Returns:ClassMap

the class map

getMethodback to summary
public Method getMethod(Class<?> c, MethodKey key)

Gets the method defined by the MethodKey for the class c.

Parameters
c:Class<?>

Class in which the method search is taking place

key:MethodKey

Key of the method being searched for

Returns:Method

The desired method object

Exceptions
AmbiguousException:
if no unambiguous method could be found through introspection
getMethodNamesback to summary
public String[] getMethodNames(Class<?> c)

Gets the array of accessible methods names known for a given class.

Parameters
c:Class<?>

the class

Returns:String[]

the class method names

getMethodsback to summary
public Method[] getMethods(Class<?> c, String methodName)

Gets the array of accessible method known for a given class.

Parameters
c:Class<?>

the class

methodName:String

the method name

Returns:Method[]

the array of methods (null or not empty)

isLoadedByback to summary
private static boolean isLoadedBy(ClassLoader loader, Class<?> clazz)

Checks whether a class is loaded through a given class loader or one of its ascendants.

Parameters
loader:ClassLoader

the class loader

clazz:Class<?>

the class to check

Returns:boolean

true if clazz was loaded through the loader, false otherwise

setLoaderback to summary
public void setLoader(ClassLoader cloader)

Sets the class loader used to solve constructors.

Also cleans the constructors and methods caches.

Parameters
cloader:ClassLoader

the class loader; if null, use this instance class loader

org.apache.commons.jexl2.internal.introspection back to summary

private Class IntrospectorBase.CacheMiss

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.jexl2.internal.introspection.IntrospectorBase.CacheMiss

A Constructor get cache-miss.

Constructor Summary

AccessConstructor and Description
public
CacheMiss()

The constructor used as cache-miss.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CacheMissback to summary
public CacheMiss()

The constructor used as cache-miss.

Annotations
@SuppressWarnings:unused