Java 类org.mozilla.javascript.tools.shell.Main 实例源码

项目:whackpad    文件:ShellTest.java   
private static void runFileIfExists(Context cx, Scriptable global, File f)
{
    if(f.isFile())
    {
        Main.processFile(cx, global, f.getPath());
    }
}
项目:dwr    文件:ShrinkSafeCompressor.java   
public String compressJavaScript(final String source) throws Exception
{
    final Exception[] thrown = new Exception[1];
    String reply = (String) Main.shellContextFactory.call(new ContextAction()
    {
        public Object run(Context cx)
        {
            try
            {
                // The shrinksafe Compressor only obfuscates the javascript. Line breaks are removed
                // by the dojo build. Adding the removal of line breaks to make the optimization that
                // would come from using the dojo build. See
                // http://svn.dojotoolkit.org/src/tags/release-1.5.0/util/buildscripts/jslib/buildUtil.js
                // in the buildUtil.optimizeJs function which has the following:
                // if(optimizeType.indexOf("shrinksafe") == 0 || optimizeType == "packer"){
                //     //Apply compression using custom compression call in Dojo-modified rhino.
                //     fileContents = new String(Packages.org.dojotoolkit.shrinksafe.Compressor.compressScript(fileContents, 0, 1, stripConsole));
                //     if(optimizeType.indexOf(".keepLines") == -1){
                //         fileContents = fileContents.replace(/[\r\n]/g, "");
                //     }
                // }
                String obfuscated = org.dojotoolkit.shrinksafe.Compressor.compressScript(source, 0, 1, false, null);
                return obfuscated.replaceAll("[\\r\\n]", "");
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
                thrown[0] = ex;
            }
            return null;
        }
    });

    if (thrown[0] != null)
    {
        throw thrown[0];
    }
    else
    {
        return reply;
    }
}
项目:rhino-android    文件:ShellTest.java   
private static void runFileIfExists(Context cx, Scriptable global, File f) {
    if(f.isFile()) {
        Main.processFileNoThrow(cx, global, f.getPath());
    }
}
项目:code404    文件:ShellTest.java   
private static void runFileIfExists(Context cx, Scriptable global, File f) {
    if(f.isFile()) {
        Main.processFileNoThrow(cx, global, f.getPath());
    }
}
项目:rhino-jscover    文件:ShellTest.java   
private static void runFileIfExists(Context cx, Scriptable global, File f) {
    if(f.isFile()) {
        Main.processFileNoThrow(cx, global, f.getPath());
    }
}
项目:astor    文件:ShellTest.java   
private static void runFileIfExists(Context cx, Scriptable global, File f) {
    if(f.isFile()) {
        Main.processFileNoThrow(cx, global, f.getPath());
    }
}
项目:Rhino-Prov-Mod    文件:ShellTest.java   
private static void runFileIfExists(Context cx, Scriptable global, File f) {
    if(f.isFile()) {
        Main.processFileNoThrow(cx, global, f.getPath());
    }
}