You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2007/12/05 03:56:27 UTC

svn commit: r601195 - /xmlgraphics/batik/trunk/documentation-sources/content/xdocs/using/scripting/ecmascript.xml

Author: cam
Date: Tue Dec  4 18:56:26 2007
New Revision: 601195

URL: http://svn.apache.org/viewvc?rev=601195&view=rev
Log:
Update the examples to compile.

Modified:
    xmlgraphics/batik/trunk/documentation-sources/content/xdocs/using/scripting/ecmascript.xml

Modified: xmlgraphics/batik/trunk/documentation-sources/content/xdocs/using/scripting/ecmascript.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/documentation-sources/content/xdocs/using/scripting/ecmascript.xml?rev=601195&r1=601194&r2=601195&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/documentation-sources/content/xdocs/using/scripting/ecmascript.xml (original)
+++ xmlgraphics/batik/trunk/documentation-sources/content/xdocs/using/scripting/ecmascript.xml Tue Dec  4 18:56:26 2007
@@ -190,22 +190,25 @@
       </p>
       <source>import org.apache.batik.script.rhino.RhinoInterpreter;
 
+import java.net.URL;
+
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Function;
 import org.mozilla.javascript.Scriptable;
 import org.mozilla.javascript.ScriptableObject;
 import org.mozilla.javascript.PropertyException;
 
-public class ExtendedRhinoInterpreter extends RhinoIntepreter {
+public class ExtendedRhinoInterpreter extends RhinoInterpreter {
 
-    public ExtendedRhinoInterpreter() {
+    public ExtendedRhinoInterpreter(URL documentURL) {
+        super(documentURL);
 
         // Array of functions to put in the global object.
         final String[] names = { "print" }
         try {
             // Add the functions to the global object.
             getGlobalObject().defineFunctionProperties
-                (names, ExtendedRhinoIntepreter.class,
+                (names, ExtendedRhinoInterpreter.class,
                  ScriptableObject.DONTENUM);
         } catch (PropertyException e) {
             throw new Error(e);
@@ -232,12 +235,12 @@
         instances of your interpreter.
       </p>
       <source>import org.apache.batik.script.Interpreter;
-import org.apache.batik.script.InterpreterFactory;
+import org.apache.batik.script.rhino.RhinoInterpreterFactory;
 
-public class ExtendedRhinoInterpreterFactory implements InterpreterFactory {
+public class ExtendedRhinoInterpreterFactory extends RhinoInterpreterFactory {
 
-    public Interpreter createInterpreter() {
-        return new ExtendedRhinoInterpreter();
+    public Interpreter createInterpreter(URL documentURL, boolean isSVG12) {
+        return new ExtendedRhinoInterpreter(documentURL);
     }
 }</source>
       <p>
@@ -250,8 +253,14 @@
       <source>org.apache.batik.bridge.BridgeContext ctx = ...;
 org.apache.batik.script.InterpreterPool pool =
     new org.apache.batik.script.InterpreterPool();
-pool.putInterpreterFactory("text/ecmascript", 
-                           new ExtendedRhinoInterpreterFactory());
+InterpreterFactory f = new ExtendedRhinoInterpreterFactory();
+
+// Register the interpreter factory for all four MIME types that
+// Batik normally supports for ECMAScript.
+pool.putInterpreterFactory("text/ecmascript", f);
+pool.putInterpreterFactory("text/javascript", f);
+pool.putInterpreterFactory("application/ecmascript", f);
+pool.putInterpreterFactory("application/javascript", f);
 ctx.setIntepreterPool(pool);</source>
       <p>
         For example if you are using the Batik SVG browser application you