public class Reflection
extends java.lang.Object
Constructor and Description |
---|
Reflection() |
Modifier and Type | Method and Description |
---|---|
static void |
dump(java.lang.Object obj)
Print the value of all member variables to System.out.
|
static void |
dumpMethods(java.lang.Object obj)
Print the value of all member variables to System.out.
|
static java.lang.String |
getMemberValue(java.lang.Object obj,
java.lang.String name)
Call the get() method with a given name suffix and return the value as
String . |
static java.lang.reflect.Method |
getMethod(java.lang.Object obj,
java.lang.String name)
Returns the first Method with a given name regardless of
the full signature (arguments) of the method.
|
static java.lang.reflect.Method |
getMethod(java.lang.Object obj,
java.lang.String name,
java.lang.Class[] argSig)
Returns the first Method with a given name which matches the
the full signature (arguments) of the method.
|
static void |
main(java.lang.String[] args) |
static boolean |
setMember(java.lang.Object obj,
java.lang.String statement)
Set a member variable using the syntax "name=value".
|
static boolean |
setMember(java.lang.Object obj,
java.lang.String name,
java.lang.String value)
Call the set() method with a given name suffix passing one argument.
|
static boolean |
setMember(java.lang.Object obj,
java.lang.String name,
java.lang.String[] value)
Call the set() method with a given name suffix and a
String array
as an argument. |
static boolean |
setMemberString(java.lang.Object obj,
java.lang.String name,
java.lang.String value)
Call the set() method with a given name suffix and a
String
as an argument. |
public static void main(java.lang.String[] args)
public static boolean setMember(java.lang.Object obj, java.lang.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(java.lang.Object obj, java.lang.String name, java.lang.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(java.lang.Object obj, java.lang.String name, java.lang.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(java.lang.Object obj, java.lang.String name, java.lang.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 java.lang.String getMemberValue(java.lang.Object obj, java.lang.String name)
String
.obj
- the Object
to inspect for the setName method.name
- the name of the item to set.public static java.lang.reflect.Method getMethod(java.lang.Object obj, java.lang.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 java.lang.reflect.Method getMethod(java.lang.Object obj, java.lang.String name, java.lang.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(java.lang.Object obj)
obj
- the Object
to inspect for the member varaibles.public static void dumpMethods(java.lang.Object obj)
obj
- the Object
to inspect for the member varaibles.Copyright © 2008-2018 Regents University of California. All Rights Reserved.