org.eclipse.actf.validation.doc.scripting
Class JavaScriptCodeInterpreter

java.lang.Object
  extended by org.eclipse.actf.validation.doc.codeproc.AbstractCodeProcessor
      extended by org.eclipse.actf.validation.doc.scripting.AbstractCodeInterpreter
          extended by org.eclipse.actf.validation.doc.scripting.JavaScriptCodeInterpreter
All Implemented Interfaces:
ICodeProcessor

public class JavaScriptCodeInterpreter
extends AbstractCodeInterpreter

A code interpreter for scripts written in JavaScript/Rhino.

Author:
Mike Squillace

Field Summary
 
Fields inherited from class org.eclipse.actf.validation.doc.scripting.AbstractCodeInterpreter
manager
 
Fields inherited from class org.eclipse.actf.validation.doc.codeproc.AbstractCodeProcessor
classpath, configuration, language, model
 
Fields inherited from interface org.eclipse.actf.validation.doc.codeproc.ICodeProcessor
FACTORY_PROCESSOR_KEY, SCRIPTLANG_ID
 
Constructor Summary
JavaScriptCodeInterpreter(String lang, IModel model)
          create a new interpreter for JavaScript
 
Method Summary
protected  void finalize()
           
protected  String formatPackageImport(String packageName)
           
protected  void initClasspath()
          initializes the underlying scripting engine with the classpath supplied via setClasspath.
protected  Object toJavaObject(Object o, Class c)
          overwritten by those interpreters that wrap the results of evaluations in API-specific instances
protected  Object[] toJavaObjects(Object o, Class[] paramTypes)
          convert the given object to an array of objects of the specified types.
 
Methods inherited from class org.eclipse.actf.validation.doc.scripting.AbstractCodeInterpreter
addScript, addScript, evaluateArguments, evaluateArguments, getEnvironment, getExpressionDelimiter, getInitCode, getLanguageSupportsTuples, getNullValue, getScript, isCompilerProcessor, postInit, preInit, processCode, setClasspath, setEnvironment, setLanguageSupportsTuples, setLocal
 
Methods inherited from class org.eclipse.actf.validation.doc.codeproc.AbstractCodeProcessor
addScript, addScripts, getClasspath, getFileContents, getLanguage, getModel, isIdVisible, makeExpressionList, prepareCode, setIdVisibility, setLanguage, setModel
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaScriptCodeInterpreter

public JavaScriptCodeInterpreter(String lang,
                                 IModel model)
create a new interpreter for JavaScript

Parameters:
lang -
arch -
Method Detail

initClasspath

protected void initClasspath()
Description copied from class: AbstractCodeInterpreter
initializes the underlying scripting engine with the classpath supplied via setClasspath. This will be the classpath referenced from within actual script code.

Overrides:
initClasspath in class AbstractCodeInterpreter
See Also:
AbstractCodeInterpreter.setClasspath(String)

formatPackageImport

protected String formatPackageImport(String packageName)
Specified by:
formatPackageImport in class AbstractCodeInterpreter

toJavaObject

protected Object toJavaObject(Object o,
                              Class c)
overwritten by those interpreters that wrap the results of evaluations in API-specific instances

Specified by:
toJavaObject in class AbstractCodeInterpreter
Parameters:
o - -- wrapped object
c - -- desired type
Returns:
"unwrapped" o as type c

toJavaObjects

protected Object[] toJavaObjects(Object o,
                                 Class[] paramTypes)
convert the given object to an array of objects of the specified types. This version is typically used by those interpreters in which languageSupportsTuples() returns true

Specified by:
toJavaObjects in class AbstractCodeInterpreter
Parameters:
o - -- API-dependent tuple object
paramTypes - -- desired types of returned objects
Returns:
array of objects of the specified types or null if conversion could not be performed
See Also:
AbstractCodeInterpreter.getLanguageSupportsTuples()

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable