1 2 3 27 28 29 package org.apache.coyote.tomcat5; 30 31 import java.io.IOException ; 32 import java.io.PrintWriter ; 33 34 import javax.servlet.ServletOutputStream ; 35 36 41 public class CoyoteWriter 42 extends PrintWriter { 43 44 45 47 48 private static final char[] LINE_SEP = { '\r', '\n' }; 49 50 51 53 54 protected OutputBuffer ob; 55 protected boolean error = false; 56 57 58 60 61 public CoyoteWriter(OutputBuffer ob) { 62 super(ob); 63 this.ob = ob; 64 } 65 66 67 69 70 73 protected Object clone() 74 throws CloneNotSupportedException { 75 throw new CloneNotSupportedException (); 76 } 77 78 79 81 82 85 void clear() { 86 ob = null; 87 } 88 89 92 void recycle() { 93 error = false; 94 } 95 96 97 99 100 public void flush() { 101 102 if (error) 103 return; 104 105 try { 106 ob.flush(); 107 } catch (IOException e) { 108 error = true; 109 } 110 111 } 112 113 114 public void close() { 115 116 try { 119 ob.close(); 120 } catch (IOException ex ) { 121 ; 122 } 123 error = false; 124 125 } 126 127 128 public boolean checkError() { 129 flush(); 130 return error; 131 } 132 133 134 public void write(int c) { 135 136 if (error) 137 return; 138 139 try { 140 ob.write(c); 141 } catch (IOException e) { 142 error = true; 143 } 144 145 } 146 147 148 public void write(char buf[], int off, int len) { 149 150 if (error) 151 return; 152 153 try { 154 ob.write(buf, off, len); 155 } catch (IOException e) { 156 error = true; 157 } 158 159 } 160 161 162 public void write(char buf[]) { 163 write(buf, 0, buf.length); 164 } 165 166 167 public void write(String s, int off, int len) { 168 169 if (error) 170 return; 171 172 try { 173 ob.write(s, off, len); 174 } catch (IOException e) { 175 error = true; 176 } 177 178 } 179 180 181 public void write(String s) { 182 write(s, 0, s.length()); 183 } 184 185 186 188 189 public void print(boolean b) { 190 if (b) { 191 write("true"); 192 } else { 193 write("false"); 194 } 195 } 196 197 198 public void print(char c) { 199 write(c); 200 } 201 202 203 public void print(int i) { 204 write(String.valueOf(i)); 205 } 206 207 208 public void print(long l) { 209 write(String.valueOf(l)); 210 } 211 212 213 public void print(float f) { 214 write(String.valueOf(f)); 215 } 216 217 218 public void print(double d) { 219 write(String.valueOf(d)); 220 } 221 222 223 public void print(char s[]) { 224 write(s); 225 } 226 227 228 public void print(String s) { 229 if (s == null) { 230 s = "null"; 231 } 232 write(s); 233 } 234 235 236 public void print(Object obj) { 237 write(String.valueOf(obj)); 238 } 239 240 241 public void println() { 242 write(LINE_SEP); 243 } 244 245 246 public void println(boolean b) { 247 print(b); 248 println(); 249 } 250 251 252 public void println(char c) { 253 print(c); 254 println(); 255 } 256 257 258 public void println(int i) { 259 print(i); 260 println(); 261 } 262 263 264 public void println(long l) { 265 print(l); 266 println(); 267 } 268 269 270 public void println(float f) { 271 print(f); 272 println(); 273 } 274 275 276 public void println(double d) { 277 print(d); 278 println(); 279 } 280 281 282 public void println(char c[]) { 283 print(c); 284 println(); 285 } 286 287 288 public void println(String s) { 289 print(s); 290 println(); 291 } 292 293 294 public void println(Object o) { 295 print(o); 296 println(); 297 } 298 299 300 } 301 | Popular Tags |