1 21 22 package org.apache.derbyTesting.functionTests.util.corruptio; 23 import org.apache.derby.io.StorageRandomAccessFile; 24 import java.io.IOException ; 25 import java.io.File ; 26 27 28 41 public class CorruptRandomAccessFile implements StorageRandomAccessFile 42 { 43 44 private StorageRandomAccessFile realRaf; 45 private CorruptibleIo cbio; 46 private File realFile; 47 48 54 CorruptRandomAccessFile(StorageRandomAccessFile raf, File realFile) 55 { 56 this.realRaf = raf; 57 cbio = CorruptibleIo.getInstance(); 58 this.realFile = realFile; 59 } 60 61 62 65 public void close() throws IOException 66 { 67 realRaf.close(); 68 } 69 70 73 public long getFilePointer() throws IOException 74 { 75 return realRaf.getFilePointer(); 76 } 77 78 81 public long length() throws IOException 82 { 83 return realRaf.length(); 84 } 85 86 89 public void seek(long newFilePointer) throws IOException 90 { 91 realRaf.seek(newFilePointer); 92 } 93 94 97 public void setLength(long newLength) throws IOException 98 { 99 realRaf.setLength(newLength); 100 } 101 102 105 public void sync( boolean metaData) throws IOException 106 { 107 realRaf.sync(metaData); 108 } 109 110 111 112 113 116 public void readFully(byte b[]) throws IOException 117 { 118 realRaf.readFully(b); 119 } 120 121 125 public void readFully(byte b[], int off, int len) throws IOException 126 { 127 realRaf.readFully(b , off, len); 128 } 129 130 133 public int skipBytes(int nBytes) throws IOException 134 { 135 return realRaf.skipBytes(nBytes); 136 } 137 138 142 public boolean readBoolean() throws IOException 143 { 144 return realRaf.readBoolean(); 145 } 146 147 150 public byte readByte() throws IOException 151 { 152 return realRaf.readByte(); 153 } 154 155 158 public int readUnsignedByte() throws IOException 159 { 160 return realRaf.readUnsignedByte(); 161 } 162 163 166 public short readShort() throws IOException 167 { 168 return realRaf.readShort(); 169 } 170 171 174 public int readUnsignedShort() throws IOException 175 { 176 return realRaf.readUnsignedShort(); 177 } 178 179 182 public char readChar() throws IOException 183 { 184 return realRaf.readChar(); 185 } 186 187 190 public int readInt() throws IOException 191 { 192 return realRaf.readInt(); 193 } 194 195 198 public long readLong() throws IOException 199 { 200 return realRaf.readLong(); 201 } 202 203 206 public float readFloat() throws IOException 207 { 208 return realRaf.readFloat(); 209 } 210 211 214 public double readDouble() throws IOException 215 { 216 return realRaf.readDouble(); 217 } 218 219 222 public String readLine() throws IOException 223 { 224 return realRaf.readLine(); 225 } 226 227 230 public String readUTF() throws IOException 231 { 232 return realRaf.readUTF(); 233 } 234 235 236 237 238 241 public void write(int b) throws IOException 242 { 243 realRaf.write(b); 244 } 245 246 249 public void write(byte b[]) throws IOException 250 { 251 realRaf.write(b); 252 } 253 254 259 public void write(byte b[], int off, int len) throws IOException 260 { 261 if (cbio.isCorruptibleFile(realFile)){ 262 cbio.corrupt(b , off, len); 264 } 265 realRaf.write(b, off, len); 266 } 267 268 271 public void writeBoolean(boolean value) throws IOException 272 { 273 realRaf.writeBoolean(value); 274 } 275 276 280 public void writeByte(int value) throws IOException 281 { 282 realRaf.writeByte(value); 283 } 284 285 288 public void writeShort(int value) throws IOException 289 { 290 realRaf.writeShort(value); 291 } 292 293 299 public void writeChar(int value) throws IOException 300 { 301 realRaf.writeChar(value); 302 } 303 304 307 public void writeInt(int value) throws IOException 308 { 309 realRaf.writeInt(value); 310 } 311 312 315 public void writeLong(long value) throws IOException 316 { 317 realRaf.writeLong(value); 318 } 319 320 323 public void writeFloat(float value) throws IOException 324 { 325 realRaf.writeFloat(value); 326 } 327 328 331 public void writeDouble(double value) throws IOException 332 { 333 realRaf.writeDouble(value); 334 } 335 336 339 public void writeBytes(String str) throws IOException 340 { 341 realRaf.writeBytes(str); 342 } 343 344 347 public void writeChars(String str) throws IOException 348 { 349 realRaf.writeChars(str); 350 } 351 352 355 public void writeUTF(String str) throws IOException 356 { 357 realRaf.writeUTF(str); 358 } 359 360 } 361 | Popular Tags |