public static void setVariable( Context actualContext, Scriptable actualObject, Object[] arguments,
Function functionContext ) {
if ( arguments.length != 3 ) {
throw Context.reportRuntimeError( "The function call setVariable requires 3 arguments." );
}
Object stepObject = Context.jsToJava( actualObject.get( "_step_", actualObject ), StepInterface.class );
if ( stepObject instanceof StepInterface ) {
StepInterface step = (StepInterface) stepObject;
Trans trans = step.getTrans();
final String variableName = Context.toString( arguments[ 0 ] );
final String variableValue = Context.toString( arguments[ 1 ] );
final VariableScope variableScope = getVariableScope( Context.toString( arguments[ 2 ] ) );
step.setVariable( variableName, variableValue );
switch ( variableScope ) {
case PARENT:
setParentScopeVariable( trans, variableName, variableValue );
break;
case GRAND_PARENT:
setGrandParentScopeVariable( trans, variableName, variableValue );
break;
case ROOT:
setRootScopeVariable( trans, variableName, variableValue );
break;
case SYSTEM:
setSystemScopeVariable( trans, variableName, variableValue );
break;
}
}
}