Package repast.simphony.engine.schedule
Class CallBackAction
- java.lang.Object
-
- repast.simphony.engine.schedule.CallBackAction
-
- All Implemented Interfaces:
IAction
public class CallBackAction extends Object implements IAction
An IAction created from a method name and method parameters. When a CallBackAction is executed it will call the named method passing the parameters.- Version:
- $Revision: 1.1 $ $Date: 2005/12/21 22:25:34 $
- Author:
- Nick Collier
-
-
Constructor Summary
Constructors Constructor Description CallBackAction(Object target, Method method)
Creates a CallBackAction from the specified target and method.CallBackAction(Object target, Method method, Object... parameters)
Creates a CallBackAction from the specified target, method and parameters.CallBackAction(Object target, String methodName, Object... parameters)
Creates a CallBackAction from the specified target, method name, and method parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute()
Calls the method named in the constructor on the target named in the constructor.Object[]
getArgs()
net.sf.cglib.reflect.FastMethod
getFastMethod()
Method
getMethod()
Gets the method that this callback action will call.String
getMethodName()
Object
getTarget()
void
setArgs(int index, Object arg)
Sets the argument that is passed to the wrapped method.void
setTarget(Object obj)
Sets the target of the method call.
-
-
-
Constructor Detail
-
CallBackAction
public CallBackAction(Object target, Method method)
Creates a CallBackAction from the specified target and method. When executed, the CallBackAction will call the the method on the target.- Parameters:
target
- the object to call the method onmethod
- the method to call
-
CallBackAction
public CallBackAction(Object target, Method method, Object... parameters)
Creates a CallBackAction from the specified target, method and parameters. When executed, the CallBackAction will call the the method on the target passing the parameters.- Parameters:
target
- the object to call the method onmethod
- the method to callparameters
- the parameters to pass to the method call
-
CallBackAction
public CallBackAction(Object target, String methodName, Object... parameters)
Creates a CallBackAction from the specified target, method name, and method parameters. When executed, the CallBack action will call the named method on the target passing the specified parameters.- Parameters:
target
- the object to call the method onmethodName
- the name of the method to callparameters
- the parameters to pass to the method- Throws:
IllegalArgumentException
- if the target does not contain a method with the appropriate signature.
-
-
Method Detail
-
setArgs
public void setArgs(int index, Object arg)
Sets the argument that is passed to the wrapped method. Note that using this method is only necessary if the parameters passed into the constructor do not act as references. For example, if an int value is passed in the constructor that int value will be automatically updated as a reference to some other int value. This method allows client code to set the value of that int.- Parameters:
index
- the index into the argument arrayarg
- the argument to pass to the method
-
getArgs
public Object[] getArgs()
-
execute
public void execute()
Calls the method named in the constructor on the target named in the constructor.
-
getMethodName
public String getMethodName()
- Returns:
- the name of the method to be called on the target object.
-
getMethod
public Method getMethod()
Gets the method that this callback action will call.- Returns:
- the method that this callback action will call.
-
getFastMethod
public net.sf.cglib.reflect.FastMethod getFastMethod()
-
getTarget
public Object getTarget()
- Returns:
- the target object whose method will be called in the execution of this action.
-
setTarget
public void setTarget(Object obj)
Sets the target of the method call.- Parameters:
obj
- the new target of the method call
-
-