1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.sitegraph.model;
23
24 import java.io.IOException;
25 import java.io.Writer;
26
27 /***
28 */
29 public class IndentWriter extends Writer {
30 Writer writer;
31
32 public IndentWriter(Writer writer) {
33 this.writer = writer;
34 }
35
36 public void close() throws IOException {
37 writer.close();
38 }
39
40 public void flush() throws IOException {
41 writer.flush();
42 }
43
44 public void write(String str) throws IOException {
45 write(str, false);
46 }
47
48 public void write(String str, boolean noIndent) throws IOException {
49 if (!noIndent) {
50 str = " " + str;
51 }
52
53 if (writer instanceof IndentWriter) {
54 ((IndentWriter) writer).write(str, false);
55 } else {
56 writer.write(str + "\n");
57 }
58 }
59
60 public void write(char cbuf[], int off, int len) throws IOException {
61 writer.write(cbuf, off, len);
62 }
63 }