public class Clazz
extends java.lang.Object
Constructor and Description |
---|
Clazz() |
Modifier and Type | Method and Description |
---|---|
static java.util.List |
getAllInterfaces(java.lang.Class cls)
Gets a
List of all interfaces implemented by the given
class and its superclasses. |
static java.lang.Class |
getClazz(java.lang.ClassLoader classLoader,
java.lang.String clazzName)
Loads a class with the given name.
|
static boolean |
hasClazz(java.lang.ClassLoader classLoader,
java.lang.String clazzName)
Determine if the class can be loaded.
|
static java.lang.Object |
invoke(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] signature,
java.lang.Object[] args)
Invokes a static method on a class.
|
static java.lang.Object |
invoke(java.lang.Object instance,
java.lang.String methodName,
java.lang.Class[] signature,
java.lang.Object[] args)
Invokes a given method on the instance.
|
static java.lang.Object |
newInstance(java.lang.Class clazz,
java.lang.Class[] signature,
java.lang.Object[] args)
Creates a new instance of the class
|
public static boolean hasClazz(java.lang.ClassLoader classLoader, java.lang.String clazzName)
classLoader
- the classloader to be usedclazzName
- the name of the class to be loadedpublic static java.lang.Class getClazz(java.lang.ClassLoader classLoader, java.lang.String clazzName) throws java.lang.ClassNotFoundException
classLoader
- the class loader to be usedclazzName
- the name of the clazz to be loadedjava.lang.ClassNotFoundException
- the class was nout foundpublic static java.lang.Object newInstance(java.lang.Class clazz, java.lang.Class[] signature, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException, java.lang.IllegalAccessException
clazz
- the class to be instantiatedsignature
- the signature of the constructorargs
- the arguments to be passedjava.lang.NoSuchMethodException
- the method was not foundjava.lang.reflect.InvocationTargetException
- an exception was thrown in the constructorjava.lang.InstantiationException
- the target class could not be instantiatedjava.lang.IllegalAccessException
- an field couldn't be accessedpublic static java.lang.Object invoke(java.lang.Object instance, java.lang.String methodName, java.lang.Class[] signature, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
instance
- the instancemethodName
- the name of the method to be invokedsignature
- the signature of the methodargs
- the arguments for the method invocationjava.lang.NoSuchMethodException
- the method was not foundjava.lang.reflect.InvocationTargetException
- an exception was thrown in the constructorjava.lang.IllegalAccessException
- an field couldn't be accessedpublic static java.lang.Object invoke(java.lang.Class clazz, java.lang.String methodName, java.lang.Class[] signature, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.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 invocationjava.lang.NoSuchMethodException
- the method was not foundjava.lang.reflect.InvocationTargetException
- an exception was thrown in the constructorjava.lang.IllegalAccessException
- an field couldn't be accessedpublic static java.util.List getAllInterfaces(java.lang.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 © 2000-2013 Apache Software Foundation. All Rights Reserved.