|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectigpp.util.Reflection
public class Reflection
A utility class that provides methods for self-aware actions. Methods support the calling set*() methods using keyword/value arguments which includes using "keyword=value" syntax. Additional methods support dumping the value of all fields of an object.
Constructor Summary | |
---|---|
Reflection()
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Reflection()
Method Detail |
---|
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.
obj
- the Object
to inspect for the setName method.name
- the name of the item to set.value
- the String
array of values to set.
true
public static boolean setMemberString(Object obj, String name, String value)
String
as an argument.
obj
- the Object
to inspect for the setName method.name
- the name of the item to set.value
- the String
value to set.
true
if the set method was called, otherwise false
public static boolean setMember(Object obj, String name, String value)
obj
- the Object
to inspect for the setName method.name
- the name of the item to set.value
- the String
value to set.
true
if the set method was called, otherwise false
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)
obj
- the Object
to inspect for the get method.name
- the name of the item to set.
Method
is a match is found, otherwise null
public static Method getMethod(Object obj, String name, Class[] argSig)
obj
- the Object
to inspect for the get method.name
- the name of the item to set.argSig
- an array of Class
instances which specify the argument types for the method.
Method
is a match is found, otherwise null
public static void dump(Object obj)
obj
- the Object
to inspect for the member varaibles.public static void dumpMethods(Object obj)
obj
- the Object
to inspect for the member varaibles.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |