當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.getOptimizationLevel方法代碼示例

本文整理匯總了Java中org.mozilla.javascript.Context.getOptimizationLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.getOptimizationLevel方法的具體用法?Java Context.getOptimizationLevel怎麽用?Java Context.getOptimizationLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.javascript.Context的用法示例。


在下文中一共展示了Context.getOptimizationLevel方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processFileSecure

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
static void processFileSecure(Context cx, Scriptable scope,
                              String path, Object securityDomain)
        throws IOException {

    boolean isClass = path.endsWith(".class");
    Object source = readFileOrUrl(path, !isClass);

    byte[] digest = getDigest(source);
    String key = path + "_" + cx.getOptimizationLevel();
    ScriptReference ref = scriptCache.get(key, digest);
    Script script = ref != null ? ref.get() : null;

    if (script == null) {
        if (isClass) {
            script = loadCompiledScript(cx, path, (byte[]) source, securityDomain);
        } else {
            String strSrc = (String) source;
            // Support the executable script #! syntax:  If
            // the first line begins with a '#', treat the whole
            // line as a comment.
            if (strSrc.length() > 0 && strSrc.charAt(0) == '#') {
                for (int i = 1; i != strSrc.length(); ++i) {
                    int c = strSrc.charAt(i);
                    if (c == '\n' || c == '\r') {
                        strSrc = strSrc.substring(i);
                        break;
                    }
                }
            }
            script = cx.compileString(strSrc, path, 1, securityDomain);
        }
        scriptCache.put(key, digest, script);
    }

    if (script != null) {
        script.exec(cx, scope);
    }
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:39,代碼來源:Main.java

示例2: preHandle

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler)
        throws Exception {
    final Context cx = getContextFactory().enterContext();
    if (cx.getOptimizationLevel() != -1) {
        cx.setOptimizationLevel(-1);
    }
    return true;
}
 
開發者ID:szegedi,項目名稱:spring-web-jsflow,代碼行數:10,代碼來源:OpenContextInViewInterceptor.java

示例3: processFileSecure

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
static void processFileSecure(Context cx, Scriptable scope,
                              String path, Object securityDomain) {

    boolean isClass = path.endsWith(".class");
    Object source = readFileOrUrl(path, !isClass);

    if (source == null) {
        exitCode = EXITCODE_FILE_NOT_FOUND;
        return;
    }

    byte[] digest = getDigest(source);
    String key = path + "_" + cx.getOptimizationLevel();
    ScriptReference ref = scriptCache.get(key, digest);
    Script script = ref != null ? ref.get() : null;

    if (script == null) {
        if (isClass) {
            script = loadCompiledScript(cx, path, (byte[])source, securityDomain);
        } else {
            String strSrc = (String) source;
            // Support the executable script #! syntax:  If
            // the first line begins with a '#', treat the whole
            // line as a comment.
            if (strSrc.length() > 0 && strSrc.charAt(0) == '#') {
                for (int i = 1; i != strSrc.length(); ++i) {
                    int c = strSrc.charAt(i);
                    if (c == '\n' || c == '\r') {
                        strSrc = strSrc.substring(i);
                        break;
                    }
                }
            }
            script = loadScriptFromSource(cx, strSrc, path, 1, securityDomain);
        }
        scriptCache.put(key, digest, script);
    }

    if (script != null) {
        evaluateScript(script, cx, scope);
    }
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:43,代碼來源:Main.java


注:本文中的org.mozilla.javascript.Context.getOptimizationLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。