RandomAccessStorageModule implements IStorageModule { public static synchronized final IStorageModule open (final File file, final long storageLength, final boolean create, Class<? extends IStorageModule> kind) throws IOException { long sizeInBlocks; sizeInBlocks = storageLength / VIRTUAL_BLOCK_SIZE; if (create && !kind.equals(JCloudsStorageModule.class)) { createStorageVolume(file, storageLength); } @SuppressWarnings ("unchecked") Constructor<? extends IStorageModule> cons = (Constructor<? extends IStorageModule>) kind.getConstructors()[0]; try { IStorageModule mod = cons.newInstance(sizeInBlocks, file); return mod; } catch (InvocationTargetException | IllegalAccessException | InstantiationException exc) { throw new IOException(exc); } } RandomAccessStorageModule(final long sizeInBlocks, final File file); @Override void read(byte[] bytes, long storageIndex); @Override void write(byte[] bytes, long storageIndex); @Override final long getSizeInBlocks(); @Override final int checkBounds(final long logicalBlockAddress, final int transferLengthInBlocks); final void close(); @Override int getBlockSize(); static synchronized final IStorageModule open(final File file, final long storageLength, final boolean create, Class<? extends IStorageModule> kind); static boolean recursiveDelete(final File pFile);  }
@Test public void testOpen () { assertTrue(module != null); }