|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrailo.runtime.reflection.Reflector
public final class Reflector
Class to reflect on Objects and classes
Constructor Summary | |
---|---|
Reflector()
|
Method Summary | |
---|---|
static Object |
_convert(Object src,
Class trgClass)
|
static Object |
callConstructor(Class clazz,
Object[] args)
call constructor of a class with matching arguments |
static Object |
callConstructor(Class clazz,
Object[] args,
Object defaultValue)
|
static Object |
callGetter(Object obj,
String prop)
to invoke a getter Method of a Object |
static Object |
callMethod(Object obj,
Collection.Key methodName,
Object[] args)
|
static Object |
callMethod(Object obj,
Collection.Key methodName,
Object[] args,
Object defaultValue)
|
static Object |
callMethod(Object obj,
String methodName,
Object[] args)
calls a Method of a Objct |
static void |
callSetter(Object obj,
String prop,
Object value)
to invoke a setter Method of a Object |
static void |
callSetterEL(Object obj,
String prop,
Object value)
do nothing when not exist |
static Object |
callStaticMethod(Class clazz,
String methodName,
Object[] args)
calls a Static Method on the given CLass |
static boolean |
canConvert(Class from,
Class to)
check if given class "from" can be converted to class "to" without explicit casting |
static Object |
convert(Object src,
Class trgClass,
RefInteger rating)
convert Object from src to trg Type, if possible |
static Class[] |
getClasses(Object[] objs)
get all Classes from a Object Array |
static ConstructorInstance |
getConstructorInstance(Class clazz,
Object[] args)
gets Constructor Instance matching given parameter |
static ConstructorInstance |
getConstructorInstance(Class clazz,
Object[] args,
ConstructorInstance defaultValue)
|
static Method[] |
getDeclaredMethods(Class clazz)
return all methods that are defined by the class itself (not extended) |
static String |
getDspMethods(Class... clazzArgs)
creates a string list with class arguments in a displable form |
static Object |
getField(Object obj,
String prop)
to get a visible Field of a object |
static Object |
getField(Object obj,
String prop,
Object defaultValue)
|
static Field[] |
getFieldsIgnoreCase(Class clazz,
String name)
same like method getField from Class but ignore case from field name |
static Field[] |
getFieldsIgnoreCase(Class clazz,
String name,
Field[] defaultValue)
|
static MethodInstance |
getGetter(Class clazz,
String prop)
to get a Getter Method of a Object |
static MethodInstance |
getGetterEL(Class clazz,
String prop)
to get a Getter Method of a Object |
static Method[] |
getGetters(Class clazz)
|
static MethodInstance |
getMethodInstance(Class clazz,
String methodName,
Object[] args)
gets the MethodInstance matching given Parameter |
static MethodInstance |
getMethodInstanceEL(Class clazz,
Collection.Key methodName,
Object[] args)
gets the MethodInstance matching given Parameter |
static Object |
getProperty(Object obj,
String prop)
to get a visible Propety (Field or Getter) of a object |
static Object |
getProperty(Object obj,
String prop,
Object defaultValue)
to get a visible Propety (Field or Getter) of a object |
static String[] |
getPropertyKeys(Class clazz)
|
static MethodInstance |
getSetter(Object obj,
String prop,
Object value)
to invoke a setter Method of a Object |
static MethodInstance |
getSetter(Object obj,
String prop,
Object value,
MethodInstance defaultValue)
to invoke a setter Method of a Object |
static Method[] |
getSetters(Class clazz)
|
static boolean |
hasFieldIgnoreCase(Class clazz,
String name)
|
static boolean |
hasPropertyIgnoreCase(Class clazz,
String name)
|
static boolean |
isGetter(Method method)
|
static boolean |
isInstaneOf(Class src,
Class trg)
check if Class is instanceof a a other Class |
static boolean |
isInstaneOf(Class src,
String trgClassName)
check if Class is instanceof a a other Class |
static boolean |
isInstaneOf(String srcClassName,
Class trg)
check if Class is instanceof a a other Class |
static boolean |
isInstaneOf(String srcClassName,
String trgClassName)
check if Class is instanceof a a other Class |
static boolean |
isInstaneOfIgnoreCase(Class src,
String trg)
|
static boolean |
isSetter(Method method)
|
static boolean |
like(Class src,
Class trg)
checks if src Class is "like" trg class |
static String |
removeGetterPrefix(String name)
|
static boolean |
setField(Object obj,
String prop,
Object value)
assign a value to a visible Field of a object |
static void |
setProperty(Object obj,
String prop,
Object value)
assign a value to a visible Property (Field or Setter) of a object |
static void |
setPropertyEL(Object obj,
String prop,
Object value)
assign a value to a visible Property (Field or Setter) of a object |
static ExpressionException |
throwCall(Object obj,
Collection.Key methodName,
Object[] args)
|
static ExpressionException |
throwCall(Object obj,
String methodName,
Object[] args)
|
static Class |
toReferenceClass(Class c)
convert a primitive class Type to a Reference Type (Example: int -> java.lang.Integer) |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Reflector()
Method Detail |
---|
public static boolean isInstaneOf(String srcClassName, Class trg)
srcClassName
- Class name to checktrg
- is Class of?
public static boolean isInstaneOf(String srcClassName, String trgClassName)
srcClassName
- Class name to checktrgClassName
- is Class of?
public static boolean isInstaneOf(Class src, String trgClassName)
src
- is Class of?trgClassName
- Class name to check
public static boolean isInstaneOfIgnoreCase(Class src, String trg)
public static boolean isInstaneOf(Class src, Class trg)
src
- Class to checktrg
- is Class of?
public static Class[] getClasses(Object[] objs)
objs
- Objects to get
public static Class toReferenceClass(Class c)
c
- Class to convert
public static String getDspMethods(Class... clazzArgs)
clazzArgs
- arguments to display
public static boolean like(Class src, Class trg)
src
- Source Classtrg
- Target Class
public static Object convert(Object src, Class trgClass, RefInteger rating) throws PageException
src
- Object to convertsrcClass
- Source ClasstrgClass
- Target Class
PageException
public static Object _convert(Object src, Class trgClass) throws PageException
PageException
public static ConstructorInstance getConstructorInstance(Class clazz, Object[] args) throws NoSuchMethodException
clazz
- Clazz to Invokeargs
- Matching args
NoSuchMethodException
PageException
public static ConstructorInstance getConstructorInstance(Class clazz, Object[] args, ConstructorInstance defaultValue)
public static MethodInstance getMethodInstanceEL(Class clazz, Collection.Key methodName, Object[] args)
clazz
- Class Of the Method to getmethodName
- Name of the Method to getargs
- Arguments of the Method to get
public static MethodInstance getMethodInstance(Class clazz, String methodName, Object[] args) throws NoSuchMethodException
clazz
- Class Of the Method to getmethodName
- Name of the Method to getargs
- Arguments of the Method to get
NoSuchMethodException
PageException
public static Field[] getFieldsIgnoreCase(Class clazz, String name) throws NoSuchFieldException
clazz
- class to search the fieldname
- name to search
NoSuchFieldException
public static Field[] getFieldsIgnoreCase(Class clazz, String name, Field[] defaultValue)
public static String[] getPropertyKeys(Class clazz)
public static boolean hasPropertyIgnoreCase(Class clazz, String name)
public static boolean hasFieldIgnoreCase(Class clazz, String name)
public static Object callConstructor(Class clazz, Object[] args) throws PageException
clazz
- Class to get Instanceargs
- Arguments for the Class
PageException
public static Object callConstructor(Class clazz, Object[] args, Object defaultValue)
public static Object callMethod(Object obj, String methodName, Object[] args) throws PageException
obj
- Object to call Method on itmethodName
- Name of the Method to getargs
- Arguments of the Method to get
PageException
public static Object callMethod(Object obj, Collection.Key methodName, Object[] args) throws PageException
PageException
public static Object callMethod(Object obj, Collection.Key methodName, Object[] args, Object defaultValue)
public static ExpressionException throwCall(Object obj, String methodName, Object[] args)
public static ExpressionException throwCall(Object obj, Collection.Key methodName, Object[] args)
public static Object callStaticMethod(Class clazz, String methodName, Object[] args) throws PageException
clazz
- Class to call Method on itmethodName
- Name of the Method to getargs
- Arguments of the Method to get
PageException
public static MethodInstance getGetter(Class clazz, String prop) throws PageException, NoSuchMethodException
clazz
- Class to invoke method fromprop
- Name of the Method without get
NoSuchMethodException
PageException
public static MethodInstance getGetterEL(Class clazz, String prop)
clazz
- Class to invoke method fromprop
- Name of the Method without get
public static Object callGetter(Object obj, String prop) throws PageException
obj
- Object to invoke method fromprop
- Name of the Method without get
PageException
public static MethodInstance getSetter(Object obj, String prop, Object value) throws NoSuchMethodException
obj
- Object to invoke method fromprop
- Name of the Method without getvalue
- Value to set to the Method
NoSuchMethodException
PageException
public static MethodInstance getSetter(Object obj, String prop, Object value, MethodInstance defaultValue)
obj
- Object to invoke method fromprop
- Name of the Method without getvalue
- Value to set to the Method
public static void callSetter(Object obj, String prop, Object value) throws PageException
obj
- Object to invoke method fromprop
- Name of the Method without getvalue
- Value to set to the Method
PageException
public static void callSetterEL(Object obj, String prop, Object value) throws PageException
obj
- prop
- value
-
PageException
public static Object getField(Object obj, String prop) throws PageException
obj
- Object to invokeprop
- property to call
PageException
public static Object getField(Object obj, String prop, Object defaultValue)
public static boolean setField(Object obj, String prop, Object value) throws PageException
obj
- Object to assign value to his propertyprop
- name of propertyvalue
- Value to assign
PageException
public static Object getProperty(Object obj, String prop) throws PageException
obj
- Object to invokeprop
- property to call
PageException
public static Object getProperty(Object obj, String prop, Object defaultValue)
obj
- Object to invokeprop
- property to call
public static void setProperty(Object obj, String prop, Object value) throws PageException
obj
- Object to assign value to his propertyprop
- name of propertyvalue
- Value to assign
PageException
public static void setPropertyEL(Object obj, String prop, Object value)
obj
- Object to assign value to his propertyprop
- name of propertyvalue
- Value to assignpublic static boolean isGetter(Method method)
public static boolean isSetter(Method method)
public static Method[] getDeclaredMethods(Class clazz)
clazz
-
public static Method[] getSetters(Class clazz)
public static Method[] getGetters(Class clazz)
public static boolean canConvert(Class from, Class to)
from
- source classto
- target class
public static String removeGetterPrefix(String name)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |