Klasse Clazz
java.lang.Object
org.apache.fulcrum.yaafi.framework.reflection.Clazz
Helper clazz to do a little bit of reflection magic.
- Autor:
- Siegfried Goeschl
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic List<?>
getAllInterfaces
(Class<?> cls) Gets aList
of all interfaces implemented by the given class and its superclasses.static Class<?>
getClazz
(ClassLoader classLoader, String clazzName) Loads a class with the given name.static boolean
hasClazz
(ClassLoader classLoader, String clazzName) Determine if the class can be loaded.static Object
Invokes a static method on a class.static Object
Invokes a given method on the instance.static Object
newInstance
(Class<?> clazz, Class[] signature, Object[] args) Creates a new instance of the class
-
Konstruktordetails
-
Clazz
public Clazz()
-
-
Methodendetails
-
hasClazz
Determine if the class can be loaded.- Parameter:
classLoader
- the classloader to be usedclazzName
- the name of the class to be loaded- Gibt zurück:
- true if the class was found
-
getClazz
public static Class<?> getClazz(ClassLoader classLoader, String clazzName) throws ClassNotFoundException Loads a class with the given name.- Parameter:
classLoader
- the class loader to be usedclazzName
- the name of the clazz to be loaded- Gibt zurück:
- the loaded class
- Löst aus:
ClassNotFoundException
- the class was nout found
-
newInstance
public static Object newInstance(Class<?> clazz, Class[] signature, Object[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException Creates a new instance of the class- Parameter:
clazz
- the class to be instantiatedsignature
- the signature of the constructorargs
- the arguments to be passed- Gibt zurück:
- the newly created instance
- Löst aus:
NoSuchMethodException
- the method was not foundInvocationTargetException
- an exception was thrown in the constructorInstantiationException
- the target class could not be instantiatedIllegalAccessException
- an field couldn't be accessed
-
invoke
public static Object invoke(Object instance, String methodName, Class[] signature, Object[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException Invokes a given method on the instance.- Parameter:
instance
- the instancemethodName
- the name of the method to be invokedsignature
- the signature of the methodargs
- the arguments for the method invocation- Gibt zurück:
- the result of the method invocation
- Löst aus:
NoSuchMethodException
- the method was not foundInvocationTargetException
- an exception was thrown in the constructorIllegalAccessException
- an field couldn't be accessed
-
invoke
public static Object invoke(Class<?> clazz, String methodName, Class[] signature, Object[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException Invokes a static method on a class.- Parameter:
clazz
- the class instance to work onmethodName
- the name of the method to be invokedsignature
- the signature of the methodargs
- the arguments for the method invocation- Gibt zurück:
- the result of the method invocation
- Löst aus:
NoSuchMethodException
- the method was not foundInvocationTargetException
- an exception was thrown in the constructorIllegalAccessException
- an field couldn't be accessed
-
getAllInterfaces
Gets a
List
of all interfaces implemented by the given class and its superclasses.The order is determined by looking through each interface in turn as declared in the source file and following its hierarchy up. Then each superclass is considered in the same way. Later duplicates are ignored, so the order is maintained.
- Parameter:
cls
- the class to look up, may benull
- Gibt zurück:
- the
List
of interfaces in order,null
if null input
-