Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / impl / io / CPStorageFactory.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/io/CPStorageFactory.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/io/CPStorageFactory.java
new file mode 100644 (file)
index 0000000..591b9d1
--- /dev/null
@@ -0,0 +1,94 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.io.CPStorageFactory\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 org.apache.derby.iapi.services.sanity.SanityManager;\r
+\r
+import org.apache.derby.io.StorageFactory;\r
+import org.apache.derby.io.StorageFile;\r
+\r
+import java.io.FileNotFoundException;\r
+import java.io.InputStream;\r
+import java.io.OutputStream;\r
+import java.io.IOException;\r
+\r
+import java.util.Properties;\r
+\r
+/**\r
+ * This class provides a class path based implementation of the StorageFactory interface. It is used by the\r
+ * database engine to access persistent data and transaction logs under the classpath subsubprotocol.\r
+ */\r
+\r
+public class CPStorageFactory extends BaseStorageFactory\r
+{   \r
+    /**\r
+     * Construct a persistent StorageFile from a path name.\r
+     *\r
+     * @param path The path name of the file\r
+     *\r
+     * @return A corresponding StorageFile object\r
+     */\r
+    StorageFile newPersistentFile( String path)\r
+    {\r
+        return new CPFile( this, path);\r
+    }\r
+\r
+    /**\r
+     * Construct a StorageFile from a directory and file name.\r
+     *\r
+     * @param directoryName The directory part of the path name. Must not be null, nor may it be in the temp dir.\r
+     * @param fileName The name of the file within the directory.\r
+     *\r
+     * @return A corresponding StorageFile object\r
+     */\r
+    StorageFile newPersistentFile( String directoryName, String fileName)\r
+    {\r
+        if( directoryName == null || directoryName.length() == 0)\r
+            return newPersistentFile( fileName);\r
+        return new CPFile( this, directoryName, fileName);\r
+    }\r
+\r
+    /**\r
+     * Construct a StorageFile from a directory and file name.\r
+     *\r
+     * @param directoryName The directory part of the path name.\r
+     * @param fileName The name of the file within the directory.\r
+     *\r
+     * @return A corresponding StorageFile object\r
+     */\r
+    StorageFile newPersistentFile( StorageFile directoryName, String fileName)\r
+    {\r
+        if( directoryName == null)\r
+            return newPersistentFile( fileName);\r
+        return new CPFile( (CPFile) directoryName, fileName);\r
+    }\r
+\r
+    void doInit() throws IOException\r
+    {\r
+        if( dataDirectory != null)\r
+        {\r
+            separatedDataDirectory = dataDirectory + '/'; // Class paths use '/' as a separator\r
+            canonicalName = dataDirectory;\r
+            createTempDir();\r
+        }\r
+    } // end of doInit\r
+}\r