|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sibvisions.util.Reflective
public final class Reflective
This is a utility class to call different methods of classes via java.lang.reflect package.
Nested Class Summary | |
---|---|
static class |
Reflective.Parameter
The Parameter class is a placeholder for parameters. |
Constructor Summary | |
---|---|
Reflective()
Creates a new instance of Reflective to ensure thread safety. |
Method Summary | |
---|---|
static Object |
call(Object pObject,
boolean pOnlyDeclared,
String pMethod,
Object... pParams)
Invokes the method of an object without changing the access to the method. |
static Object |
call(Object pObject,
Class<?> pBaseClass,
boolean pOnlyDeclared,
String pMethod,
Object... pParams)
Invokes the method of an object without changing the access to the method. |
static Object |
call(Object pObject,
String pMethod,
Object... pParams)
Invokes the method of an object without changing the access to the method. |
static Object |
construct(Class<?> pClass,
boolean pOnlyDeclared,
Object... pParams)
Invokes the constructor of a pre-loaded class. |
static Object |
construct(Class<?> pClass,
Object... pParams)
Invokes the constructor of a pre-loaded class. |
static Object |
construct(ClassLoader pClassLoader,
String pClassName,
Object... pParams)
Invokes the constructor of a desired class. |
static Object |
construct(String pClassName,
Object... pParams)
Invokes the constructor of a desired class. |
static Object |
get(Object pObject,
String pProperty)
Invokes the get method of the given property. |
static Method |
getMethod(Class<?> pBaseClass,
boolean pOnlyDeclared,
String pMethod,
Class... pParamTypes)
Gets the method with the given types. |
static Method |
getMethod(Class<?> pBaseClass,
String pMethod,
Class... pParamTypes)
Gets the method with the given types. |
static String |
getMethodDeclaration(Class pClass,
String pMethod,
Object... pParams)
Gets the human readable method declaration of a method with its parameter list. |
static Object |
getValue(Object pObject,
Field pField)
Gets the value from a vield. |
static Object |
getValue(Object pObject,
String pFieldName)
Gets the value from a field. |
static Object |
invoke(Object pObject,
Method pMethod,
Object... pParams)
Invokes a method with parameters. |
void |
invokeLater(Runnable pRunnable)
Causes pRunnable.run() to be executed asynchronously on the
current event dispatching thread. |
static void |
printFields(Object pObject,
boolean pOnlyDeclared)
Prints out the fields and field values from a specific object. |
static void |
printMethods(Object pObject,
boolean pOnlyDeclared)
Prints out the methods and return values from a specific object. |
static void |
set(Object pObject,
String pProperty,
Object pValue)
Invokes the set method of the given property. |
static void |
setValue(Object pObject,
Field pField,
Object pValue)
Sets a field on a specified object value. |
static void |
setValue(Object pObject,
String pFieldName,
Object pValue)
Sets a field on a specified object value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Reflective()
Reflective
to ensure thread safety.
Method Detail |
---|
public static final Object construct(String pClassName, Object... pParams) throws Throwable
pClassName
- full qualified class namepParams
- parameters for the constructor
Throwable
- if it is not possible to invoke the constructorpublic static final Object construct(ClassLoader pClassLoader, String pClassName, Object... pParams) throws Throwable
pClassLoader
- an optional ClassLoader
for dynamic class loadingpClassName
- full qualified class namepParams
- parameters for the constructor
Throwable
- if it is not possible to invoke the constructorpublic static final Object construct(Class<?> pClass, Object... pParams) throws Throwable
pClass
- the pre-loaded classpParams
- parameters for the constructor
Throwable
- if it is not possible to invoke the constructorpublic static final Object construct(Class<?> pClass, boolean pOnlyDeclared, Object... pParams) throws Throwable
pClass
- the pre-loaded classpOnlyDeclared
- true
to use only declared constructorspParams
- parameters for the constructor
Throwable
- if it is not possible to invoke the constructorpublic static final Object call(Object pObject, String pMethod, Object... pParams) throws Throwable
pObject
- object with the desired methodpMethod
- invocable methodpParams
- parameters for the method
Throwable
- if it is not possible to invoke the methodpublic static final Object call(Object pObject, boolean pOnlyDeclared, String pMethod, Object... pParams) throws Throwable
pObject
- object with the desired methodpOnlyDeclared
- true
to use only declared methodspMethod
- invocable methodpParams
- parameters for the method
Throwable
- if it is not possible to invoke the methodpublic static final Object call(Object pObject, Class<?> pBaseClass, boolean pOnlyDeclared, String pMethod, Object... pParams) throws Throwable
pObject
- object with the desired methodpBaseClass
- the object class or a super class from which the method will be calledpOnlyDeclared
- true
to use only declared methodspMethod
- invocable methodpParams
- parameters for the method
Throwable
- if it is not possible to invoke the methodpublic static final String getMethodDeclaration(Class pClass, String pMethod, Object... pParams)
pClass
- the classpMethod
- method or full qualified class namepParams
- parameter list
public static void setValue(Object pObject, String pFieldName, Object pValue) throws Throwable
pObject
- the object with the fieldpFieldName
- the field namepValue
- the new value
Throwable
- if it is not possible to set the desired fieldsetValue(Object, Field, Object)
public static void setValue(Object pObject, Field pField, Object pValue) throws Throwable
pObject
- the object with the fieldpField
- the fieldpValue
- the new value
Throwable
- if it is not possible to set the desired fieldpublic static Object getValue(Object pObject, String pFieldName) throws Throwable
pObject
- the object with the fieldpFieldName
- the field name
Throwable
- if it is not possible to get the value of desired field or the field is not presendgetValue(Object, Field)
public static Object getValue(Object pObject, Field pField) throws Throwable
pObject
- the object with the fieldpField
- the field
Throwable
- if it is not possible to get the value of desired field or the field is not presendpublic static Object invoke(Object pObject, Method pMethod, Object... pParams) throws Throwable
pObject
- the object with the methodpMethod
- the methodpParams
- the method parameters
Throwable
- if an error occurs during invocationpublic static Object get(Object pObject, String pProperty) throws Throwable
pObject
- the object with the methodpProperty
- the property
Throwable
- if an error occurs during invocationpublic static void set(Object pObject, String pProperty, Object pValue) throws Throwable
pObject
- the object with the methodpProperty
- the propertypValue
- the value of the property.
Throwable
- if an error occurs during invocationpublic void invokeLater(Runnable pRunnable)
pRunnable.run()
to be executed asynchronously on the
current event dispatching thread. There are different technologies
with different invokeLater
implementations. To find the UI
dependent method the current factory manager will be used. If there is
no factory manager, then the pRunnable.run()
will be
started within the current thread.
pRunnable
- specific functionality to run asynchronouspublic static final void printFields(Object pObject, boolean pOnlyDeclared)
pObject
- an objectpOnlyDeclared
- use only declared fieldspublic static final void printMethods(Object pObject, boolean pOnlyDeclared)
pObject
- an objectpOnlyDeclared
- use only declared methodspublic static final Method getMethod(Class<?> pBaseClass, String pMethod, Class... pParamTypes) throws NoSuchMethodException
pBaseClass
- the object class or a super class from which the method will be calledpMethod
- invocable methodpParamTypes
- parameters for the method
NoSuchMethodException
- if Method does not exist.public static final Method getMethod(Class<?> pBaseClass, boolean pOnlyDeclared, String pMethod, Class... pParamTypes) throws NoSuchMethodException
pBaseClass
- the object class or a super class from which the method will be calledpOnlyDeclared
- true
to use only declared methodspMethod
- invocable methodpParamTypes
- parameters for the method
NoSuchMethodException
- if Method does not exist.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |