|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.xoetrope.xui.helper.ReflectionHelper
public class ReflectionHelper
A helper to simplify some of the more common reflection tasks used in XUI
Copyright: Copyright (c) 2004
$Revision: 1.5 $
| Field Summary | |
|---|---|
static int |
LOG_ERROR_MESSAGE
|
static int |
PRINT_STACK_TRACE
|
| Constructor Summary | |
|---|---|
ReflectionHelper()
|
|
| Method Summary | |
|---|---|
static java.lang.Object |
constructViaReflection(java.lang.ClassLoader cl,
java.lang.Object klass)
Create a new Object via reflection |
static java.lang.Object |
constructViaReflection(java.lang.ClassLoader cl,
java.lang.Object klass,
java.lang.Class argClass,
java.lang.Object value)
Create a new Object via reflection |
static java.lang.Object |
constructViaReflection(java.lang.Object klass,
java.lang.Class[] params,
java.lang.Object[] values)
Create a new Object via reflection |
static java.lang.Object |
constructViaReflection(java.lang.String klass,
java.lang.Class argClass,
java.lang.Object value)
Create a new Object via reflection |
static java.lang.Object |
constructViaReflection(java.lang.String className,
java.lang.Object[] values)
Create a new Object via reflection |
static java.lang.Object |
deserialize(java.lang.Object value)
|
static java.lang.Object[] |
deserialize(java.lang.Object[] values)
|
static java.lang.Class |
getAltClass(java.lang.Class objectClass)
Get an alternative for a class e.g. int.class for Integer.class |
static int |
getErrorMode()
Get the current error mode |
static java.lang.Object |
getObject(java.lang.String paramType,
java.lang.String content)
Get an object from an XML (config file) description |
static java.lang.Class |
getParamClass(java.lang.String paramType)
Get the class from a parameter type as it appears in the XML |
static java.lang.Object |
getViaReflection(java.lang.Class klass,
java.lang.String methodName,
java.lang.Object comp)
Get a property using refelction |
static java.lang.Object |
getViaReflection(java.lang.String methodName,
java.lang.Object comp)
Get a property using refelction |
static java.lang.Object |
getViaReflection(java.lang.String methodName,
java.lang.Object comp,
boolean warn)
Get a property using refelction |
static java.lang.Object |
parseArgument(java.lang.Class param,
java.lang.Object value)
Converts the value passed to the ReflectionHelper to the specified class type if possible. |
static void |
setErrorMode(int m)
Set the error mode for reflection errors |
static void |
setFieldViaReflection(java.lang.Object clazz,
java.lang.String fieldName,
java.lang.Object value)
Set a field property using reflection instead of the property helper. |
static void |
setFieldViaReflection(java.lang.Object clazz,
java.lang.String fieldName,
java.lang.String value)
Set a field property using reflection instead of the property helper. |
static boolean |
setViaReflection(java.lang.String methodName,
java.lang.Object comp,
java.lang.Object value)
Set a property using reflection instead of the property helper. |
static boolean |
setViaReflection(java.lang.String methodName,
java.lang.Object comp,
java.lang.Object[] values)
Set a property using reflection instead of the property helper. |
static boolean |
setViaReflection(java.lang.String methodName,
java.lang.Object comp,
java.lang.Object value,
boolean isBoolean)
Set a property using reflection instead of the property helper. |
static boolean |
setViaReflection(java.lang.String methodName,
java.lang.Object comp,
java.lang.Object value,
java.lang.Class objectClass)
Set a property using reflection instead of the property helper. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int PRINT_STACK_TRACE
public static final int LOG_ERROR_MESSAGE
| Constructor Detail |
|---|
public ReflectionHelper()
| Method Detail |
|---|
public static void setErrorMode(int m)
m - the new modepublic static int getErrorMode()
public static java.lang.Object getViaReflection(java.lang.String methodName,
java.lang.Object comp)
methodName - the method namecomp - the component being modified
public static java.lang.Object getViaReflection(java.lang.String methodName,
java.lang.Object comp,
boolean warn)
methodName - the method namecomp - the component being modifiedwarn - true to issue a warning if no matching method is found
public static java.lang.Object getViaReflection(java.lang.Class klass,
java.lang.String methodName,
java.lang.Object comp)
klass - the class whose method is being invokedmethodName - the method namecomp - the component being modified
public static boolean setViaReflection(java.lang.String methodName,
java.lang.Object comp,
java.lang.Object value)
methodName - the method namecomp - the component being modifiedvalue - the new value
public static boolean setViaReflection(java.lang.String methodName,
java.lang.Object comp,
java.lang.Object[] values)
methodName - the method namecomp - the component being modifiedvalue - the new value
public static java.lang.Object parseArgument(java.lang.Class param,
java.lang.Object value)
param - the class instance requiredvalue - the argument, probably represented as a string
public static boolean setViaReflection(java.lang.String methodName,
java.lang.Object comp,
java.lang.Object value,
boolean isBoolean)
methodName - the method namecomp - the component being modifiedvalue - the new valueisBoolean - is it a boolean property being modified
public static boolean setViaReflection(java.lang.String methodName,
java.lang.Object comp,
java.lang.Object value,
java.lang.Class objectClass)
methodName - the method namecomp - the component being modifiedvalue - the new valueobjectClass - the class of the argument of the set method being invoked
public static void setFieldViaReflection(java.lang.Object clazz,
java.lang.String fieldName,
java.lang.String value)
clazz - the object instance whose property we want to setfieldName - the name of the field to setvalue - the new value
public static void setFieldViaReflection(java.lang.Object clazz,
java.lang.String fieldName,
java.lang.Object value)
clazz - the object instance whose property we want to setfieldName - the name of the field to setvalue - the new value
public static java.lang.Object constructViaReflection(java.lang.String className,
java.lang.Object[] values)
className - the class to constructvalues - an array of arguments used by the constructor
public static java.lang.Object constructViaReflection(java.lang.Object klass,
java.lang.Class[] params,
java.lang.Object[] values)
params - the types used by the constructorklass - the class to construct or the classnamevalues - an array of arguments used by the constructor
public static java.lang.Object constructViaReflection(java.lang.String klass,
java.lang.Class argClass,
java.lang.Object value)
klass - the class to construct or the classnameargClass - the argument type used by the constructorvalue - an argument used by the constructor
public static java.lang.Object constructViaReflection(java.lang.ClassLoader cl,
java.lang.Object klass,
java.lang.Class argClass,
java.lang.Object value)
cl - the class loader to use to located the class, or null to use
Class.forName to locate the classklass - the class to construct or the class nameargClass - the argument type used by the constructorvalue - an argument used by the constructor
public static java.lang.Object constructViaReflection(java.lang.ClassLoader cl,
java.lang.Object klass)
cl - the class loader to use to located the class, or null to use
Class.forName to locate the classklass - the class to construct or the classname
public static java.lang.Class getAltClass(java.lang.Class objectClass)
objectClass - the class of the argument
public static java.lang.Class getParamClass(java.lang.String paramType)
paramType - the type name
public static java.lang.Object getObject(java.lang.String paramType,
java.lang.String content)
paramType - the class name/typecontent - the content of the object
public static java.lang.Object deserialize(java.lang.Object value)
public static java.lang.Object[] deserialize(java.lang.Object[] values)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||