KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.io.DirStorageFactory4
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.io.StorageFile;
25 import org.apache.derby.iapi.services.info.JVMInfo;
26
27 import java.io.IOException JavaDoc;
28
29 /**
30  * This class implements the WritableStorageFactory interface using features found in Java 1.4 but
31  * not in earlier versions of Java.
32  */

33 public class DirStorageFactory4 extends DirStorageFactory
34 {
35
36     private static final boolean rwsOK = JVMInfo.JDK_ID >= JVMInfo.J2SE_142;
37     
38     /**
39      * Most of the initialization is done in the init method.
40      */

41     public DirStorageFactory4()
42     {
43         super();
44     }
45
46     /**
47      * Construct a persistent StorageFile from a path name.
48      *
49      * @param path The path name of the file. Guaranteed not to be in the temporary file directory. If null
50      * then the database directory should be returned.
51      *
52      * @return A corresponding StorageFile object
53      */

54     StorageFile newPersistentFile( String JavaDoc path)
55     {
56         if( path == null)
57             return new DirFile4(dataDirectory, rwsOK);
58         return new DirFile4(dataDirectory, path, rwsOK);
59     }
60
61     /**
62      * Construct a persistent StorageFile from a directory and path name.
63      *
64      * @param directoryName The path name of the directory. Guaranteed not to be in the temporary file directory.
65      * Guaranteed not to be null
66      * @param fileName The name of the file within the directory. Guaranteed not to be null.
67      *
68      * @return A corresponding StorageFile object
69      */

70     StorageFile newPersistentFile( String JavaDoc directoryName, String JavaDoc fileName)
71     {
72         return new DirFile4( separatedDataDirectory + directoryName, fileName, rwsOK);
73     }
74
75     /**
76      * Construct a persistent StorageFile from a directory and path name.
77      *
78      * @param directoryName The path name of the directory. Guaranteed not to be to be null. Guaranteed to be
79      * created by a call to one of the newPersistentFile methods.
80      * @param fileName The name of the file within the directory. Guaranteed not to be null.
81      *
82      * @return A corresponding StorageFile object
83      */

84     StorageFile newPersistentFile( StorageFile directoryName, String JavaDoc fileName)
85     {
86         return new DirFile4( (DirFile) directoryName, fileName, rwsOK);
87     }
88
89     
90     /**
91      * This method tests whether the "rws" and "rwd" modes are implemented. If the "rws" method is supported
92      * then the database engine will conclude that the write methods of "rws" mode StorageRandomAccessFiles are
93      * slow but the sync method is fast and optimize accordingly.
94      *
95      * @return <b>true</b> if an StIRandomAccess file opened with "rws" or "rwd" modes immediately writes data to the
96      * underlying storage, <b>false</b> if not.
97      */

98     public boolean supportsRws()
99     {
100         return rwsOK;
101     }
102     
103
104 }
105
Popular Tags