1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.seasar.cubby.tags;
18
19 import java.io.IOException;
20 import java.io.PrintWriter;
21 import java.io.StringWriter;
22
23 import javax.servlet.jsp.JspWriter;
24
25 public class MockJspWriter extends JspWriter {
26
27 private StringWriter writer = new StringWriter();
28
29 private PrintWriter printWriter = new PrintWriter(writer);
30
31 public MockJspWriter() {
32 this(0, true);
33 }
34
35 protected MockJspWriter(int bufferSize, boolean autoFlush) {
36 super(bufferSize, autoFlush);
37 }
38
39 public String getResult() {
40 return writer.toString();
41 }
42
43 @Override
44 public void clear() throws IOException {
45 writer = new StringWriter();
46 printWriter = new PrintWriter(writer);
47 }
48
49 @Override
50 public void clearBuffer() throws IOException {
51 writer = new StringWriter();
52 printWriter = new PrintWriter(writer);
53 }
54
55 @Override
56 public void close() throws IOException {
57 writer.close();
58 }
59
60 @Override
61 public void flush() throws IOException {
62 writer.flush();
63 }
64
65 @Override
66 public int getRemaining() {
67 return 0;
68 }
69
70 @Override
71 public void newLine() throws IOException {
72 printWriter.println();
73 }
74
75 @Override
76 public void print(boolean b) throws IOException {
77 printWriter.print(b);
78 }
79
80 @Override
81 public void print(char c) throws IOException {
82 printWriter.print(c);
83 }
84
85 @Override
86 public void print(int i) throws IOException {
87 printWriter.print(i);
88 }
89
90 @Override
91 public void print(long l) throws IOException {
92 printWriter.print(l);
93 }
94
95 @Override
96 public void print(float f) throws IOException {
97 printWriter.print(f);
98 }
99
100 @Override
101 public void print(double d) throws IOException {
102 printWriter.print(d);
103 }
104
105 @Override
106 public void print(char[] s) throws IOException {
107 printWriter.print(s);
108 }
109
110 @Override
111 public void print(String s) throws IOException {
112 printWriter.print(s);
113 }
114
115 @Override
116 public void print(Object obj) throws IOException {
117 printWriter.print(obj);
118 }
119
120 @Override
121 public void println() throws IOException {
122 printWriter.println();
123 }
124
125 @Override
126 public void println(boolean x) throws IOException {
127 printWriter.println(x);
128 }
129
130 @Override
131 public void println(char x) throws IOException {
132 printWriter.println(x);
133 }
134
135 @Override
136 public void println(int x) throws IOException {
137 printWriter.println(x);
138 }
139
140 @Override
141 public void println(long x) throws IOException {
142 printWriter.println(x);
143 }
144
145 @Override
146 public void println(float x) throws IOException {
147 printWriter.println(x);
148 }
149
150 @Override
151 public void println(double x) throws IOException {
152 printWriter.println(x);
153 }
154
155 @Override
156 public void println(char[] x) throws IOException {
157 printWriter.println(x);
158 }
159
160 @Override
161 public void println(String x) throws IOException {
162 printWriter.println(x);
163 }
164
165 @Override
166 public void println(Object x) throws IOException {
167 printWriter.println(x);
168 }
169
170 @Override
171 public void write(char[] cbuf, int off, int len) throws IOException {
172 printWriter.write(cbuf, off, len);
173 }
174
175 @Override
176 public String toString() {
177 return writer.toString();
178 }
179 }