<invoke>
Purpose/Function
Use reflection to invoke a method on an object.
This task assumes the target object and all parameter values already exist in the environment. (Note that ncsa.tools.ogrescript.types.JavaConstructor
– see Assign and Declare – carries the same constraint vis-à-vis its parameter values.)
If invokeFirst is set to false and there are multiple matches, an exception will be thrown.
Attributes
NAME |
TYPE |
DEFAULT VALUE |
DESCRIPTION |
---|---|---|---|
target |
|
(required) |
invocation target instance, passed in from the environment |
methodName |
|
(required) |
exact name of the method to be invoked |
fullScan |
|
|
search the entire class hierarchy for the method |
invokeFirst |
|
|
if multiple methods are found, invoke the first encountered (i.e., that of the specific subclass) |
global |
|
|
if declaring or assigning return value, use global frame |
declare |
|
|
declare return value as variable with this name |
assign |
|
|
assign return value to variable with this name |
Elements
TAG |
TYPE |
COUNT |
DESCRIPTION |
---|---|---|---|
<parameter-value> |
|
0:N |
value of a parameter the method signature will accept |
These should be added in the order required by the method signature. Polymorphism functions normally here.
ReturnValues
The invocation return value can be directly assigned to environment by setting the declare or assign attribute.
Examples
<ogrescript> <declare name="list" configured="true"> <list> <value>false</value> <value>string-beans</value> <value>043.24398</value> <value>hypertension</value> </list> </declare> <declare name="newValue" string="anemia"/> <declare name="index" int="3"/> <invoke target="${list}" methodName="set"> <parameter-value>${index}</parameter-value> <parameter-value>${newValue}</parameter-value> </invoke> </ogrescript>
The side-effected list should be:
[OgreScript:false, string-beans, 043.24398, anemia]