1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
package org.apache.tiles.request.jsp; |
22 | |
|
23 | |
import java.io.IOException; |
24 | |
import java.io.PrintWriter; |
25 | |
|
26 | |
import javax.servlet.jsp.JspWriter; |
27 | |
|
28 | |
import org.slf4j.Logger; |
29 | |
import org.slf4j.LoggerFactory; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class JspPrintWriterAdapter extends PrintWriter { |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
private JspWriter writer; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | 60 | private final Logger log = LoggerFactory.getLogger(this.getClass()); |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
public JspPrintWriterAdapter(JspWriter writer) { |
54 | 60 | super(writer); |
55 | 60 | this.writer = writer; |
56 | 60 | } |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
public JspWriter getJspWriter() { |
64 | 2 | return writer; |
65 | |
} |
66 | |
|
67 | |
|
68 | |
@Override |
69 | |
public PrintWriter append(char c) { |
70 | |
try { |
71 | 2 | writer.append(c); |
72 | 1 | } catch (IOException e) { |
73 | 1 | log.error("Error when writing in JspWriter", e); |
74 | 1 | setError(); |
75 | 1 | } |
76 | 2 | return this; |
77 | |
} |
78 | |
|
79 | |
|
80 | |
@Override |
81 | |
public PrintWriter append(CharSequence csq, int start, int end) { |
82 | |
try { |
83 | 2 | writer.append(csq, start, end); |
84 | 1 | } catch (IOException e) { |
85 | 1 | log.error("Error when writing in JspWriter", e); |
86 | 1 | setError(); |
87 | 1 | } |
88 | 2 | return this; |
89 | |
} |
90 | |
|
91 | |
|
92 | |
@Override |
93 | |
public PrintWriter append(CharSequence csq) { |
94 | |
try { |
95 | 2 | writer.append(csq); |
96 | 1 | } catch (IOException e) { |
97 | 1 | log.error("Error when writing in JspWriter", e); |
98 | 1 | setError(); |
99 | 1 | } |
100 | 2 | return this; |
101 | |
} |
102 | |
|
103 | |
|
104 | |
@Override |
105 | |
public void close() { |
106 | |
try { |
107 | 2 | writer.close(); |
108 | 1 | } catch (IOException e) { |
109 | 1 | log.error("Error when writing in JspWriter", e); |
110 | 1 | setError(); |
111 | 1 | } |
112 | 2 | } |
113 | |
|
114 | |
|
115 | |
@Override |
116 | |
public void flush() { |
117 | |
try { |
118 | 31 | writer.flush(); |
119 | 1 | } catch (IOException e) { |
120 | 1 | log.error("Error when writing in JspWriter", e); |
121 | 1 | setError(); |
122 | 30 | } |
123 | 31 | } |
124 | |
|
125 | |
|
126 | |
@Override |
127 | |
public void print(boolean b) { |
128 | |
try { |
129 | 2 | writer.print(b); |
130 | 1 | } catch (IOException e) { |
131 | 1 | log.error("Error when writing in JspWriter", e); |
132 | 1 | setError(); |
133 | 1 | } |
134 | 2 | } |
135 | |
|
136 | |
|
137 | |
@Override |
138 | |
public void print(char c) { |
139 | |
try { |
140 | 2 | writer.print(c); |
141 | 1 | } catch (IOException e) { |
142 | 1 | log.error("Error when writing in JspWriter", e); |
143 | 1 | setError(); |
144 | 1 | } |
145 | 2 | } |
146 | |
|
147 | |
|
148 | |
@Override |
149 | |
public void print(char[] s) { |
150 | |
try { |
151 | 2 | writer.print(s); |
152 | 1 | } catch (IOException e) { |
153 | 1 | log.error("Error when writing in JspWriter", e); |
154 | 1 | setError(); |
155 | 1 | } |
156 | 2 | } |
157 | |
|
158 | |
|
159 | |
@Override |
160 | |
public void print(double d) { |
161 | |
try { |
162 | 2 | writer.print(d); |
163 | 1 | } catch (IOException e) { |
164 | 1 | log.error("Error when writing in JspWriter", e); |
165 | 1 | setError(); |
166 | 1 | } |
167 | 2 | } |
168 | |
|
169 | |
|
170 | |
@Override |
171 | |
public void print(float f) { |
172 | |
try { |
173 | 2 | writer.print(f); |
174 | 1 | } catch (IOException e) { |
175 | 1 | log.error("Error when writing in JspWriter", e); |
176 | 1 | setError(); |
177 | 1 | } |
178 | 2 | } |
179 | |
|
180 | |
|
181 | |
@Override |
182 | |
public void print(int i) { |
183 | |
try { |
184 | 2 | writer.print(i); |
185 | 1 | } catch (IOException e) { |
186 | 1 | log.error("Error when writing in JspWriter", e); |
187 | 1 | setError(); |
188 | 1 | } |
189 | 2 | } |
190 | |
|
191 | |
|
192 | |
@Override |
193 | |
public void print(long l) { |
194 | |
try { |
195 | 2 | writer.print(l); |
196 | 1 | } catch (IOException e) { |
197 | 1 | log.error("Error when writing in JspWriter", e); |
198 | 1 | setError(); |
199 | 1 | } |
200 | 2 | } |
201 | |
|
202 | |
|
203 | |
@Override |
204 | |
public void print(Object obj) { |
205 | |
try { |
206 | 2 | writer.print(obj); |
207 | 1 | } catch (IOException e) { |
208 | 1 | log.error("Error when writing in JspWriter", e); |
209 | 1 | setError(); |
210 | 1 | } |
211 | 2 | } |
212 | |
|
213 | |
|
214 | |
@Override |
215 | |
public void print(String s) { |
216 | |
try { |
217 | 2 | writer.print(s); |
218 | 1 | } catch (IOException e) { |
219 | 1 | log.error("Error when writing in JspWriter", e); |
220 | 1 | setError(); |
221 | 1 | } |
222 | 2 | } |
223 | |
|
224 | |
|
225 | |
@Override |
226 | |
public void println() { |
227 | |
try { |
228 | 2 | writer.println(); |
229 | 1 | } catch (IOException e) { |
230 | 1 | log.error("Error when writing in JspWriter", e); |
231 | 1 | setError(); |
232 | 1 | } |
233 | 2 | } |
234 | |
|
235 | |
|
236 | |
@Override |
237 | |
public void println(boolean x) { |
238 | |
try { |
239 | 2 | writer.println(x); |
240 | 1 | } catch (IOException e) { |
241 | 1 | log.error("Error when writing in JspWriter", e); |
242 | 1 | setError(); |
243 | 1 | } |
244 | 2 | } |
245 | |
|
246 | |
|
247 | |
@Override |
248 | |
public void println(char x) { |
249 | |
try { |
250 | 2 | writer.println(x); |
251 | 1 | } catch (IOException e) { |
252 | 1 | log.error("Error when writing in JspWriter", e); |
253 | 1 | setError(); |
254 | 1 | } |
255 | 2 | } |
256 | |
|
257 | |
|
258 | |
@Override |
259 | |
public void println(char[] x) { |
260 | |
try { |
261 | 2 | writer.println(x); |
262 | 1 | } catch (IOException e) { |
263 | 1 | log.error("Error when writing in JspWriter", e); |
264 | 1 | setError(); |
265 | 1 | } |
266 | 2 | } |
267 | |
|
268 | |
|
269 | |
@Override |
270 | |
public void println(double x) { |
271 | |
try { |
272 | 2 | writer.println(x); |
273 | 1 | } catch (IOException e) { |
274 | 1 | log.error("Error when writing in JspWriter", e); |
275 | 1 | setError(); |
276 | 1 | } |
277 | 2 | } |
278 | |
|
279 | |
|
280 | |
@Override |
281 | |
public void println(float x) { |
282 | |
try { |
283 | 2 | writer.println(x); |
284 | 1 | } catch (IOException e) { |
285 | 1 | log.error("Error when writing in JspWriter", e); |
286 | 1 | setError(); |
287 | 1 | } |
288 | 2 | } |
289 | |
|
290 | |
|
291 | |
@Override |
292 | |
public void println(int x) { |
293 | |
try { |
294 | 2 | writer.println(x); |
295 | 1 | } catch (IOException e) { |
296 | 1 | log.error("Error when writing in JspWriter", e); |
297 | 1 | setError(); |
298 | 1 | } |
299 | 2 | } |
300 | |
|
301 | |
|
302 | |
@Override |
303 | |
public void println(long x) { |
304 | |
try { |
305 | 2 | writer.println(x); |
306 | 1 | } catch (IOException e) { |
307 | 1 | log.error("Error when writing in JspWriter", e); |
308 | 1 | setError(); |
309 | 1 | } |
310 | 2 | } |
311 | |
|
312 | |
|
313 | |
@Override |
314 | |
public void println(Object x) { |
315 | |
try { |
316 | 2 | writer.println(x); |
317 | 1 | } catch (IOException e) { |
318 | 1 | log.error("Error when writing in JspWriter", e); |
319 | 1 | setError(); |
320 | 1 | } |
321 | 2 | } |
322 | |
|
323 | |
|
324 | |
@Override |
325 | |
public void println(String x) { |
326 | |
try { |
327 | 2 | writer.println(x); |
328 | 1 | } catch (IOException e) { |
329 | 1 | log.error("Error when writing in JspWriter", e); |
330 | 1 | setError(); |
331 | 1 | } |
332 | 2 | } |
333 | |
|
334 | |
|
335 | |
@Override |
336 | |
public void write(char[] buf, int off, int len) { |
337 | |
try { |
338 | 2 | writer.write(buf, off, len); |
339 | 1 | } catch (IOException e) { |
340 | 1 | log.error("Error when writing in JspWriter", e); |
341 | 1 | setError(); |
342 | 1 | } |
343 | 2 | } |
344 | |
|
345 | |
|
346 | |
@Override |
347 | |
public void write(char[] buf) { |
348 | |
try { |
349 | 2 | writer.write(buf); |
350 | 1 | } catch (IOException e) { |
351 | 1 | log.error("Error when writing in JspWriter", e); |
352 | 1 | setError(); |
353 | 1 | } |
354 | 2 | } |
355 | |
|
356 | |
|
357 | |
@Override |
358 | |
public void write(int c) { |
359 | |
try { |
360 | 2 | writer.write(c); |
361 | 1 | } catch (IOException e) { |
362 | 1 | log.error("Error when writing in JspWriter", e); |
363 | 1 | setError(); |
364 | 1 | } |
365 | 2 | } |
366 | |
|
367 | |
|
368 | |
@Override |
369 | |
public void write(String s, int off, int len) { |
370 | |
try { |
371 | 2 | writer.write(s, off, len); |
372 | 1 | } catch (IOException e) { |
373 | 1 | log.error("Error when writing in JspWriter", e); |
374 | 1 | setError(); |
375 | 1 | } |
376 | 2 | } |
377 | |
|
378 | |
|
379 | |
@Override |
380 | |
public void write(String s) { |
381 | |
try { |
382 | 2 | writer.write(s); |
383 | 1 | } catch (IOException e) { |
384 | 1 | log.error("Error when writing in JspWriter", e); |
385 | 1 | setError(); |
386 | 1 | } |
387 | 2 | } |
388 | |
} |