ClassWrapper
ptolemy.actor.lib.ClassWrapper

This actor wraps (an instance of) a Java class specified by the className parameter. The actor has no ports when created. If an input port is added to the actor, the name of the port is interpreted as the name of a method of the Java class. When the actor is fired and a token is received from this input port, the value of the token is treated as the argument(s) for invoking the method. If the method has a return value and the actor has an output port named methodNameResult, the return value is wrapped in a token that is sent to the output port.

For example, suppose the specified class has a method named foo and the actor has an input port of the same name. If method foo takes no argument, the token received from port foo is treated as the trigger for invoking the method, and its content is ignored. If method foo takes arguments, the input token should be a record token whose field values are used as the arguments. The field labels of the record token should be "arg1", "arg2", etc. For example, if method foo takes two double arguments, the record token "{arg1 = 0.0, arg2 = 1.0}" can be the input. A special case is when method foo takes one argument, the token containing the argument value can be input directly, and does not need to be put into a record token.

FIXME: Need to set type constraints appropriately. Need (and how) to handle overloaded methods.

Author(s): Xiaojun Liu
Version:$Id: ClassWrapper.java,v 1.28 2006/03/04 21:54:23 eal Exp $
Pt.Proposed Rating:Red (liuxj)
Pt.Accepted Rating:Red (liuxj)