1 21 package org.apache.derbyTesting.functionTests.util.corruptio; 22 import org.apache.derby.io.WritableStorageFactory; 23 import org.apache.derby.io.StorageFile; 24 25 import java.io.File ; 26 import java.io.IOException ; 27 import java.io.OutputStream ; 28 import java.io.IOException ; 29 import java.io.SyncFailedException ; 30 31 45 46 abstract class CorruptBaseStorageFactory implements WritableStorageFactory 47 { 48 49 protected WritableStorageFactory realStorageFactory; 50 51 54 CorruptBaseStorageFactory() 55 {} 56 57 89 public void init( String home, String databaseName, String tempDirName, String uniqueName) 90 throws IOException 91 { 92 realStorageFactory = getRealStorageFactory(); 93 realStorageFactory.init(home, databaseName, tempDirName, uniqueName); 94 } 96 97 public void shutdown() 98 { 99 realStorageFactory.shutdown(); 100 } 101 102 103 117 public String getCanonicalName() throws IOException 118 { 119 return realStorageFactory.getCanonicalName(); 120 } 121 122 129 public StorageFile newStorageFile( String path) 130 { 131 return new CorruptFile(realStorageFactory.newStorageFile(path)); 132 } 133 134 142 public StorageFile newStorageFile( String directoryName, String fileName) 143 { 144 return new CorruptFile(realStorageFactory.newStorageFile(directoryName, fileName)); 145 } 146 147 155 public StorageFile newStorageFile( StorageFile directoryName, String fileName) 156 { 157 StorageFile realDirFile = ((CorruptFile) directoryName).getRealFileInstance(); 158 return new CorruptFile(realStorageFactory.newStorageFile(realDirFile, fileName)); 159 } 160 161 167 public char getSeparator() 168 { 169 return realStorageFactory.getSeparator(); 170 } 171 172 177 public StorageFile getTempDir() 178 { 179 return new CorruptFile(realStorageFactory.getTempDir()); 180 } 181 182 191 public boolean isFast() 192 { 193 return realStorageFactory.isFast(); 194 } 195 196 public boolean isReadOnlyDatabase() 197 { 198 return realStorageFactory.isReadOnlyDatabase(); 199 } 200 201 208 public boolean supportsRandomAccess() 209 { 210 return realStorageFactory.supportsRandomAccess(); 211 } 212 213 public int getStorageFactoryVersion() 214 { 215 return realStorageFactory.getStorageFactoryVersion(); 216 } 217 218 219 220 239 public void sync( OutputStream stream, boolean metaData) throws IOException , SyncFailedException 240 { 241 realStorageFactory.sync(stream, metaData); 242 } 243 244 254 public boolean supportsRws() 255 { 256 return realStorageFactory.supportsRws(); 257 } 258 259 260 264 abstract WritableStorageFactory getRealStorageFactory(); 265 266 } 267 | Popular Tags |