|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.massimo.utils.ReflectionHelper
public final class ReflectionHelper
Helper for using reflection
Method Summary | |
---|---|
static void |
clearFieldCache()
Clear the Fields cache. |
static void |
clearMethodCache()
Clear the Methods cache. |
static Object |
createObject(String className)
Create an object of the supplied classname. |
static Object |
createParameter(Object target,
String name,
Object val)
Find the type of and create a parameter for attribute name's set method Introspect the target to get the parameter type |
static Object |
createType(Class type,
Object val)
Utility method to create primitive types |
static Object |
createType(String factoryClass,
String factoryMethod,
Object val)
Create an object using the supplied factory class and method |
static Field |
findField(Class clazz,
String fieldName)
Find a field in clazz called fieldName that satisfies the given modifiers. |
static Method |
findMethod(Class clazz,
String methodName,
int modifiers)
Find a method in clazz called methodName that satisfies the given modifiers. |
static Method |
findSetterMethod(Object target,
String name)
Find a public setter method on a target |
static void |
setAttr(Object target,
Object value,
String attrName)
Use reflection to set an attribute to a value on the target object. |
static void |
setAttr(Object target,
Object value,
String attrName,
int attrIndex)
Use reflection to set an attribute to a value on the target object. |
static void |
setAttr(Object target,
String name,
Object value,
int index)
Use refection to set an attribute. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void clearFieldCache()
public static void clearMethodCache()
public static Object createObject(String className)
className
-
public static Object createParameter(Object target, String name, Object val)
target
- name
- val
-
public static Object createType(Class type, Object val)
type
- val
-
Integer.TYPE
,
Long.TYPE
,
Float.TYPE
,
Double.TYPE
,
Short.TYPE
,
Boolean.TYPE
,
Character.TYPE
,
Byte.TYPE
,
Void.TYPE
public static Object createType(String factoryClass, String factoryMethod, Object val)
factoryClass
- factoryMethod
- val
-
public static Field findField(Class clazz, String fieldName)
clazz
- fieldName
-
public static Method findMethod(Class clazz, String methodName, int modifiers)
clazz
- methodName
- modifiers
-
public static Method findSetterMethod(Object target, String name)
target
- Object whose attribute we want to setname
- Name of the attribute we want to set
public static void setAttr(Object target, Object value, String attrName)
target
- value
- attrName
- public static void setAttr(Object target, Object value, String attrName, int attrIndex)
target
- value
- attrName
- attrIndex
- public static void setAttr(Object target, String name, Object value, int index)
target
- name
- value
- index
-
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |