From f997a53abaaaaa01ea1a7ae45ac576e41b5d886b Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Mon, 14 Dec 2009 02:36:27 +0100 Subject: [PATCH] Separated the bsvc console for clarity. --- samples/bsh/src/dolda/bsvc/Console.java | 48 +++++++++++++++++++++++++++++++ samples/bsh/src/dolda/bsvc/ShellPage.java | 45 ----------------------------- 2 files changed, 48 insertions(+), 45 deletions(-) create mode 100644 samples/bsh/src/dolda/bsvc/Console.java diff --git a/samples/bsh/src/dolda/bsvc/Console.java b/samples/bsh/src/dolda/bsvc/Console.java new file mode 100644 index 0000000..fc25bdd --- /dev/null +++ b/samples/bsh/src/dolda/bsvc/Console.java @@ -0,0 +1,48 @@ +package dolda.bsvc; + +import java.io.*; + +public class Console implements bsh.ConsoleInterface { + ByteArrayOutputStream obuf = new ByteArrayOutputStream(); + ByteArrayOutputStream ebuf = new ByteArrayOutputStream(); + Reader in = new StringReader(""); + PrintStream out; + PrintStream err; + { + try { + out = new PrintStream(obuf, false, "UTF-8"); + err = new PrintStream(ebuf, false, "UTF-8"); + } catch(UnsupportedEncodingException e) { + throw(new Error(e)); + } + } + + public void error(Object msg) { + getErr().println(msg); + } + + public void print(Object o) { + getOut().print(o); + } + + public void println(Object o) { + getOut().println(o); + } + + public PrintStream getOut() { + return(out); + } + + public PrintStream getErr() { + return(err); + } + + public Reader getIn() { + return(in); + } + + public void reset() { + obuf.reset(); + ebuf.reset(); + } +} diff --git a/samples/bsh/src/dolda/bsvc/ShellPage.java b/samples/bsh/src/dolda/bsvc/ShellPage.java index 13be814..aa9f2c8 100644 --- a/samples/bsh/src/dolda/bsvc/ShellPage.java +++ b/samples/bsh/src/dolda/bsvc/ShellPage.java @@ -11,51 +11,6 @@ public class ShellPage implements Responder { private Console cons = new Console(); private Interpreter ip = new Interpreter(cons); - private static class Console implements bsh.ConsoleInterface { - ByteArrayOutputStream obuf = new ByteArrayOutputStream(); - ByteArrayOutputStream ebuf = new ByteArrayOutputStream(); - Reader in = new StringReader(""); - PrintStream out; - PrintStream err; - { - try { - out = new PrintStream(obuf, false, "UTF-8"); - err = new PrintStream(ebuf, false, "UTF-8"); - } catch(UnsupportedEncodingException e) { - throw(new Error(e)); - } - } - - public void error(Object msg) { - getErr().println(msg); - } - - public void print(Object o) { - getOut().print(o); - } - - public void println(Object o) { - getOut().println(o); - } - - public PrintStream getOut() { - return(out); - } - - public PrintStream getErr() { - return(err); - } - - public Reader getIn() { - return(in); - } - - public void reset() { - obuf.reset(); - ebuf.reset(); - } - } - public void respond(Request req) { MultiMap params = req.params(); String cmd = params.get("cmd"); -- 2.11.0