Hi,
I'm trying to follow the example at
http://xmlgraphics.apache.org/batik/using/scripting/ecmascript.html#customizingRhino
to extend the RhinoInterpreter and include a print function but it's not
working out for me. Just a note: RhinoInterpreter is spelled incorrectly in
the class declaration line.
I'm using Batik 1.7, Java 1.3.1, netbeans, a macbook, and this code:
package raprogram.svg.script;
import java.net.URL;
import org.apache.batik.script.rhino.*;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.PropertyException;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
public class ExtendedRhinoInterpreter extends RhinoInterpreter {
public ExtendedRhinoInterpreter(URL 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,
ScriptableObject.DONTENUM);
} catch (PropertyException e) {
throw new Error(e);
}
}
public static void print(Context cx, Scriptable thisObj,
Object[] args, Function funObj) {
for (int i = 0; i < args.length; i++) {
if (i > 0) {
System.out.print(" ");
}
// Convert the ECMAScript value into a string form.
String s = Context.toString(args[i]);
System.out.print(s);
}
System.out.println();
}
}
I'm getting an error with the constructor. The example is missing the URL
argument but even when I add it I get this error:
ExtendedRhinoInterpreter.java:24: RhinoInterpreter(java.net.URL) in
org.apache.batik.script.rhino.RhinoInterpreter cannot be applied to ()
A second error I'm getting is with this line:
getGlobalObject().defineFunctionProperties
(names, ExtendedRhinoIntepreter.class,
ScriptableObject.DONTENUM);
The error is:
ExtendedRhinoInterpreter.java:31: cannot find symbol
symbol : class ExtendedRhinoIntepreter
location: class raprogram.svg.script.ExtendedRhinoInterpreter
(names, ExtendedRhinoIntepreter.class,
Any help would be greatly appreciated.
Regards,
Jeff Cressman
--
View this message in context:
http://www.nabble.com/problems-extending-RhinoInterpreter-tf4934336.html#a14123824
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]