java.beans

Class Statement

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.

Since: 1.4

Constructor Summary
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.

Method Summary
voidexecute()
Execute the statement.
Object[]getArguments()
Return the statement arguments.
StringgetMethodName()
Return the statement method name.
ObjectgetTarget()
Return the statement object.
StringtoString()
Returns a string representation of this Statement.

Constructor Detail

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.

Parameters: target The object to invoke the method on. methodName The object method to invoke. arguments An array of arguments to pass to the method.

Method Detail

execute

public void execute()
Execute the statement.

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.

Throws: Exception if an exception occurs while locating or invoking the method.

getArguments

public Object[] getArguments()
Return the statement arguments.

getMethodName

public String getMethodName()
Return the statement method name.

getTarget

public Object getTarget()
Return the statement object.

toString

public String toString()
Returns a string representation of this Statement.

Returns: A string representation of this Statement.