|
jTransfo, 0.10 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jtransfo.internal.ReflectionHelper
public class ReflectionHelper
Helper class for all things class manipulation and reflection.
| Constructor Summary | |
|---|---|
ReflectionHelper()
|
|
| Method Summary | ||
|---|---|---|
List<Field> |
getFields(Class<?> clazz)
Find all declared fields of a class. |
|
Method |
getMethod(Class<?> type,
Class<?> returnType,
String name,
Class<?>... parameters)
Get method with given name and parameters and given return type. |
|
List<SyntheticField> |
getSyntheticFields(Class<?> clazz)
Find all declared (synthetic) fields of a class. |
|
|
loadClass(String name)
Load class with given name from the correct class loader. |
|
void |
makeAccessible(Field field)
Make the given field accessible, explicitly setting it accessible if necessary. |
|
List<SyntheticField> |
makeSynthetic(Class<?> clazz,
List<Field> fields)
Convert list of (real) fields to synthetic fields (which use accessor methods). |
|
|
newInstance(Class<T> clazz)
Create a new instance of a class. |
|
|
newInstance(String className)
Create a new instance of a class given the class name. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectionHelper()
| Method Detail |
|---|
public <T> T newInstance(Class<T> clazz)
throws IllegalAccessException,
InstantiationException
T - type of object to createclazz - class to create new instance of
IllegalAccessException - see Class.newInstance()
InstantiationException - see Class.newInstance()
public <T> T newInstance(String className)
throws IllegalAccessException,
InstantiationException,
ClassNotFoundException
T - type of object to createclassName - name of class to create new instance of
IllegalAccessException - see Class.newInstance()
InstantiationException - see Class.newInstance()
ClassNotFoundException - see ClassLoader.loadClass(String)
public <T> Class<T> loadClass(String name)
throws ClassNotFoundException
T - type of object to createname - name of class to load
ClassNotFoundException - see ClassLoader.loadClass(String)public List<Field> getFields(Class<?> clazz)
clazz - class to find fields for
public List<SyntheticField> makeSynthetic(Class<?> clazz,
List<Field> fields)
clazz - class which contains the fieldsfields - fields to convert to synthetic fields
public List<SyntheticField> getSyntheticFields(Class<?> clazz)
clazz - class to find fields for
public void makeAccessible(Field field)
setAccessible(true) method is only called when actually necessary, to avoid unnecessary
conflicts with a JVM SecurityManager (if active).
This method is borrowed from Spring's ReflectionUtil class.
field - the field to make accessibleAccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)
public Method getMethod(Class<?> type,
Class<?> returnType,
String name,
Class<?>... parameters)
type - class on which method should be foundreturnType - required return type (or null for void or no check)name - method nameparameters - method parameter types
|
jTransfo, 0.10 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||