|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.util.Reflection
Reflection utilities.
Field Summary | |
static java.lang.String |
code_id
|
protected static Trace |
trace
|
Constructor Summary | |
Reflection()
|
Method Summary | |
static java.lang.Class[] |
getArgClasses(java.util.List args)
Convert a list of argument values, into an array of classes used to locate the appropriate method. |
static java.lang.Object |
getBooleanProperty(java.lang.Object obj,
java.lang.String name)
Get the value of a boolean property using JavaBean setter convention. |
static java.lang.Class |
getClass(java.lang.String name)
Load a class, but make exceptions prettier. |
static java.lang.Class |
getClassIfExists(java.lang.String cname)
|
static java.lang.reflect.Constructor |
getConstructor(java.lang.Class c,
java.lang.Class[] args)
Locate a suitable constructor. |
static int |
getIntConstant(java.lang.Class c,
java.lang.String constantName,
int dflt)
|
static java.lang.reflect.Method |
getMethod(java.lang.Class c,
java.lang.String name,
java.lang.Class[] args)
Locate a suitable method. |
static java.lang.reflect.Method |
getMethod(java.lang.Class c,
java.lang.String name,
java.lang.Class[] args,
boolean raiseError)
Locate a suitable method. |
static java.lang.reflect.Method |
getMethod(java.lang.Class c,
java.lang.String name,
java.util.List argValues)
Locate a suitable method, making certain parameter corecions if necessary. |
static java.lang.Object |
getProperty(java.lang.Object obj,
java.lang.String name)
Get the value of a property using JavaBean setter convention. |
static java.lang.Object |
getProperty(java.lang.Object obj,
java.lang.String name,
boolean raiseError)
|
static java.lang.String |
getStringConstant(java.lang.Class c,
java.lang.String constantName,
java.lang.String dflt)
|
static java.lang.Package[] |
getWavesetPackages()
|
static boolean |
hasProperty(java.lang.Object obj,
java.lang.String name)
Test to see if a property is supported. |
static java.lang.Object |
instantiate(java.lang.Class c)
Create an instance of an object given a class, and assuming a no-arg constructor. |
static java.lang.Object |
instantiate(java.lang.Class c,
java.util.List args)
Create an instance of an object, given a class and a list of constructor arguments. |
static java.lang.Object |
instantiate(java.lang.Class c,
java.lang.Object[] args)
Create an instance of an object, given a class and an array of constructor arguments. |
static java.lang.Object |
instantiate(java.lang.reflect.Constructor con,
java.util.List args)
Create an instance of an object, given a constructor and a list of arguments. |
static java.lang.Object |
instantiate(java.lang.String name)
Create an instance of a class given a class name, and assuming a no-arg constructor. |
static java.lang.Object |
instantiate(java.lang.String name,
java.util.List args)
Create an instance of an object, given a class name and a list of constructor arguments. |
static java.lang.Object |
invoke(java.lang.reflect.Method m,
java.lang.Object target,
java.util.List args)
Invoke a method. |
static java.lang.Object |
invoke(java.lang.reflect.Method m,
java.lang.Object target,
java.lang.Object[] args)
Invoke a method. |
static void |
setProperty(java.lang.Object obj,
java.lang.String name,
java.lang.Object value)
Assign an object field using JavaBean setter convention. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
protected static final Trace trace
Constructor Detail |
public Reflection()
Method Detail |
public static java.lang.Class getClass(java.lang.String name) throws WavesetException
WavesetException
public static java.lang.Class getClassIfExists(java.lang.String cname)
public static java.lang.Class[] getArgClasses(java.util.List args) throws WavesetException
Note that we'll convert java.lang.Integer values into Class.forName("int") classes under the assumption you normally use primitive integers for method arguments. We could try to be smarter and recognize both types, but that would require that we merge getArgClasses and getMethod.
If we encounter a null argument, we originally left behind the java.lang.Object class, but since we really have to treat this as a wildcard during method searching, just leave it null.
WavesetException
public static java.lang.reflect.Constructor getConstructor(java.lang.Class c, java.lang.Class[] args) throws WavesetException
WavesetException
public static java.lang.Object instantiate(java.lang.String name) throws WavesetException
WavesetException
public static java.lang.Object instantiate(java.lang.Class c) throws WavesetException
WavesetException
public static java.lang.Object instantiate(java.lang.reflect.Constructor con, java.util.List args) throws WavesetException
WavesetException
public static java.lang.Object instantiate(java.lang.Class c, java.util.List args) throws WavesetException
WavesetException
public static java.lang.Object instantiate(java.lang.Class c, java.lang.Object[] args) throws WavesetException
WavesetException
public static java.lang.Object instantiate(java.lang.String name, java.util.List args) throws WavesetException
WavesetException
public static java.lang.reflect.Method getMethod(java.lang.Class c, java.lang.String name, java.lang.Class[] args) throws WavesetException
WavesetException
public static java.lang.reflect.Method getMethod(java.lang.Class c, java.lang.String name, java.lang.Class[] args, boolean raiseError) throws WavesetException
WavesetException
public static java.lang.reflect.Method getMethod(java.lang.Class c, java.lang.String name, java.util.List argValues) throws WavesetException
This is handy for cases like setting properties from Forms or XPRESS where the value may be a string, but the function is defined to take an "int". Handle a few of the common cases and coerce the value. We assume we're allowed to modify the values in the params list.
This isn't nearly comprehensive enough, adding coercion makes the difficulty of selecting the "best fit" method within the class hierarchy even harder and potentially ambiguous.
c
- The class the method is inname
- The name of the methodargValues
- The values of the arguments
WavesetException
public static java.lang.Object invoke(java.lang.reflect.Method m, java.lang.Object target, java.util.List args) throws WavesetException
WavesetException
public static java.lang.Object invoke(java.lang.reflect.Method m, java.lang.Object target, java.lang.Object[] args) throws WavesetException
WavesetException
public static void setProperty(java.lang.Object obj, java.lang.String name, java.lang.Object value) throws WavesetException
WavesetException
public static java.lang.Object getProperty(java.lang.Object obj, java.lang.String name) throws WavesetException
WavesetException
public static java.lang.Object getProperty(java.lang.Object obj, java.lang.String name, boolean raiseError) throws WavesetException
WavesetException
public static java.lang.Object getBooleanProperty(java.lang.Object obj, java.lang.String name) throws WavesetException
WavesetException
public static boolean hasProperty(java.lang.Object obj, java.lang.String name)
public static java.lang.String getStringConstant(java.lang.Class c, java.lang.String constantName, java.lang.String dflt)
public static int getIntConstant(java.lang.Class c, java.lang.String constantName, int dflt)
public static java.lang.Package[] getWavesetPackages()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |