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 classProxy class to avoid proliferation of anonymous classes.(package private) static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static ToolErrorReporterprotected static intprivate static final intprivate static final intstatic Global(package private) static String(package private) static boolean(package private) static Require(package private) static booleanprivate static final Main.ScriptCacheprivate static SecurityProxystatic ShellContextFactory(package private) static boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidevalInlineScript(Context cx, String scriptText) static intExecute the given arguments, but don't System.exit at the end.private static byte[]static PrintStreamgetErr()static Globalstatic InputStreamgetIn()static PrintStreamgetOut()(package private) static Scriptable(package private) static Scriptableprivate static voidprivate static ScriptloadCompiledScript(Context cx, String path, byte[] data, Object securityDomain) static voidMain entry point.private static voidstatic voidprocessFile(Context cx, Scriptable scope, String filename) static voidprocessFileNoThrow(Context cx, Scriptable scope, String filename) (package private) static voidprocessFiles(Context cx, String[] args) (package private) static voidprocessFileSecure(Context cx, Scriptable scope, String path, Object securityDomain) static String[]processOptions(String[] args) Parse arguments.static voidprocessSource(Context cx, String filename) Evaluate JavaScript source.private static ObjectreadFileOrUrl(String path, boolean convertToString) Read file or url specified bypath.static voidsetErr(PrintStream err) static voidsetIn(InputStream in) static voidsetOut(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
Parse arguments. -
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 asStringifconvertToStringis true. - Throws:
IOException
-