java.beans
public class Statement extends Object
A Statement captures the execution of an object method. It stores the object, the method to call, and the arguments to the method and provides the ability to execute the method on the object, using the provided arguments.
Constructor and Description |
---|
Statement(Object target,
String methodName,
Object[] arguments)
Constructs a statement representing the invocation of
object.methodName(arg[0], arg[1], ...)
|
Modifier and Type | Method and Description |
---|---|
void |
execute()
Execute the statement.
|
Object[] |
getArguments()
Return the statement arguments.
|
String |
getMethodName()
Return the statement method name.
|
Object |
getTarget()
Return the statement object.
|
String |
toString()
Returns a string representation of this
Statement . |
public Statement(Object target, String methodName, Object[] arguments)
Constructs a statement representing the invocation of object.methodName(arg[0], arg[1], ...);
If the argument array is null it is replaced with an array of zero length.
target
- The object to invoke the method on.methodName
- The object method to invoke.arguments
- An array of arguments to pass to the method.public void execute() throws Exception
Finds the specified method in the target object and calls it with the arguments given in the constructor.
The most specific method according to the JLS(15.11) is used when there are multiple methods with the same name.
Execute performs some special handling for methods and parameters:
The Sun spec doesn't deal with overloading between int and Integer carefully. If there are two methods, one that takes an Integer and the other taking an int, the method chosen is not specified, and can depend on the order in which the methods are declared in the source file.
Exception
- if an exception occurs while locating or
invoking the method.public Object[] getArguments()
public String getMethodName()
public String toString()
Statement
.toString
in class Object
Statement
.Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)