scripting
Class JSInterpreterDriver

java.lang.Object
  extended by scripting.JSInterpreterDriver
All Implemented Interfaces:
java.lang.Runnable, InterpreterDriver

public class JSInterpreterDriver
extends java.lang.Object
implements InterpreterDriver, java.lang.Runnable

JavaScript / EcmaScript implementation of a language interpreter. This class uses the FESI library by Jean-Marc Lugrin for interpretation, available at:

http://www.lugrin.ch/fesi/


Nested Class Summary
 
Nested classes/interfaces inherited from interface scripting.InterpreterDriver
InterpreterDriver.InterpreterException
 
Constructor Summary
JSInterpreterDriver()
          Default constructor
 
Method Summary
 void executeScript(java.lang.String script, java.lang.String[] argNames, java.lang.String[] argValues)
          Executes the specified JavaScript/EcmaScript code
 void executeScriptFile(java.lang.String scriptFile, java.lang.String[] argNames, java.lang.String[] argValues)
          Executes JavaScript/Ecma code contained in the specified file
 java.lang.String[] getSupportedExtensions()
          Returns the list of file extensions supported by this interpreter
 java.lang.String[] getSupportedLanguages()
          Returns the list of languages supported by this interpreter
 void run()
          Interprets a script in a new thread
 void setVariable(java.lang.String name, java.lang.String value)
          Sets a variable/member to the specified value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSInterpreterDriver

public JSInterpreterDriver()
                    throws FESI.jslib.JSException
Default constructor

Throws:
FESI.jslib.JSException
Method Detail

executeScript

public void executeScript(java.lang.String script,
                          java.lang.String[] argNames,
                          java.lang.String[] argValues)
                   throws InterpreterDriver.InterpreterException
Executes the specified JavaScript/EcmaScript code

Specified by:
executeScript in interface InterpreterDriver
Parameters:
script - the script data to execute
argNames - an array containing the names of arguments to be passed to the evaluation
argValues - an array containing the values of the arguments to be passed to the evaluation
Throws:
InterpreterDriver.InterpreterException - if an exception occurs during execution

executeScriptFile

public void executeScriptFile(java.lang.String scriptFile,
                              java.lang.String[] argNames,
                              java.lang.String[] argValues)
                       throws InterpreterDriver.InterpreterException
Executes JavaScript/Ecma code contained in the specified file

Specified by:
executeScriptFile in interface InterpreterDriver
Parameters:
scriptFile - filename containing the code to be executed. This must end in either a '.js' or '.es' extension.
argNames - an array containing the names of arguments to be passed to the evaluation
argValues - an array containing the values of the arguments to be passed to the evaluation
Throws:
InterpreterDriver.InterpreterException - if an exception occurs during execution

getSupportedExtensions

public java.lang.String[] getSupportedExtensions()
Returns the list of file extensions supported by this interpreter

Specified by:
getSupportedExtensions in interface InterpreterDriver
Returns:
an array of strings containing the extensions 'js' and 'es'

getSupportedLanguages

public java.lang.String[] getSupportedLanguages()
Returns the list of languages supported by this interpreter

Specified by:
getSupportedLanguages in interface InterpreterDriver
Returns:
an array of string containing the languages 'JavaScript' and 'EcmaScript'

setVariable

public void setVariable(java.lang.String name,
                        java.lang.String value)
Sets a variable/member to the specified value

Specified by:
setVariable in interface InterpreterDriver
Parameters:
name - the name of the variable to set
value - the value to assign the variable

run

public void run()
Interprets a script in a new thread

Specified by:
run in interface java.lang.Runnable