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


Java ScriptContext.setWriter方法代碼示例

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


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

示例1: runScript

import javax.script.ScriptContext; //導入方法依賴的package包/類
public static void runScript(Network network, Reader reader, Writer out) {
    ScriptEngineManager mgr = new ScriptEngineManager();
    ScriptEngine jsEngine = mgr.getEngineByName("js");
    try {
        ScriptContext context = new SimpleScriptContext();
        context.setAttribute("network", network, ScriptContext.ENGINE_SCOPE);
        if (out != null) {
            context.setWriter(out);
        }
        jsEngine.eval(reader, context);
    } catch (ScriptException e) {
        throw new PowsyblException(e);
    }
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:15,代碼來源:Networks.java

示例2: start

import javax.script.ScriptContext; //導入方法依賴的package包/類
protected void start(boolean console) {
  ScriptContext context = engine.getContext();
  OutputStream out = getOutputStream();
  if (out != null) {
    context.setWriter(new PrintWriter(out));
  }
  OutputStream err = getErrorStream();
  if (err != null) {
    context.setErrorWriter(new PrintWriter(err));
  }
  // load "sa.js" initialization file
  loadInitFile();
  // load "~/jsdb.js" (if found) to perform user specific
  // initialization steps, if any.
  loadUserInitFile();

  JSJavaFactory fac = getJSJavaFactory();
  JSJavaVM jvm = (fac != null)? fac.newJSJavaVM() : null;
  // call "main" function from "sa.js" -- main expects
  // 'this' object and jvm object
  call("main", new Object[] { this, jvm });

  // if asked, start read-eval-print console
  if (console) {
    processSource(null);
  }
}
 
開發者ID:arodchen,項目名稱:MaxSim,代碼行數:28,代碼來源:JSJavaScriptEngine.java

示例3: applyTo

import javax.script.ScriptContext; //導入方法依賴的package包/類
public void applyTo ( final ScriptContext scriptContext )
{
    scriptContext.setWriter ( new PrintWriter ( new OutputStreamWriter ( this.writerStream ) ) );
    scriptContext.setErrorWriter ( this.errorPrintWriter );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:6,代碼來源:ConsoleContext.java


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