protected final Out out;
private StringBuffer log = loggingEnabled ? new StringBuffer(16 * 1024) : null;
private String newLine = "\r\n";
+ private Stream in_next = null;
- public static boolean loggingEnabled = System.getProperty("ibex.io.stream.logEnabled", "true") != null;
+ public Stream appendStream(Stream in_next) {
+ if (this.in_next != null) return this.in_next.appendStream(in_next);
+ this.in_next = in_next;
+ return this;
+ }
public Stream(InputStream in) { this.in = new Stream.In(in); this.out = null; }
public Stream( OutputStream out) { this.in = null; this.out = new Stream.Out(out); }
public void write(String s) { try { w.write(s); } catch (IOException e) { ioe(e); } }
}
- private static class In extends InputStream {
- public Reader reader = new InputStreamReader(this);
- private final InputStream orig;
+ private class In extends InputStream {
+ public final Reader reader = new InputStreamReader(this);
+ private /*final*/ InputStream orig;
public In(InputStream in) { orig = in; }
char[] cbuf = new char[8192];
if (cstart == cend) {
cstart = 0;
cend = reader.read(cbuf, 0, cbuf.length);
- if (cend == -1) { cend = cstart; throw new EOF(); }
+ if (cend == -1) {
+ cend = cstart;
+ if (in_next == null) throw new EOF();
+ // FIXME: sketchy
+ orig = in_next.in.orig;
+ in_next = in_next.in_next;
+ return getc(peek);
+ }
}
return peek ? cbuf[cstart] : cbuf[cstart++];
} catch (IOException e) { return (char)ioe(e); } }