public class Clazz extends Object
Constructor and Description |
---|
Clazz() |
Modifier and Type | Method and Description |
---|---|
static List<?> |
getAllInterfaces(Class<?> cls)
Gets a
List 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 |
invoke(Class<?> clazz,
String methodName,
Class[] signature,
Object[] args)
Invokes a static method on a class.
|
static Object |
invoke(Object instance,
String methodName,
Class[] signature,
Object[] args)
Invokes a given method on the instance.
|
static Object |
newInstance(Class<?> clazz,
Class[] signature,
Object[] args)
Creates a new instance of the class
|
public Clazz()
public static boolean hasClazz(ClassLoader classLoader, String clazzName)
classLoader
- the classloader to be usedclazzName
- the name of the class to be loadedpublic static Class<?> getClazz(ClassLoader classLoader, String clazzName) throws ClassNotFoundException
classLoader
- the class loader to be usedclazzName
- the name of the clazz to be loadedClassNotFoundException
- the class was nout foundpublic static Object newInstance(Class<?> clazz, Class[] signature, Object[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException
clazz
- the class to be instantiatedsignature
- the signature of the constructorargs
- the arguments to be passedNoSuchMethodException
- the method was not foundInvocationTargetException
- an exception was thrown in the constructorInstantiationException
- the target class could not be instantiatedIllegalAccessException
- an field couldn't be accessedpublic static Object invoke(Object instance, String methodName, Class[] signature, Object[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
instance
- the instancemethodName
- the name of the method to be invokedsignature
- the signature of the methodargs
- the arguments for the method invocationNoSuchMethodException
- the method was not foundInvocationTargetException
- an exception was thrown in the constructorIllegalAccessException
- an field couldn't be accessedpublic static Object invoke(Class<?> clazz, String methodName, Class[] signature, Object[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
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 invocationNoSuchMethodException
- the method was not foundInvocationTargetException
- an exception was thrown in the constructorIllegalAccessException
- an field couldn't be accessedpublic static List<?> getAllInterfaces(Class<?> cls)
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.
cls
- the class to look up, may be null
List
of interfaces in order,
null
if null inputCopyright © 2004–1970 The Apache Software Foundation. All rights reserved.