01: /*
02: * Created on Jun 17, 2005
03: */
04: package uk.org.ponder.streamutil.write;
05:
06: import uk.org.ponder.stringutil.CharWrap;
07: import uk.org.ponder.stringutil.StringList;
08:
09: /**
10: * @author Antranig Basman (antranig@caret.cam.ac.uk)
11: *
12: */
13: public class StringListPOS implements PrintOutputStream {
14: public StringList stringlist = null;
15: private CharWrap incompleteline = new CharWrap();
16:
17: public StringListPOS() {
18: stringlist = new StringList();
19: }
20:
21: public StringListPOS(StringList stringlist) {
22: this .stringlist = stringlist;
23: }
24:
25: public void println(String toprint) {
26: if (incompleteline.size() > 0) {
27: incompleteline.append(toprint);
28: stringlist.add(incompleteline.toString());
29: incompleteline.clear();
30: } else {
31: stringlist.add(toprint);
32: }
33: }
34:
35: public void flush() {
36: }
37:
38: public void close() {
39: }
40:
41: public PrintOutputStream print(String string) {
42: incompleteline.append(string);
43: return this ;
44: }
45:
46: public void println() {
47: println("");
48: }
49:
50: public void println(Object obj) {
51: println(obj.toString());
52: }
53:
54: public void write(char[] storage, int offset, int size) {
55: incompleteline.append(storage, offset, size);
56: }
57: }
|