com.cycling74.max
Class Callback

java.lang.Object
  extended by com.cycling74.max.Callback
All Implemented Interfaces:
Executable

public class Callback
extends Object
implements Executable

Used to transform a java method into an Executable object. This simplify the job of always implementing the executable interface on all your objects since you can define it dynamically with this class.

 
 class Myclass  {
    public void doit() {
                do_something_fun()
    }
 }
 
 ...
 
      Myclass myclass = new Myclass();
      Executable e = new Callback(myclass, "doit");
      MaxClock clock = new MaxClock(e);
 
 


Constructor Summary
Callback(Object obj, String methodName)
          Will call method methodName with no argument by using execute()
Callback(Object obj, String methodName, boolean flag)
          Will call method methodName with a boolean by using execute()
Callback(Object obj, String methodName, float f)
          Will call method methodName with a float by using execute()
Callback(Object obj, String methodName, int i)
          Will call method methodName with a int by using execute()
Callback(Object obj, String methodName, Object[] params)
          Will call method methodName with multiple arguments by using execute()
Callback(Object obj, String methodName, Object[] params, Class[] params_types)
          Will call method methodName with multiple arguments (typed) by using execute()
Callback(Object obj, String methodName, String str)
          Will call method methodName with a Stringt by using execute()
 
Method Summary
 void execute()
          Execute the method with arguments specified at constructor
 Object[] getArgs()
          Returns the argument that will be used when the execute method will be invoke.
 Method getMethod()
          Returns the Method that will be used with the execute call
 String getMethodName()
          Returns the method name invoked on object with the execute call
 Object getObject()
          Returns the object used to issue the call
 void setArgs(boolean flag)
          Sets boolean argument to method
 void setArgs(float f)
          Sets float argument to method
 void setArgs(int i)
          Sets int argument to method
 void setArgs(Object[] args)
          Set the argument for the execute call
 void setArgs(String value)
          Sets String argument to method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Callback

public Callback(Object obj,
                String methodName)
Will call method methodName with no argument by using execute()

Parameters:
obj - the object with the method
methodName - the name of the method

Callback

public Callback(Object obj,
                String methodName,
                int i)
Will call method methodName with a int by using execute()

Parameters:
obj - the object with the method
methodName - the name of the method
i - the int value

Callback

public Callback(Object obj,
                String methodName,
                float f)
Will call method methodName with a float by using execute()

Parameters:
obj - the object with the method
methodName - the name of the method
f - the float value

Callback

public Callback(Object obj,
                String methodName,
                String str)
Will call method methodName with a Stringt by using execute()

Parameters:
obj - the object with the method
methodName - the name of the method
str - the string value

Callback

public Callback(Object obj,
                String methodName,
                boolean flag)
Will call method methodName with a boolean by using execute()

Parameters:
obj - the object with the method
methodName - the name of the method
flag - the boolean value

Callback

public Callback(Object obj,
                String methodName,
                Object[] params)
Will call method methodName with multiple arguments by using execute()

Parameters:
obj - the object with the method
methodName - the name of the method
params - argument to pass to the method

Callback

public Callback(Object obj,
                String methodName,
                Object[] params,
                Class[] params_types)
Will call method methodName with multiple arguments (typed) by using execute()

Parameters:
obj - the object with the method
methodName - the name of the method
params - argument to pass to the method
params_types - the type of arguments
Method Detail

execute

public void execute()
Execute the method with arguments specified at constructor

Specified by:
execute in interface Executable

getArgs

public Object[] getArgs()
Returns the argument that will be used when the execute method will be invoke.

Returns:
the array of arguments

getObject

public Object getObject()
Returns the object used to issue the call

Returns:
the object to use with execute

getMethod

public Method getMethod()
Returns the Method that will be used with the execute call

Returns:
the method given by reflection

getMethodName

public String getMethodName()
Returns the method name invoked on object with the execute call

Returns:
the method name

setArgs

public void setArgs(int i)
Sets int argument to method

Parameters:
i - int value

setArgs

public void setArgs(float f)
Sets float argument to method

Parameters:
f - float argument

setArgs

public void setArgs(String value)
Sets String argument to method

Parameters:
value - int value

setArgs

public void setArgs(boolean flag)
Sets boolean argument to method

Parameters:
flag - boolean value

setArgs

public void setArgs(Object[] args)
Set the argument for the execute call

Parameters:
args - the array object to pass to the method


This API is based on mxj for Max/MSP by Cycling74. Please see original MXJ implementation.