koala.dynamicjava.classinfo
Class ClassInfoUtilities

java.lang.Object
  extended bykoala.dynamicjava.classinfo.ClassInfoUtilities

public class ClassInfoUtilities
extends java.lang.Object

This class contains a collection of utility methods for reflection.


Method Summary
static FieldInfo getField(ClassInfo cl, java.lang.String name)
          Returns a field with the given name declared in the given class or in the superclasses of the given class
static java.util.List getMethods(ClassInfo cl, java.lang.String name, int params)
          Gets all the methods with the given name in the given class or super classes.
static FieldInfo getOuterField(ClassInfo cl, java.lang.String name)
          Returns a field with the given name declared in one of the outer classes of the given class
static boolean isAssignableFrom(ClassInfo c1, ClassInfo c2)
          Tests whether c1 is assignable from c2.
static ConstructorInfo lookupConstructor(ClassInfo cl, ClassInfo[] ac)
          Looks for a constructor in the given class or in super classes of this class.
static MethodInfo lookupMethod(ClassInfo cl, java.lang.String name, ClassInfo[] ac)
          Looks for a method in the given class or in super classes of this class.
static MethodInfo lookupOuterMethod(ClassInfo cl, java.lang.String name, ClassInfo[] ac)
          Looks up for a method in an outer classes of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

lookupConstructor

public static ConstructorInfo lookupConstructor(ClassInfo cl,
                                                ClassInfo[] ac)
                                         throws java.lang.NoSuchMethodException
Looks for a constructor in the given class or in super classes of this class.

Parameters:
cl - the class of which the constructor is a member
ac - the arguments classes (possibly not the exact declaring classes)
Throws:
java.lang.NoSuchMethodException

isAssignableFrom

public static boolean isAssignableFrom(ClassInfo c1,
                                       ClassInfo c2)
Tests whether c1 is assignable from c2. This function works on every types (primitive or not)

Parameters:
c1 - a class info
c2 - a class info

getField

public static FieldInfo getField(ClassInfo cl,
                                 java.lang.String name)
                          throws java.lang.NoSuchFieldException,
                                 AmbiguousFieldException
Returns a field with the given name declared in the given class or in the superclasses of the given class

Parameters:
cl - the class where the field must look for the field
name - the name of the field
Throws:
java.lang.NoSuchFieldException
AmbiguousFieldException

getOuterField

public static FieldInfo getOuterField(ClassInfo cl,
                                      java.lang.String name)
                               throws java.lang.NoSuchFieldException,
                                      AmbiguousFieldException
Returns a field with the given name declared in one of the outer classes of the given class

Parameters:
cl - the inner class
name - the name of the field
Throws:
java.lang.NoSuchFieldException
AmbiguousFieldException

lookupMethod

public static MethodInfo lookupMethod(ClassInfo cl,
                                      java.lang.String name,
                                      ClassInfo[] ac)
                               throws java.lang.NoSuchMethodException
Looks for a method in the given class or in super classes of this class.

Parameters:
cl - the class of which the method is a member
name - the name of the method
ac - the arguments classes (possibly not the exact declaring classes)
Throws:
java.lang.NoSuchMethodException

lookupOuterMethod

public static MethodInfo lookupOuterMethod(ClassInfo cl,
                                           java.lang.String name,
                                           ClassInfo[] ac)
                                    throws java.lang.NoSuchMethodException
Looks up for a method in an outer classes of this class.

Parameters:
cl - the inner class
name - the name of the method
ac - the arguments classes (possibly not the exact declaring classes)
Throws:
java.lang.NoSuchMethodException

getMethods

public static java.util.List getMethods(ClassInfo cl,
                                        java.lang.String name,
                                        int params)
Gets all the methods with the given name in the given class or super classes. Even the redefined methods are returned.

Parameters:
cl - the class where the method was declared
name - the name of the method
params - the number of parameters
Returns:
a list that contains the found methods, an empty list if no matching method was found.


Copyright © 2001 Stephane Hillion. All Rights Reserved.