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