public class MethodInvocationUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_NAME
Name of this class
|
static java.lang.String |
COPYRIGHT
IBM Copyright
|
static java.lang.String |
GETTER_METHOD_HEADER
getters start with this string
|
static java.lang.String |
SETTER_METHOD_HEADER
setters start with this string
|
Constructor and Description |
---|
MethodInvocationUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Method |
findMethod(java.lang.Class klass,
java.lang.String methodName,
java.lang.Class[] parameters)
Returns the first found
Method object that is a public member method
of the class or interface represented by this Class object, if any. |
static java.lang.Class |
getClass(java.lang.String shortName)
Returns the Class that is represents by the given class name.
|
static java.lang.String |
getClassFullName(java.lang.String shortName)
Returns the full name of a class that has the given short name
|
static java.lang.Package |
getPackage(java.lang.String name)
Returns the package that contains a registered class
|
static java.lang.String |
getPackageName(java.lang.String name)
Returns the package name of a registered class
|
static java.lang.Object |
getProperty(java.lang.Object target,
java.lang.String propertyName)
Gets the value of a property.
|
static java.lang.reflect.Method |
getReadMethod(java.lang.Object obj,
java.lang.String property)
Gets the getter of a property in a given object following JavaBean spec.
|
static java.lang.reflect.Method |
getWriteMethod(java.lang.Object obj,
java.lang.String property)
Gets the setter of a property in a given object following JavaBean spec.
|
static void |
registerClass(java.lang.Class aClass)
Associate a class's name with the class's package
|
static boolean |
setProperty(java.lang.Object target,
java.lang.String propertyName,
java.lang.Object propertyValue)
Sets a property value to a property in a given object.
|
public static final java.lang.String GETTER_METHOD_HEADER
public static final java.lang.String SETTER_METHOD_HEADER
public static final java.lang.String COPYRIGHT
public static final java.lang.String CLASS_NAME
public static java.lang.Class getClass(java.lang.String shortName)
shortName
- the short name of a classregisterClass(Class)
public static void registerClass(java.lang.Class aClass)
aClass
- the name of it will be associated with its packagegetPackage
public static java.lang.Package getPackage(java.lang.String name)
name
- the name of a classregisterClass(Class)
public static java.lang.String getPackageName(java.lang.String name)
name
- the name of a classregisterClass(Class)
public static java.lang.String getClassFullName(java.lang.String shortName)
shortName
- short name of a classpublic static boolean setProperty(java.lang.Object target, java.lang.String propertyName, java.lang.Object propertyValue)
target
- the object whose property is to be set.propertyName
- the name of the propertypropertyValue
- the value for the given propertypublic static java.lang.reflect.Method getReadMethod(java.lang.Object obj, java.lang.String property)
obj
- the object to be analyzedproperty
- the property that is associated with the getterpublic static java.lang.reflect.Method getWriteMethod(java.lang.Object obj, java.lang.String property)
obj
- the object to be analyzedproperty
- the property that is associated with the setterpublic static java.lang.reflect.Method findMethod(java.lang.Class klass, java.lang.String methodName, java.lang.Class[] parameters)
Method
object that is a public member method
of the class or interface represented by this Class
object, if any.
If this Class
object does not contain the method, its parent class
or parent interface will be searched. The search continues until the method is found or there is no
class or interface to search.klass
- The Class
object where the search startsmethodName
- the name of the methodparameters
- the parameter list of the method to searchMethod
object. If no method is found, it will return null.public static java.lang.Object getProperty(java.lang.Object target, java.lang.String propertyName)
target
- the object whose property will be accessedpropertyName
- the getter of the property will be calledNullObject.VALUE