KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > webFlow > model > IndentWriter


1 package com.opensymphony.webwork.webFlow.model;
2
3 import java.io.IOException JavaDoc;
4 import java.io.Writer JavaDoc;
5
6 /**
7  * User: plightbo
8  * Date: Jun 26, 2005
9  * Time: 5:02:14 PM
10  */

11 public class IndentWriter extends Writer JavaDoc {
12     Writer JavaDoc writer;
13
14     public IndentWriter(Writer JavaDoc writer) {
15         this.writer = writer;
16     }
17
18     public void close() throws IOException JavaDoc {
19         writer.close();
20     }
21
22     public void flush() throws IOException JavaDoc {
23         writer.flush();
24     }
25
26     public void write(String JavaDoc str) throws IOException JavaDoc {
27         write(str, false);
28     }
29
30     public void write(String JavaDoc str, boolean noIndent) throws IOException JavaDoc {
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 JavaDoc {
43         writer.write(cbuf, off, len);
44     }
45 }
46
Popular Tags