Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.scripting.ecmascript
Class JavascriptScriptEngine

java.lang.Object
  extended by org.web3d.vrml.scripting.ecmascript.JavascriptScriptEngine
All Implemented Interfaces:
ScriptEngine

public class JavascriptScriptEngine
extends java.lang.Object
implements ScriptEngine

A scripting engine that provides capabilities for VRML97 Javascript.

This implementation does not support the old vrmlscript protocol that was a CosmoPlayer specific hack to avoid implementing a full Javascript system.

The setup process uses delayed loading of the Javascript interpreter. It won't actually initialise Rhino until the first script wrapper needs to be built.

Version:
$Revision: 1.6 $
Author:
Justin Couch

Constructor Summary
JavascriptScriptEngine(BrowserCore browser, RouteManager rm, FrameStateManager fsm, WorldLoaderManager wlm)
          Construct a new script engine with a reference to the enclosing browser.
 
Method Summary
 ScriptWrapper buildWrapper(VRMLExecutionSpace space, java.lang.String contentType, java.lang.Object content)
          Create a wrapper for the given script content.
 java.lang.String[] getSupportedContentTypes()
          Get a listing of the content types that this engine implementation can handle.
 int getSupportedSpecificationVersion()
          Get the version of the specification that this engine implementation supports.
 void setErrorReporter(ErrorReporter reporter)
          Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavascriptScriptEngine

public JavascriptScriptEngine(BrowserCore browser,
                              RouteManager rm,
                              FrameStateManager fsm,
                              WorldLoaderManager wlm)
Construct a new script engine with a reference to the enclosing browser.

Parameters:
browser - The core representation of the browser
rm - A route manager for users creating/removing routes
wlm - Loader for full files
fsm - State manager for coordinating inter-frame processing
Throws:
java.lang.IllegalArgumentException - The browser reference is null
Method Detail

getSupportedSpecificationVersion

public int getSupportedSpecificationVersion()
Get the version of the specification that this engine implementation supports. A script engine only supports a single major version of any given spec.

Specified by:
getSupportedSpecificationVersion in interface ScriptEngine
Returns:
A number greater than one indicating the supported spec.

getSupportedContentTypes

public java.lang.String[] getSupportedContentTypes()
Get a listing of the content types that this engine implementation can handle.

Specified by:
getSupportedContentTypes in interface ScriptEngine
Returns:
A non-empty list of content types

buildWrapper

public ScriptWrapper buildWrapper(VRMLExecutionSpace space,
                                  java.lang.String contentType,
                                  java.lang.Object content)
                           throws InvalidScriptContentException
Create a wrapper for the given script content. The wrapper will be built based on the details from the mime type.

Specified by:
buildWrapper in interface ScriptEngine
Parameters:
space - The execution space this script belongs to
contentType - The MIME type of the engine
content - The actual content loaded from a stream
Returns:
An appropriate wrapper instance
Throws:
InvalidScriptContentException - The form of the content does not match the requirements of the engine.

setErrorReporter

public void setErrorReporter(ErrorReporter reporter)
Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.

Specified by:
setErrorReporter in interface ScriptEngine
Parameters:
reporter - The instance to use or null

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium