1 29 30 package com.caucho.vfs; 31 32 import com.caucho.util.NullIterator; 33 34 import java.io.IOException ; 35 import java.util.Iterator ; 36 37 41 public class StreamImpl { 42 protected static NullPath _nullPath; 43 44 private static final byte _newline[] = new byte[] {(byte) '\n'}; 45 46 protected Path _path; 47 48 51 public byte []getNewline() 52 { 53 return _newline; 54 } 55 56 59 public boolean hasSkip() 60 { 61 return false; 62 } 63 64 71 public long skip(long n) 72 throws IOException 73 { 74 return 0; 75 } 76 77 80 public boolean canRead() 81 { 82 return false; 83 } 84 85 88 public byte []getReadBuffer() 89 { 90 return null; 91 } 92 93 102 public int read(byte []buffer, int offset, int length) throws IOException 103 { 104 throw new UnsupportedOperationException (String.valueOf(this)); 105 } 106 107 116 public int readNonBlock(byte []buffer, int offset, int length) 117 throws IOException 118 { 119 return 0; 120 } 121 122 131 public int readTimeout(byte []buffer, int offset, int length, 132 long timeout) 133 throws IOException 134 { 135 return 0; 136 } 137 138 143 public int getAvailable() throws IOException 144 { 145 throw new UnsupportedOperationException (String.valueOf(this)); 146 } 147 148 151 public long getReadPosition() 152 { 153 return -1; 154 } 155 156 159 public boolean canWrite() 160 { 161 return false; 162 } 163 164 168 public boolean getFlushOnNewline() 169 { 170 return false; 171 } 172 173 176 public void setWriteEncoding(String encoding) 177 { 178 } 179 180 188 public void write(byte []buffer, int offset, int length, boolean isEnd) 189 throws IOException 190 { 191 throw new UnsupportedOperationException (String.valueOf(this)); 192 } 193 194 205 public boolean write(byte []buf1, int off1, int len1, 206 byte []buf2, int off2, int len2, 207 boolean isEnd) 208 throws IOException 209 { 210 if (len1 == 0) { 211 write(buf2, off2, len2, isEnd); 212 213 return true; 214 } 215 else 216 return false; 217 } 218 219 222 public void clearWrite() 223 { 224 } 225 226 229 public void seekStart(long offset) 230 throws IOException 231 { 232 throw new UnsupportedOperationException (getClass().getName()); 233 } 234 235 238 public void seekEnd(long offset) 239 throws IOException 240 { 241 throw new UnsupportedOperationException (getClass().getName()); 242 } 243 244 247 public void flushBuffer() throws IOException 248 { 249 } 250 251 254 public void flush() throws IOException 255 { 256 } 257 258 261 public void flushToDisk() throws IOException 262 { 263 throw new UnsupportedOperationException (); 264 } 265 266 269 public Path getPath() 270 { 271 if (_path != null) 272 return _path; 273 274 if (_nullPath == null) 275 _nullPath = new NullPath("stream"); 276 277 return _nullPath; 278 } 279 280 283 public void setPath(Path path) 284 { 285 _path = path; 286 } 287 288 295 public Object getAttribute(String name) 296 throws IOException 297 { 298 return null; 299 } 300 301 307 public void setAttribute(String name, Object value) 308 throws IOException 309 { 310 } 311 312 317 public void removeAttribute(String name) 318 throws IOException 319 { 320 } 321 322 325 public Iterator getAttributeNames() 326 throws IOException 327 { 328 return NullIterator.create(); 329 } 330 331 334 public void closeWrite() throws IOException 335 { 336 close(); 337 } 338 339 342 public void close() throws IOException 343 { 344 } 345 } 346 | Popular Tags |