java.lang.Object
org.mozilla.javascript.tools.shell.Main
The shell program.
Can execute scripts interactively or in batch mode at the command line. An example of controlling the JavaScript engine.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static ToolErrorReporterprotected static intstatic Globalstatic ShellContextFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intExecute the given arguments, but don't System.exit at the end.static PrintStreamgetErr()static Globalstatic InputStreamgetIn()static PrintStreamgetOut()static voidMain entry point.static voidprocessFile(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, String filename) static voidprocessFileNoThrow(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, String filename) static String[]processOptions(String[] args) Parse arguments.static voidprocessSource(org.mozilla.javascript.Context cx, String filename) Evaluate JavaScript source.static voidsetErr(PrintStream err) static voidsetIn(InputStream in) static voidsetOut(PrintStream out)
-
Field Details
-
shellContextFactory
-
global
-
errorReporter
-
exitCode
protected static int exitCode
-
-
Constructor Details
-
Main
public Main()
-
-
Method Details
-
main
Main entry point.Process arguments as would a normal Java program. Also create a new Context and associate it with the current thread. Then set up the execution environment and begin to execute scripts.
-
exec
Execute the given arguments, but don't System.exit at the end. -
getGlobal
-
processOptions
Parse arguments. -
processSource
public static void processSource(org.mozilla.javascript.Context cx, String filename) throws IOException Evaluate JavaScript source.- Parameters:
cx- the current contextfilename- the name of the file to compile, or null for interactive mode.- Throws:
IOException- if the source could not be readorg.mozilla.javascript.RhinoException- thrown during evaluation of source
-
processFileNoThrow
public static void processFileNoThrow(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, String filename) -
processFile
public static void processFile(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, String filename) throws IOException - Throws:
IOException
-
getIn
-
setIn
-
getOut
-
setOut
-
getErr
-
setErr
-