Class Main
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Proxy class to avoid proliferation of anonymous classes.(package private) static class
(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static ToolErrorReporter
protected static int
private static final int
private static final int
static Global
(package private) static String
(package private) static boolean
(package private) static Require
(package private) static boolean
private static final Main.ScriptCache
private static SecurityProxy
static ShellContextFactory
(package private) static boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static void
evalInlineScript
(Context cx, String scriptText) static int
Execute the given arguments, but don't System.exit at the end.private static byte[]
static PrintStream
getErr()
static Global
static InputStream
getIn()
static PrintStream
getOut()
(package private) static Scriptable
(package private) static Scriptable
private static void
private static Script
loadCompiledScript
(Context cx, String path, byte[] data, Object securityDomain) static void
Main entry point.private static void
static void
processFile
(Context cx, Scriptable scope, String filename) static void
processFileNoThrow
(Context cx, Scriptable scope, String filename) (package private) static void
processFiles
(Context cx, String[] args) (package private) static void
processFileSecure
(Context cx, Scriptable scope, String path, Object securityDomain) static String[]
processOptions
(String[] args) Parse arguments.static void
processSource
(Context cx, String filename) Evaluate JavaScript source.private static Object
readFileOrUrl
(String path, boolean convertToString) Read file or url specified bypath
.static void
setErr
(PrintStream err) static void
setIn
(InputStream in) static void
setOut
(PrintStream out)
-
Field Details
-
shellContextFactory
-
global
-
errorReporter
-
exitCode
protected static int exitCode -
EXITCODE_RUNTIME_ERROR
private static final int EXITCODE_RUNTIME_ERROR- See Also:
-
EXITCODE_FILE_NOT_FOUND
private static final int EXITCODE_FILE_NOT_FOUND- See Also:
-
processStdin
static boolean processStdin -
fileList
-
modulePath
-
mainModule
-
sandboxed
static boolean sandboxed -
useRequire
static boolean useRequire -
require
-
securityImpl
-
scriptCache
-
-
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. -
processFiles
-
evalInlineScript
-
getGlobal
-
getShellScope
-
getScope
-
processOptions
-
initJavaPolicySecuritySupport
private static void initJavaPolicySecuritySupport() -
processSource
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 readRhinoException
- thrown during evaluation of source
-
processFileNoThrow
-
processFile
- Throws:
IOException
-
processFileSecure
static void processFileSecure(Context cx, Scriptable scope, String path, Object securityDomain) throws IOException - Throws:
IOException
-
getDigest
-
loadCompiledScript
private static Script loadCompiledScript(Context cx, String path, byte[] data, Object securityDomain) throws FileNotFoundException - Throws:
FileNotFoundException
-
printPromiseWarnings
-
getIn
-
setIn
-
getOut
-
setOut
-
getErr
-
setErr
-
readFileOrUrl
Read file or url specified bypath
.- Returns:
- file or url content as
byte[]
or asString
ifconvertToString
is true. - Throws:
IOException
-