public class ReflectionUtils extends Object
| Constructor and Description |
|---|
ReflectionUtils()
Constructor method for i18n purposes only.
|
| Modifier and Type | Method and Description |
|---|---|
static Object |
getDeclaredField(Object target,
Class clazz,
String name)
Extracts the value of the instance variable via reflection (also protected, private etc.).
|
static Object |
getDeclaredField(Object target,
String name)
Extracts the value of the instance variable via reflection (also protected, private etc.).
|
static Object |
getStaticField(String classname,
String fieldname)
Extracts the value of the static field via reflection (only public).
|
static Object |
invoke(Object target,
String methodname,
String[] paramtypes,
Object... args)
Invokes a method using reflection.
|
static Object |
invokeStatic(String classname,
String methodname,
String[] paramtypes,
Object... args)
Invokes a static (class) method using reflection.
|
static Object |
newInstance(String classname,
String[] paramtypes,
Object... initargs)
Creates a new instance of the given class using reflection (also used for the paramtypes classes).
|
public ReflectionUtils()
throws InstantiationException
InstantiationException - Error indicationpublic static Object getDeclaredField(Object target, Class clazz, String name) throws NoSuchFieldException, IllegalAccessException
The clazz parameter may be one of the subclasses of target.
target - The object to be accessedname - The name of the variable to accessclazz - The (sub)class of interest, target class if nullnullNullPointerException - If the parameters are nullNoSuchFieldException - Error indicationIllegalAccessException - Error indicationpublic static Object getDeclaredField(Object target, String name) throws NoSuchFieldException, IllegalAccessException
target - The object to be accessedname - The name of the variable to accessnullNullPointerException - If the parameters are nullNoSuchFieldException - Error indicationIllegalAccessException - Error indicationpublic static Object newInstance(String classname, String[] paramtypes, Object... initargs)
classname - The object to be accessedparamtypes - The parameter types for constructor, null = default constructorinitargs - The arguments for constructor, null = default constructornull if an error occurredpublic static Object invoke(Object target, String methodname, String[] paramtypes, Object... args)
target - The object to be accessedmethodname - The method to be invokedparamtypes - The parameter types for method call, null = parameterless methodargs - The arguments for method callnull otherwise (also if errors did occur)public static Object invokeStatic(String classname, String methodname, String[] paramtypes, Object... args)
classname - The class to be accessedmethodname - The method to be invokedparamtypes - The parameter types for method call, null = parameterless methodargs - The arguments for method callnull otherwise (also if errors did occur)public static Object getStaticField(String classname, String fieldname)
classname - The class name to be accessedfieldname - The name of the field to accessnullNullPointerException - If the parameters are nullClassNotFoundException - Error indicationNoSuchFieldException - Error indicationIllegalAccessException - Error indication
Copyright © 2005-2026 Leisenfels GmbH. All rights reserved.