parser.absconparseur
Class ReflectionManager

java.lang.Object
  extended by parser.absconparseur.ReflectionManager

public class ReflectionManager
extends Object

This class allows performing some operations based on reflection.


Nested Class Summary
static class ReflectionManager.DigestedFields
           
 
Field Summary
static char JAR_SEPARATOR_CHAR
           
 
Constructor Summary
ReflectionManager()
           
 
Method Summary
static ReflectionManager.DigestedFields getAllFieldsOfFieldOfInheritingFrom(Object object, Class targetClass)
           
static Object getArrayInstance(String className, int[] lengths)
          An array with elements of the given type is built.
static String[][] getDescriptionOfDeclaredFieldsOf(Object object)
          Returns a description (names and values) of the fields of the given object.
static Enumeration getEntriesOf(String jarName)
           
static Field getFirstFieldOfWithType(Class cl, Class<?> targetClass)
           
static Class getFirstInnerClassOfInheritingFrom(Class cl, Class<?> targetClass)
           
static Object getInstanceOf(Class clazz)
           
static Object getInstanceOf(String className)
          An object of the class whose name is given is built.
static Object getInstanceOf(String className, Class rootClass)
          An object of the class whose name is given is built.
static Object getInstanceOf(String className, Object[] objects)
          An object of the class whose name is given is built.
static String getStringConcatenationOfDeclaredFieldsOf(Object object)
           
static Object invokeStaticMethod(String className, String methodName)
           
static String searchAbsoluteNameOf(String basicPackage, String className)
          Returns the absolute name of the class whose name is given.
static Class[] searchClassesInheritingFrom(Class rootClass, int requiredModifiers, int forbiddenModifiers)
          Returns all classes that inherit from the given root class (by considering the CLASSPATH environment variable).
static List<Class> searchClassesInheritingFromIn(Class rootClass, File directory, int requiredModifiers, int forbiddenModifiers)
          Returns a list of all (not abstract) classes which inherit from the given root class and which can be found from the given directory.
static Constructor searchFirstConstructor(Class clazz, int modifiers)
           
static Constructor[] searchFirstConstructors(Class[] classes, int modifiers)
           
static Method searchMethod(Class clazz, String methodName, int modifiers)
           
static Method[] searchMethods(Class[] classes, String methodName, int modifiers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAR_SEPARATOR_CHAR

public static final char JAR_SEPARATOR_CHAR
See Also:
Constant Field Values
Constructor Detail

ReflectionManager

public ReflectionManager()
Method Detail

getFirstInnerClassOfInheritingFrom

public static Class getFirstInnerClassOfInheritingFrom(Class cl,
                                                       Class<?> targetClass)

searchClassesInheritingFromIn

public static List<Class> searchClassesInheritingFromIn(Class rootClass,
                                                        File directory,
                                                        int requiredModifiers,
                                                        int forbiddenModifiers)
Returns a list of all (not abstract) classes which inherit from the given root class and which can be found from the given directory.

Parameters:
rootClass - a given class
directory - a given directory
requiredModifiers - a propagationSet of required modifiers for all subclasses
forbiddenModifiers - a propagationSet of forbidden modifiers for all subclasses

getEntriesOf

public static Enumeration getEntriesOf(String jarName)

searchClassesInheritingFrom

public static Class[] searchClassesInheritingFrom(Class rootClass,
                                                  int requiredModifiers,
                                                  int forbiddenModifiers)
Returns all classes that inherit from the given root class (by considering the CLASSPATH environment variable).

Parameters:
rootClass - a given class
requiredModifiers - a set of required modifiers for all subclasses
forbiddenModifiers - a set of forbidden modifiers for all subclasses

getFirstFieldOfWithType

public static Field getFirstFieldOfWithType(Class cl,
                                            Class<?> targetClass)

getAllFieldsOfFieldOfInheritingFrom

public static ReflectionManager.DigestedFields getAllFieldsOfFieldOfInheritingFrom(Object object,
                                                                                   Class targetClass)

getDescriptionOfDeclaredFieldsOf

public static String[][] getDescriptionOfDeclaredFieldsOf(Object object)
Returns a description (names and values) of the fields of the given object.


getStringConcatenationOfDeclaredFieldsOf

public static String getStringConcatenationOfDeclaredFieldsOf(Object object)

searchAbsoluteNameOf

public static String searchAbsoluteNameOf(String basicPackage,
                                          String className)
Returns the absolute name of the class whose name is given.

Parameters:
basicPackage - the (absolute) name of a package
className - the name of a class that must be found in the package (or subpackages) whose name is given

searchMethod

public static Method searchMethod(Class clazz,
                                  String methodName,
                                  int modifiers)

searchMethods

public static Method[] searchMethods(Class[] classes,
                                     String methodName,
                                     int modifiers)

searchFirstConstructor

public static Constructor searchFirstConstructor(Class clazz,
                                                 int modifiers)

searchFirstConstructors

public static Constructor[] searchFirstConstructors(Class[] classes,
                                                    int modifiers)

getInstanceOf

public static Object getInstanceOf(Class clazz)

getInstanceOf

public static Object getInstanceOf(String className)
An object of the class whose name is given is built. Be careful: the default constructor is used.

Parameters:
className - the name of a class
Returns:
an object of the class whose name is given

invokeStaticMethod

public static Object invokeStaticMethod(String className,
                                        String methodName)

getInstanceOf

public static Object getInstanceOf(String className,
                                   Class rootClass)
An object of the class whose name is given is built. There are two restrictions:

getInstanceOf

public static Object getInstanceOf(String className,
                                   Object[] objects)
An object of the class whose name is given is built. The given objects ared passed to the constructor.

Parameters:
className - the name of a class
objects - the parameters used by the constructor
Returns:
an object of the class whose name is given

getArrayInstance

public static Object getArrayInstance(String className,
                                      int[] lengths)
An array with elements of the given type is built.

Parameters:
className - the name of a class
lengths - the dimensions of the array
Returns:
an array


Copyright © 2012. All Rights Reserved.