KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > io > CPStorageFactory


1 /*
2
3    Derby - Class org.apache.derby.impl.io.CPStorageFactory
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.io;
23
24 import org.apache.derby.iapi.services.sanity.SanityManager;
25
26 import org.apache.derby.io.StorageFactory;
27 import org.apache.derby.io.StorageFile;
28
29 import java.io.FileNotFoundException JavaDoc;
30 import java.io.InputStream JavaDoc;
31 import java.io.OutputStream JavaDoc;
32 import java.io.IOException JavaDoc;
33
34 import java.util.Properties JavaDoc;
35
36 /**
37  * This class provides a class path based implementation of the StorageFactory interface. It is used by the
38  * database engine to access persistent data and transaction logs under the classpath subsubprotocol.
39  */

40
41 public class CPStorageFactory extends BaseStorageFactory
42 {
43     /**
44      * Construct a persistent StorageFile from a path name.
45      *
46      * @param path The path name of the file
47      *
48      * @return A corresponding StorageFile object
49      */

50     StorageFile newPersistentFile( String JavaDoc path)
51     {
52         return new CPFile( this, path);
53     }
54
55     /**
56      * Construct a StorageFile from a directory and file name.
57      *
58      * @param directoryName The directory part of the path name. Must not be null, nor may it be in the temp dir.
59      * @param fileName The name of the file within the directory.
60      *
61      * @return A corresponding StorageFile object
62      */

63     StorageFile newPersistentFile( String JavaDoc directoryName, String JavaDoc fileName)
64     {
65         if( directoryName == null || directoryName.length() == 0)
66             return newPersistentFile( fileName);
67         return new CPFile( this, directoryName, fileName);
68     }
69
70     /**
71      * Construct a StorageFile from a directory and file name.
72      *
73      * @param directoryName The directory part of the path name.
74      * @param fileName The name of the file within the directory.
75      *
76      * @return A corresponding StorageFile object
77      */

78     StorageFile newPersistentFile( StorageFile directoryName, String JavaDoc fileName)
79     {
80         if( directoryName == null)
81             return newPersistentFile( fileName);
82         return new CPFile( (CPFile) directoryName, fileName);
83     }
84
85     void doInit() throws IOException JavaDoc
86     {
87         if( dataDirectory != null)
88         {
89             separatedDataDirectory = dataDirectory + '/'; // Class paths use '/' as a separator
90
canonicalName = dataDirectory;
91             createTempDir();
92         }
93     } // end of doInit
94
}
95
Popular Tags