1 28 29 package com.caucho.server.connection; 30 31 import com.caucho.log.Log; 32 import com.caucho.util.L10N; 33 import com.caucho.vfs.OutputStreamWithBuffer; 34 import com.caucho.vfs.Path; 35 36 import java.io.IOException ; 37 import java.io.OutputStream ; 38 import java.io.UnsupportedEncodingException ; 39 import java.io.Writer ; 40 import java.util.Locale ; 41 import java.util.logging.Logger ; 42 43 46 public abstract class AbstractResponseStream extends OutputStreamWithBuffer { 47 private static final Logger log = Log.open(AbstractResponseStream.class); 48 private static final L10N L = new L10N(AbstractResponseStream.class); 49 50 53 public void start() 54 { 55 } 56 57 60 abstract public boolean isCauchoResponseStream(); 61 62 65 public void setEncoding(String encoding) 66 throws UnsupportedEncodingException 67 { 68 } 69 70 73 public void setLocale(Locale locale) 74 throws UnsupportedEncodingException 75 { 76 } 77 78 81 abstract public void setBufferSize(int size); 82 83 86 abstract public int getBufferSize(); 87 88 91 public void setAutoFlush(boolean isAutoFlush) 92 { 93 } 94 95 98 public boolean isAutoFlush() 99 { 100 return true; 101 } 102 103 106 abstract public int getRemaining(); 107 108 111 abstract public char []getCharBuffer() 112 throws IOException ; 113 114 117 abstract public int getCharOffset() 118 throws IOException ; 119 120 123 abstract public void setCharOffset(int offset) 124 throws IOException ; 125 126 129 abstract public char []nextCharBuffer(int offset) 130 throws IOException ; 131 132 135 public boolean isCommitted() 136 { 137 return false; 138 } 139 140 143 public void setHead() 144 { 145 } 146 147 150 public boolean isHead() 151 { 152 return false; 153 } 154 155 158 public void setByteCacheStream(OutputStream cacheStream) 159 { 160 throw new UnsupportedOperationException (getClass().getName()); 161 } 162 163 166 public void setCharCacheStream(Writer cacheStream) 167 { 168 throw new UnsupportedOperationException (getClass().getName()); 169 } 170 171 174 public int getContentLength() 175 { 176 return 0; 177 } 178 179 182 abstract public void write(int v) 183 throws IOException ; 184 185 188 abstract public void write(byte []buffer, int offset, int length) 189 throws IOException ; 190 191 194 abstract public void print(int ch) 195 throws IOException ; 196 197 200 abstract public void print(char []buffer, int offset, int length) 201 throws IOException ; 202 203 206 public void clear() 207 throws IOException 208 { 209 clearBuffer(); 210 } 211 212 215 abstract public void clearBuffer(); 216 217 220 abstract public void flushBuffer() 221 throws IOException ; 222 223 226 public void flushByte() 227 throws IOException 228 { 229 flushBuffer(); 230 } 231 232 235 public void flushChar() 236 throws IOException 237 { 238 flushBuffer(); 239 } 240 241 247 public void sendFile(Path path, long length) 248 throws IOException 249 { 250 path.writeToStream(this); 251 } 252 253 256 public void flush() 257 throws IOException 258 { 259 flushByte(); 260 } 261 262 265 public void finish() 266 throws IOException 267 { 268 flushBuffer(); 269 } 270 271 274 public void close() 275 throws IOException 276 { 277 finish(); 278 } 279 280 283 public void clearClosed() 284 throws IOException 285 { 286 } 287 } 288 | Popular Tags |