Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / io / DirRandomAccessFile4.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/io/DirRandomAccessFile4.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/io/DirRandomAccessFile4.java
new file mode 100644 (file)
index 0000000..11cdbe0
--- /dev/null
@@ -0,0 +1,83 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.io.DirRandomAccessFile4\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.io;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.io.SyncFailedException;\r
+import java.nio.channels.ClosedChannelException;\r
+\r
+/**\r
+ * This class provides a disk based implementation of the StIRandomAccess File interface. It is used by the\r
+ * database engine to access persistent data and transaction logs under the directory (default) subsubprotocol.\r
+ *\r
+ * This class extends DirRandomAccessFile to use the java.nio.channels.FileChannel.force() method to\r
+ * implement sync(). Java.nio.channels.FileChannel was introduced in Java 1.4; it was not available in Java 1.3.\r
+ */\r
+class DirRandomAccessFile4 extends DirRandomAccessFile\r
+{\r
+\r
+\r
+    /**\r
+     * Construct a StorageRandomAccessFileImpl.\r
+     *\r
+     * @param name The file name.\r
+     * @param mode The file open mode: "r", "rw", "rws", or "rwd". The  "rws" and "rwd" modes specify that the file is to\r
+     *             be synchronized, consistent with the java.io.RandomAccessFile class. However the\r
+     *             StorageRandomAccessFile.sync() method will be called even if the file was opened\r
+     *             in "rws" or "rwd" mode.  If the "rws" or "rwd" modes are supported then the implementation\r
+     *             of StorageRandomAccessFile.sync need not do anything.\r
+     *\r
+     * @exception IllegalArgumentException if the mode argument is not equal to one of "r", "rw".\r
+     * @exception FileNotFoundException if the file exists but is a directory rather than a regular\r
+     *              file, or cannot be opened or created for any other reason .\r
+     */\r
+    DirRandomAccessFile4( File name, String mode) throws FileNotFoundException\r
+    {\r
+        super( name, mode);\r
+    }\r
+\r
+    /**\r
+     * Force any changes out to the persistent store.\r
+     *\r
+     * @param metaData If true then this method is required to force changes to both the file's\r
+     *          content and metadata to be written to storage; otherwise, it need only force content changes\r
+     *          to be written.\r
+     *\r
+     * @exception IOException If an IO error occurs.\r
+     */\r
+    public void sync( boolean metaData) throws IOException\r
+    {\r
+        try\r
+        {\r
+            getChannel().force( metaData);\r
+        }\r
+        catch( ClosedChannelException cce) { throw cce;}\r
+        catch( IOException ioe)\r
+        {\r
+            SyncFailedException sne = new SyncFailedException( ioe.getMessage());\r
+            sne.initCause( ioe);\r
+            throw sne;\r
+        }\r
+    } // end of sync\r
+}\r