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