1 29 30 package com.caucho.jsp; 31 32 import com.caucho.log.Log; 33 import com.caucho.vfs.FlushBuffer; 34 35 import javax.servlet.jsp.JspWriter ; 36 import java.io.IOException ; 37 import java.io.PrintWriter ; 38 import java.io.StringWriter ; 39 import java.io.Writer ; 40 import java.util.logging.Level ; 41 import java.util.logging.Logger ; 42 43 46 public class JspPrintWriter extends PrintWriter implements FlushBuffer { 47 private static final Logger log = Log.open(JspPrintWriter.class); 48 49 private static final Writer _dummyWriter = new StringWriter (); 50 51 private JspWriter _jspWriter; 52 53 56 JspPrintWriter() 57 { 58 super(_dummyWriter); 59 } 60 61 64 JspPrintWriter(JspWriter jspWriter) 65 { 66 super(jspWriter); 67 68 _jspWriter = jspWriter; 69 } 70 71 76 void init(JspWriter jspWriter) 77 { 78 _jspWriter = jspWriter; 79 } 80 81 88 final public void write(char []buf, int offset, int length) 89 { 90 try { 91 _jspWriter.write(buf, offset, length); 92 } catch (IOException e) { 93 log.log(Level.FINE, e.toString(), e); 94 } 95 } 96 97 102 final public void write(int ch) 103 { 104 try { 105 _jspWriter.write(ch); 106 } catch (IOException e) { 107 log.log(Level.FINE, e.toString(), e); 108 } 109 } 110 111 116 final public void write(char []buf) 117 { 118 try { 119 _jspWriter.write(buf, 0, buf.length); 120 } catch (IOException e) { 121 log.log(Level.FINE, e.toString(), e); 122 } 123 } 124 125 128 final public void write(String s) 129 { 130 try { 131 _jspWriter.write(s, 0, s.length()); 132 } catch (IOException e) { 133 log.log(Level.FINE, e.toString(), e); 134 } 135 } 136 137 140 final public void write(String s, int off, int len) 141 { 142 try { 143 _jspWriter.write(s, 0, s.length()); 144 } catch (IOException e) { 145 log.log(Level.FINE, e.toString(), e); 146 } 147 } 148 149 152 final public void newLine() 153 { 154 try { 155 _jspWriter.newLine(); 156 } catch (IOException e) { 157 log.log(Level.FINE, e.toString(), e); 158 } 159 } 160 161 164 final public void print(boolean b) 165 { 166 try { 167 _jspWriter.print(b); 168 } catch (IOException e) { 169 log.log(Level.FINE, e.toString(), e); 170 } 171 } 172 173 176 final public void print(char ch) 177 { 178 try { 179 _jspWriter.write(ch); 180 } catch (IOException e) { 181 log.log(Level.FINE, e.toString(), e); 182 } 183 } 184 185 188 final public void print(int v) 189 { 190 try { 191 _jspWriter.print(v); 192 } catch (IOException e) { 193 log.log(Level.FINE, e.toString(), e); 194 } 195 } 196 197 200 final public void print(long v) 201 { 202 try { 203 _jspWriter.print(v); 204 } catch (IOException e) { 205 log.log(Level.FINE, e.toString(), e); 206 } 207 } 208 209 212 final public void print(float f) 213 { 214 try { 215 _jspWriter.print(f); 216 } catch (IOException e) { 217 log.log(Level.FINE, e.toString(), e); 218 } 219 } 220 221 224 final public void print(double d) 225 { 226 try { 227 _jspWriter.print(d); 228 } catch (IOException e) { 229 log.log(Level.FINE, e.toString(), e); 230 } 231 } 232 233 236 final public void print(char []s) 237 { 238 try { 239 _jspWriter.write(s, 0, s.length); 240 } catch (IOException e) { 241 log.log(Level.FINE, e.toString(), e); 242 } 243 } 244 245 248 final public void print(String s) 249 { 250 try { 251 _jspWriter.print(s); 252 } catch (IOException e) { 253 log.log(Level.FINE, e.toString(), e); 254 } 255 } 256 257 260 final public void print(Object v) 261 { 262 try { 263 _jspWriter.print(v); 264 } catch (IOException e) { 265 log.log(Level.FINE, e.toString(), e); 266 } 267 } 268 269 272 final public void println() 273 { 274 try { 275 _jspWriter.newLine(); 276 } catch (IOException e) { 277 log.log(Level.FINE, e.toString(), e); 278 } 279 } 280 281 286 final public void println(boolean v) 287 { 288 try { 289 _jspWriter.println(v); 290 } catch (IOException e) { 291 log.log(Level.FINE, e.toString(), e); 292 } 293 } 294 295 300 final public void println(char v) 301 { 302 try { 303 _jspWriter.println(v); 304 } catch (IOException e) { 305 log.log(Level.FINE, e.toString(), e); 306 } 307 } 308 309 314 final public void println(int v) 315 { 316 try { 317 _jspWriter.println(v); 318 } catch (IOException e) { 319 log.log(Level.FINE, e.toString(), e); 320 } 321 } 322 323 328 final public void println(long v) 329 { 330 try { 331 _jspWriter.println(v); 332 } catch (IOException e) { 333 log.log(Level.FINE, e.toString(), e); 334 } 335 } 336 337 342 final public void println(float v) 343 { 344 try { 345 _jspWriter.println(v); 346 } catch (IOException e) { 347 log.log(Level.FINE, e.toString(), e); 348 } 349 } 350 351 352 357 final public void println(double v) 358 { 359 try { 360 _jspWriter.println(v); 361 } catch (IOException e) { 362 log.log(Level.FINE, e.toString(), e); 363 } 364 } 365 366 369 final public void println(char []s) 370 { 371 try { 372 _jspWriter.println(s); 373 } catch (IOException e) { 374 log.log(Level.FINE, e.toString(), e); 375 } 376 } 377 378 381 final public void println(String s) 382 { 383 try { 384 _jspWriter.println(s); 385 } catch (IOException e) { 386 log.log(Level.FINE, e.toString(), e); 387 } 388 } 389 390 393 final public void println(Object v) 394 { 395 try { 396 _jspWriter.println(v); 397 } catch (IOException e) { 398 log.log(Level.FINE, e.toString(), e); 399 } 400 } 401 402 405 public void flushBuffer() 406 { 407 try { 408 if (_jspWriter instanceof FlushBuffer) 409 ((FlushBuffer) _jspWriter).flushBuffer(); 410 else 411 _jspWriter.flush(); 412 } catch (IOException e) { 413 log.log(Level.FINE, e.toString(), e); 414 } 415 } 416 417 420 public void flush() 421 { 422 try { 423 _jspWriter.flush(); 424 } catch (IOException e) { 425 log.log(Level.FINE, e.toString(), e); 426 } 427 } 428 429 final public void clear() 430 { 431 try { 432 _jspWriter.clear(); 433 } catch (IOException e) { 434 log.log(Level.FINE, e.toString(), e); 435 } 436 } 437 438 final public void close() 439 { 440 try { 441 _jspWriter.close(); 442 } catch (IOException e) { 443 log.log(Level.FINE, e.toString(), e); 444 } 445 } 446 } 447 | Popular Tags |