bsh.Interpreter.setErr()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中bsh.Interpreter.setErr()方法的一些代码示例,展示了Interpreter.setErr()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Interpreter.setErr()方法的具体详情如下:
包路径:bsh.Interpreter
类名称:Interpreter
方法名:setErr

Interpreter.setErr介绍

暂无

代码示例

代码示例来源:origin: beanshell/beanshell

public void setErr(final PrintStream value) {
  _interpreter.setErr(value);
}

代码示例来源:origin: jitlogic/zorka

public void setErr(final PrintStream value) {
  _interpreter.setErr(value);
}

代码示例来源:origin: beanshell/beanshell

/**
  De-serialization setup.
  Default out and err streams to stdout, stderr if they are null.
*/
private void readObject(ObjectInputStream stream)
  throws IOException, ClassNotFoundException
{
  stream.defaultReadObject();
  // set transient fields
  setOut( System.out );
  setErr( System.err );
}

代码示例来源:origin: jitlogic/zorka

/**
  De-serialization setup.
  Default out and err streams to stdout, stderr if they are null.
*/
private void readObject(ObjectInputStream stream) 
  throws java.io.IOException, ClassNotFoundException
{
  stream.defaultReadObject();
  // set transient fields
  if ( console != null ) {
    setOut( console.getOut() );
    setErr( console.getErr() );
  } else {
    setOut( System.out );
    setErr( System.err );
  }
}

代码示例来源:origin: jitlogic/zorka

/**
  Attach a console
  Note: this method is incomplete.
*/
public void setConsole( ConsoleInterface console ) {
  this.console = console;
  setu( "bsh.console", console );
  // redundant with constructor
  setOut( console.getOut() );
  setErr( console.getErr() );
  // need to set the input stream - reinit the parser?
}

代码示例来源:origin: beanshell/beanshell

/** Attempt the release of open resources.
 * @throws IOException */
public void close() throws IOException {
  EOF = true;
  if ( null != getErr() ) {
    if ( !getErr().equals(System.err) )
      getErr().close();
    setErr(null);
  }
  if ( null != getOut() ) {
    if ( !getOut().equals(System.out) )
      getOut().close();
    setOut(null);
  }
  if ( null != getIn() ) {
    getIn().close();
    console.setIn(null);
  }
}

代码示例来源:origin: org.apache.maven.shared/maven-script-interpreter

engine.setErr( scriptOutput );
engine.setOut( scriptOutput );

代码示例来源:origin: org.scijava/scripting-beanshell

protected void setup() {
  final ScriptContext context = getContext();
  final Reader reader = context.getReader();
  if (reader != null) {
    log().warn("Beanshell does not support redirecting the input");
  }
  final Writer writer = context.getWriter();
  if (writer != null) interpreter.setOut(new PrintStream(
    new WriterOutputStream(writer)));
  final Writer errorWriter = context.getErrorWriter();
  if (errorWriter != null) interpreter.setErr(new PrintStream(
    new WriterOutputStream(errorWriter)));
}

代码示例来源:origin: beanshell/beanshell

localInterpreter.console.setIn(null);
  localInterpreter.setOut(null);
  localInterpreter.setErr(null);
} catch (IOException ioe) {
  throw new EvalError("Sourced file: "+sourceFileInfo+" "

代码示例来源:origin: beanshell/beanshell

private Object evalSource(Object source, ScriptContext scriptContext) throws ScriptException {
  try ( Interpreter bsh = getInterpreter() ) {
    NameSpace contextNameSpace = getEngineNameSpace(scriptContext);
    bsh.setNameSpace(contextNameSpace);
    bsh.setOut(toPrintStream(scriptContext.getWriter()));
    bsh.setErr(toPrintStream(scriptContext.getErrorWriter()));
    if (source instanceof Reader) {
      return bsh.eval((Reader) source);
    } else {
      return bsh.eval((String) source);
    }
  } catch (ParseException e) {
    // explicit parsing error
    throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber());
  } catch (TargetError e) {
    // The script threw an application level exception
    ScriptException se = new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber());
    se.initCause(e.getTarget());
    throw se;
  } catch (EvalError e) {
    // The script couldn't be evaluated properly
    throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber());
  } catch (IOException e) {
    throw new ScriptException(e.toString());
  }
}

代码示例来源:origin: jitlogic/zorka

private Object evalSource(Object source, ScriptContext scriptContext) throws ScriptException {
  bsh.NameSpace contextNameSpace = getEngineNameSpace(scriptContext);
  Interpreter bsh = getInterpreter();
  bsh.setNameSpace(contextNameSpace);
  bsh.setOut(toPrintStream(scriptContext.getWriter()));
  bsh.setErr(toPrintStream(scriptContext.getErrorWriter()));
  try {
    if (source instanceof Reader) {
      return bsh.eval((Reader) source);
    } else {
      return bsh.eval((String) source);
    }
  //} catch (ParseException e) {
    // explicit parsing error  TODO how to handle parse exception ?
    //throw new ScriptException(e.toString());
        //e.getErrorSourceFile(), e.getErrorLineNumber());
  } catch (TargetError e) {
    // The script threw an application level exception
    // set it as the cause ?
    ScriptException se = new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber());
    se.initCause(e.getTarget());
    throw se;
  } catch (EvalError e) {
    // The script couldn't be evaluated properly
    throw new ScriptException(e.toString(), e.getErrorSourceFile(), e.getErrorLineNumber());
  } catch (InterpreterError e) {
    // The interpreter had a fatal problem
    throw new ScriptException(e.toString());
  }
}

相关文章