01: package com.opensymphony.webwork.sitegraph.model;
02:
03: import java.io.IOException;
04: import java.io.Writer;
05:
06: /**
07: * User: plightbo
08: * Date: Jun 26, 2005
09: * Time: 5:02:14 PM
10: */
11: public class IndentWriter extends Writer {
12: Writer writer;
13:
14: public IndentWriter(Writer writer) {
15: this .writer = writer;
16: }
17:
18: public void close() throws IOException {
19: writer.close();
20: }
21:
22: public void flush() throws IOException {
23: writer.flush();
24: }
25:
26: public void write(String str) throws IOException {
27: write(str, false);
28: }
29:
30: public void write(String str, boolean noIndent) throws IOException {
31: if (!noIndent) {
32: str = " " + str;
33: }
34:
35: if (writer instanceof IndentWriter) {
36: ((IndentWriter) writer).write(str, false);
37: } else {
38: writer.write(str + "\n");
39: }
40: }
41:
42: public void write(char cbuf[], int off, int len) throws IOException {
43: writer.write(cbuf, off, len);
44: }
45: }
|