Static Public Member Functions | |
static Field | getFieldWithAccess (Object obj, String fieldName) |
static Field | getFieldWithAccess (Class<?> cls, String fieldName) |
static Field | getField (Class<?> cls, String fieldName) |
static< R > R | getFieldValue (Object obj, Field field) |
static< R > R | getFieldValue (Object obj, String fieldName) |
static void | setFieldValue (Object obj, String field, Object value) |
static void | setFieldValue (Object obj, Field field, Object value) |
static Field[] | getAllFields (Class<?> clz) |
static Field[] | getAllNonStaticFields (Class<?> clz) |
static Field[] | getDeclaredNonStaticFields (Class<?> clz) |
static Method | getMethod (Class<?extends Object > clz, String methodName, Class<?>[] methodArgs) throws NoSuchMethodException |
static Method | findMethod (Class<?> clz, String methodName, Class<?>[] methodParams) throws NoSuchMethodException |
static Class<?> | box (Class<?> c) |
static Object | invoke (Object obj, String method, Class<?>[] params, Object[] args) |
static Object | invoke_ex (Object obj, String method, Class<?>[] params, Object[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException |
static Object | createObjectDefaultConstructor (Class<?> clz) |
static Object | createNewArray (Class<?> componentType, int len) |
static< T, K > T | newInstance (Class< T > clz, Class< K > argType, K arg) |
static< T > T | newInstance (Class< T > clz, Object[] args) |
static< T > T | newInstance (Class< T > clz, Class<?>[] argTypes, Object[] args) |
static< T, K, V > T | newInstance (Class< T > clz, Class< K > arg1Type, Class< V > arg2Type, K arg1, V arg2) |
static Method | getAnnotatedMethod (Class<?> owner, Class<?extends Annotation > annotation) |
static Method[] | getAnnotatedMethods (Class<?> owner, Class<?extends Annotation > annotation) |
static boolean | isPrimitive (Class<?> type) |
static Class | lca (Class clz1, Class clz2) |
static String | sig (Method method) |
static Collection< Class<?> > | getImmParents (Class<?> clz) |
static Collection< Type > | getImmGenericParents (Class<?> cls) |
static String | toString (Object obj) |
Static Package Attributes | |
static Map< Class<?>, Map < String, Field > > | cache = new HashMap<Class<?>, Map<String, Field>>() |
Static Private Member Functions | |
static void | getAllFieldsRecursive (Class<?> clz, List< Field > fldLst) |
static boolean | paramsMatch (Class<?> declared, Class<?> actual) |
static void | printObj (Object obj, StringBuilder sb, String indent, IdentityHashSet< Object > visited) |
Static Private Attributes | |
static final String | tab = " " |
Definition at line 29 of file ReflectionUtils.java.
static Class<?> edu.mit.csail.sdg.squander.utils.ReflectionUtils.box | ( | Class<?> | c | ) | [static] |
Definition at line 225 of file ReflectionUtils.java.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.paramsMatch().
static Object edu.mit.csail.sdg.squander.utils.ReflectionUtils.createNewArray | ( | Class<?> | componentType, | |
int | len | |||
) | [static] |
Definition at line 301 of file ReflectionUtils.java.
static Object edu.mit.csail.sdg.squander.utils.ReflectionUtils.createObjectDefaultConstructor | ( | Class<?> | clz | ) | [static] |
Creates object of the class clz using default constructor
If there is any problem during object construction, a RuntimeException is thrown
clz | -the class of object |
Definition at line 288 of file ReflectionUtils.java.
static Method edu.mit.csail.sdg.squander.utils.ReflectionUtils.findMethod | ( | Class<?> | clz, | |
String | methodName, | |||
Class<?>[] | methodParams | |||
) | throws NoSuchMethodException [static] |
Definition at line 197 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.paramsMatch().
static Field [] edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAllFields | ( | Class<?> | clz | ) | [static] |
Definition at line 138 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAllFieldsRecursive().
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.printObj().
static void edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAllFieldsRecursive | ( | Class<?> | clz, | |
List< Field > | fldLst | |||
) | [static, private] |
Definition at line 123 of file ReflectionUtils.java.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAllFields(), and edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAllNonStaticFields().
static Field [] edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAllNonStaticFields | ( | Class<?> | clz | ) | [static] |
Definition at line 147 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAllFieldsRecursive().
static Method edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAnnotatedMethod | ( | Class<?> | owner, | |
Class<?extends Annotation > | annotation | |||
) | [static] |
Finds method in class owner that contains given annotation. There must be at most one annotation of the given type in the class. If there are more methods that contain same annotation, RuntimeException is thrown. In this case, it would good to use getAnnotatedMethods(Class, Class) method
owner | ||
annotation |
Definition at line 354 of file ReflectionUtils.java.
static Method [] edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAnnotatedMethods | ( | Class<?> | owner, | |
Class<?extends Annotation > | annotation | |||
) | [static] |
Definition at line 368 of file ReflectionUtils.java.
static Field [] edu.mit.csail.sdg.squander.utils.ReflectionUtils.getDeclaredNonStaticFields | ( | Class<?> | clz | ) | [static] |
Definition at line 162 of file ReflectionUtils.java.
static Field edu.mit.csail.sdg.squander.utils.ReflectionUtils.getField | ( | Class<?> | cls, | |
String | fieldName | |||
) | [static] |
Gets field from class cls, either declared in cls or in one of its superclasses
cls | - declaring class of the field | |
fieldName | - name of the field |
Definition at line 51 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.cache.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldValue(), edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldWithAccess(), and edu.mit.csail.sdg.squander.utils.ReflectionUtils.setFieldValue().
static <R> R edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldValue | ( | Object | obj, | |
String | fieldName | |||
) | [static] |
Definition at line 102 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.getField(), and edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldValue().
static <R> R edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldValue | ( | Object | obj, | |
Field | field | |||
) | [static] |
Definition at line 86 of file ReflectionUtils.java.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldValue(), and edu.mit.csail.sdg.squander.utils.ReflectionUtils.printObj().
static Field edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldWithAccess | ( | Class<?> | cls, | |
String | fieldName | |||
) | [static] |
Definition at line 37 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.getField().
static Field edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldWithAccess | ( | Object | obj, | |
String | fieldName | |||
) | [static] |
Definition at line 33 of file ReflectionUtils.java.
static Collection<Type> edu.mit.csail.sdg.squander.utils.ReflectionUtils.getImmGenericParents | ( | Class<?> | cls | ) | [static] |
Definition at line 434 of file ReflectionUtils.java.
static Collection<Class<?> > edu.mit.csail.sdg.squander.utils.ReflectionUtils.getImmParents | ( | Class<?> | clz | ) | [static] |
Definition at line 425 of file ReflectionUtils.java.
static Method edu.mit.csail.sdg.squander.utils.ReflectionUtils.getMethod | ( | Class<?extends Object > | clz, | |
String | methodName, | |||
Class<?>[] | methodArgs | |||
) | throws NoSuchMethodException [static] |
Gets method from class clz
or any of its superclasses. If no method can be found NoSuchMethodException
is raised.
clz | - declaring class of the method | |
methodName | - name of the method | |
methodArgs | - method arguments |
NoSuchMethodException |
Definition at line 186 of file ReflectionUtils.java.
static Object edu.mit.csail.sdg.squander.utils.ReflectionUtils.invoke | ( | Object | obj, | |
String | method, | |||
Class<?>[] | params, | |||
Object[] | args | |||
) | [static] |
Invokes method of a given obj and set of parameters
obj | - Object for which the method is going to be executed. Special if obj is of type java.lang.Class, method is executed as static method of class given as obj parameter | |
method | - name of the object | |
params | - actual parameters for the method |
If there is any problem with method invocation, a RuntimeException is thrown
Definition at line 255 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.invoke_ex().
static Object edu.mit.csail.sdg.squander.utils.ReflectionUtils.invoke_ex | ( | Object | obj, | |
String | method, | |||
Class<?>[] | params, | |||
Object[] | args | |||
) | throws NoSuchMethodException, IllegalAccessException, InvocationTargetException [static] |
Definition at line 263 of file ReflectionUtils.java.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.invoke().
static boolean edu.mit.csail.sdg.squander.utils.ReflectionUtils.isPrimitive | ( | Class<?> | type | ) | [static] |
Definition at line 379 of file ReflectionUtils.java.
static Class edu.mit.csail.sdg.squander.utils.ReflectionUtils.lca | ( | Class | clz1, | |
Class | clz2 | |||
) | [static] |
Lowest common ancestor of two classes in the type lattice.
Definition at line 392 of file ReflectionUtils.java.
static <T,K,V> T edu.mit.csail.sdg.squander.utils.ReflectionUtils.newInstance | ( | Class< T > | clz, | |
Class< K > | arg1Type, | |||
Class< V > | arg2Type, | |||
K | arg1, | |||
V | arg2 | |||
) | [static] |
Definition at line 332 of file ReflectionUtils.java.
static <T> T edu.mit.csail.sdg.squander.utils.ReflectionUtils.newInstance | ( | Class< T > | clz, | |
Class<?>[] | argTypes, | |||
Object[] | args | |||
) | [static] |
Definition at line 322 of file ReflectionUtils.java.
static <T> T edu.mit.csail.sdg.squander.utils.ReflectionUtils.newInstance | ( | Class< T > | clz, | |
Object[] | args | |||
) | [static] |
Definition at line 315 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.newInstance().
static <T,K> T edu.mit.csail.sdg.squander.utils.ReflectionUtils.newInstance | ( | Class< T > | clz, | |
Class< K > | argType, | |||
K | arg | |||
) | [static] |
Definition at line 305 of file ReflectionUtils.java.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.newInstance().
static boolean edu.mit.csail.sdg.squander.utils.ReflectionUtils.paramsMatch | ( | Class<?> | declared, | |
Class<?> | actual | |||
) | [static, private] |
Definition at line 219 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.box().
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.findMethod().
static void edu.mit.csail.sdg.squander.utils.ReflectionUtils.printObj | ( | Object | obj, | |
StringBuilder | sb, | |||
String | indent, | |||
IdentityHashSet< Object > | visited | |||
) | [static, private] |
Definition at line 452 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.getAllFields(), edu.mit.csail.sdg.squander.utils.ReflectionUtils.getFieldValue(), and edu.mit.csail.sdg.squander.utils.ReflectionUtils.tab.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.toString().
static void edu.mit.csail.sdg.squander.utils.ReflectionUtils.setFieldValue | ( | Object | obj, | |
Field | field, | |||
Object | value | |||
) | [static] |
Definition at line 110 of file ReflectionUtils.java.
static void edu.mit.csail.sdg.squander.utils.ReflectionUtils.setFieldValue | ( | Object | obj, | |
String | field, | |||
Object | value | |||
) | [static] |
Definition at line 106 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.getField().
static String edu.mit.csail.sdg.squander.utils.ReflectionUtils.sig | ( | Method | method | ) | [static] |
Returns method signature as string
Definition at line 415 of file ReflectionUtils.java.
static String edu.mit.csail.sdg.squander.utils.ReflectionUtils.toString | ( | Object | obj | ) | [static] |
Definition at line 445 of file ReflectionUtils.java.
References edu.mit.csail.sdg.squander.utils.ReflectionUtils.printObj().
Map<Class<?>, Map<String, Field> > edu.mit.csail.sdg.squander.utils.ReflectionUtils.cache = new HashMap<Class<?>, Map<String, Field>>() [static, package] |
Definition at line 31 of file ReflectionUtils.java.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.getField().
final String edu.mit.csail.sdg.squander.utils.ReflectionUtils.tab = " " [static, private] |
Definition at line 443 of file ReflectionUtils.java.
Referenced by edu.mit.csail.sdg.squander.utils.ReflectionUtils.printObj().