public class Reflection extends Object
Constructor and Description |
---|
Reflection() |
Modifier and Type | Method and Description |
---|---|
static void |
dump(Object obj)
Print the value of all member variables to System.out.
|
static void |
dumpMethods(Object obj)
Print the value of all member variables to System.out.
|
static String |
getMemberValue(Object obj,
String name)
Call the get() method with a given name suffix and return the value as
String . |
static Method |
getMethod(Object obj,
String name)
Returns the first Method with a given name regardless of
the full signature (arguments) of the method.
|
static Method |
getMethod(Object obj,
String name,
Class[] argSig)
Returns the first Method with a given name which matches the
the full signature (arguments) of the method.
|
static void |
main(String[] args) |
static boolean |
setMember(Object obj,
String statement)
Set a member variable using the syntax "name=value".
|
static boolean |
setMember(Object obj,
String name,
String value)
Call the set() method with a given name suffix passing one argument.
|
static boolean |
setMember(Object obj,
String name,
String[] value)
Call the set() method with a given name suffix and a
String array
as an argument. |
static boolean |
setMemberString(Object obj,
String name,
String value)
Call the set() method with a given name suffix and a
String
as an argument. |
public static void main(String[] args)
public static boolean setMember(Object obj, String statement)
Object
is searched for a "setName" method
to call to set the member varaible.obj
- the Object
to inspect for the setName method.statement
- the string containing "name=value".true
if the statement was parsed correctly, otherwise false
public static boolean setMember(Object obj, String name, String[] value)
String
array
as an argument. Calls the appropriate set method for each value.public static boolean setMemberString(Object obj, String name, String value)
String
as an argument.public static boolean setMember(Object obj, String name, String value)
public static String getMemberValue(Object obj, String name)
String
.obj
- the Object
to inspect for the setName method.name
- the name of the item to set.public static Method getMethod(Object obj, String name)
public static Method getMethod(Object obj, String name, Class[] argSig)
public static void dump(Object obj)
obj
- the Object
to inspect for the member varaibles.Copyright © 2008-2009 Regents University of California. All Rights Reserved.