java.beans
Class Statement

java.lang.Object
  extended by java.beans.Statement
Direct Known Subclasses:
Expression

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], ...)
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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()
             throws Exception
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.

Overrides:
toString in class Object
Returns:
A string representation of this Statement.
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)