本文整理了Java中bsh.Interpreter.setOut()
方法的一些代码示例,展示了Interpreter.setOut()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Interpreter.setOut()
方法的具体详情如下:
包路径:bsh.Interpreter
类名称:Interpreter
方法名:setOut
暂无
代码示例来源:origin: beanshell/beanshell
public void setOut(final PrintStream value) {
_interpreter.setOut(value);
}
代码示例来源:origin: jitlogic/zorka
public void setOut(final PrintStream value) {
_interpreter.setOut(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
System.setOut( scriptOutput );
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.setOut(null);
localInterpreter.setErr(null);
} catch (IOException ioe) {
代码示例来源: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());
}
}
内容来源于网络,如有侵权,请联系作者删除!