Constructor and Description |
---|
Reflector() |
Modifier and Type | Method and Description |
---|---|
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(Object obj,
Class clazz,
String methodName,
Object[] args)
gets the MethodInstance matching given Parameter
|
static MethodInstance |
getMethodInstanceEL(Object objMaybeNull,
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)
|
public Reflector()
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 checkpublic 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 getpublic static Class toReferenceClass(Class c)
c
- Class to convertpublic static String getDspMethods(Class... clazzArgs)
clazzArgs
- arguments to displaypublic static boolean like(Class src, Class trg)
src
- Source Classtrg
- Target Classpublic static Object convert(Object src, Class trgClass, RefInteger rating) throws PageException
src
- Object to convertsrcClass
- Source ClasstrgClass
- Target ClassPageException
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 argsNoSuchMethodException
PageException
public static ConstructorInstance getConstructorInstance(Class clazz, Object[] args, ConstructorInstance defaultValue)
public static MethodInstance getMethodInstanceEL(Object objMaybeNull, Class clazz, Collection.Key methodName, Object[] args)
objMaybeNull
- maybe nullclazz
- Class Of the Method to getmethodName
- Name of the Method to getargs
- Arguments of the Method to get
public static MethodInstance getMethodInstance(Object obj, 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 getNoSuchMethodException
PageException
public static Field[] getFieldsIgnoreCase(Class clazz, String name) throws NoSuchFieldException
clazz
- class to search the fieldname
- name to searchNoSuchFieldException
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 ClassPageException
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 getPageException
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 getPageException
public static MethodInstance getGetter(Class clazz, String prop) throws PageException, NoSuchMethodException
clazz
- Class to invoke method fromprop
- Name of the Method without getNoSuchMethodException
PageException
public static MethodInstance getGetterEL(Class clazz, String prop)
clazz
- Class to invoke method fromprop
- Name of the Method without getpublic static Object callGetter(Object obj, String prop) throws PageException
obj
- Object to invoke method fromprop
- Name of the Method without getPageException
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 MethodNoSuchMethodException
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 Methodpublic 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 MethodPageException
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 callPageException
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 assignPageException
public static Object getProperty(Object obj, String prop) throws PageException
obj
- Object to invokeprop
- property to callPageException
public static Object getProperty(Object obj, String prop, Object defaultValue)
obj
- Object to invokeprop
- property to callpublic static void setProperty(Object obj, String prop, Object value) throws PageException
obj
- Object to assign value to his propertyprop
- name of propertyvalue
- Value to assignPageException
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 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 classpublic static String removeGetterPrefix(String name)
Copyright © 2015 Lucee