|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.dandelion.datatables.core.util.ClassUtils
public class ClassUtils
Helper class used for all reflection stuff.
| Constructor Summary | |
|---|---|
ClassUtils()
|
|
| Method Summary | |
|---|---|
static Boolean |
canBeUsed(String className)
Test if a class exists in the classPath, trying to load it with its name. |
static List<Class<?>> |
getAllClassesInPackage(String packageName)
|
static Class<?> |
getClass(String className)
Tries to load a class from its name. |
static Object |
getNewInstance(Class<?> klass)
Instanciate a class. |
static List<Class<?>> |
getSubClassesInPackage(String packageName,
Class<?> superClass)
|
static Object |
invokeMethod(Object obj,
String methodName,
Object[] args)
Invoke a method called methodName on the object obj, with arguments args. |
static boolean |
isPresent(String className)
Determine whether the Class identified by the supplied name is
present and can be loaded. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ClassUtils()
| Method Detail |
|---|
public static Class<?> getClass(String className)
throws ClassNotFoundException
Tries to load a class from its name. If class is not found using the standard classloader, tries with the thread classloader.
className - class name
ClassNotFoundException - if none of the ClassLoaders is able to found the class.
public static Object getNewInstance(Class<?> klass)
throws InstantiationException,
IllegalAccessException
Instanciate a class.
klass - The class to instanciate.
IllegalAccessException
InstantiationException
public static Object invokeMethod(Object obj,
String methodName,
Object[] args)
throws NoSuchMethodException,
IllegalAccessException,
InvocationTargetException
Invoke a method called methodName on the object obj, with arguments args.
obj - The object on which to invoke the method.methodName - The method name to invoke.args - The potential args used in the method.
InvocationTargetException
IllegalAccessException
NoSuchMethodException - if the methodName doesn't exist for the given object.public static Boolean canBeUsed(String className)
Test if a class exists in the classPath, trying to load it with its name.
className - The class to test.
public static boolean isPresent(String className)
Class identified by the supplied name is
present and can be loaded. Will return false if either the class
or one of its dependencies is not present or cannot be loaded.
className - the name of the class to checkclassLoader - the class loader to use (may be null, which indicates
the default class loader)
public static List<Class<?>> getSubClassesInPackage(String packageName,
Class<?> superClass)
throws ClassNotFoundException,
IOException
ClassNotFoundException
IOException
public static List<Class<?>> getAllClassesInPackage(String packageName)
throws ClassNotFoundException,
IOException
ClassNotFoundException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||