org.apache.commons.jxpath.util
Class MethodLookupUtils

java.lang.Object
  extended by org.apache.commons.jxpath.util.MethodLookupUtils

public class MethodLookupUtils
extends java.lang.Object

Method lookup utilities, which find static and non-static methods as well as constructors based on a name and list of parameters.

Version:
$Revision: 670727 $ $Date: 2008-06-23 15:10:38 -0500 (Mon, 23 Jun 2008) $
Author:
Dmitri Plotnikov

Field Summary
private static int APPROXIMATE_MATCH
           
private static int EXACT_MATCH
           
private static int NO_MATCH
           
 
Constructor Summary
MethodLookupUtils()
           
 
Method Summary
static java.lang.reflect.Constructor lookupConstructor(java.lang.Class targetClass, java.lang.Object[] parameters)
          Look up a constructor.
static java.lang.reflect.Method lookupMethod(java.lang.Class targetClass, java.lang.String name, java.lang.Object[] parameters)
          Look up a method.
static java.lang.reflect.Method lookupStaticMethod(java.lang.Class targetClass, java.lang.String name, java.lang.Object[] parameters)
          Look up a static method.
private static int matchParameterTypes(java.lang.Class[] types, java.lang.Object[] parameters)
          Return a match code of objects to types.
private static int matchType(java.lang.Class expected, java.lang.Object object)
          Return a match code between an object and type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_MATCH

private static final int NO_MATCH
See Also:
Constant Field Values

APPROXIMATE_MATCH

private static final int APPROXIMATE_MATCH
See Also:
Constant Field Values

EXACT_MATCH

private static final int EXACT_MATCH
See Also:
Constant Field Values
Constructor Detail

MethodLookupUtils

public MethodLookupUtils()
Method Detail

lookupConstructor

public static java.lang.reflect.Constructor lookupConstructor(java.lang.Class targetClass,
                                                              java.lang.Object[] parameters)
Look up a constructor.

Parameters:
targetClass - the class constructed
parameters - arguments
Returns:
Constructor found if any.

lookupStaticMethod

public static java.lang.reflect.Method lookupStaticMethod(java.lang.Class targetClass,
                                                          java.lang.String name,
                                                          java.lang.Object[] parameters)
Look up a static method.

Parameters:
targetClass - the owning class
name - method name
parameters - method parameters
Returns:
Method found if any

lookupMethod

public static java.lang.reflect.Method lookupMethod(java.lang.Class targetClass,
                                                    java.lang.String name,
                                                    java.lang.Object[] parameters)
Look up a method.

Parameters:
targetClass - owning class
name - method name
parameters - method parameters
Returns:
Method found if any

matchParameterTypes

private static int matchParameterTypes(java.lang.Class[] types,
                                       java.lang.Object[] parameters)
Return a match code of objects to types.

Parameters:
types - Class[] of expected types
parameters - Object[] to attempt to match
Returns:
int code

matchType

private static int matchType(java.lang.Class expected,
                             java.lang.Object object)
Return a match code between an object and type.

Parameters:
expected - class to test
object - object to test
Returns:
int code