KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > config > DefaultConfigDirectory


1 package org.columba.core.config;
2
3 import java.io.File JavaDoc;
4
5 import org.columba.core.base.OSInfo;
6
7 /**
8  * Path to configuration directory.
9  *
10  * @author Frederik Dietz
11  */

12 public class DefaultConfigDirectory {
13
14     private static DefaultConfigDirectory instance = new DefaultConfigDirectory();
15
16     private File JavaDoc currentPath;
17
18     private DefaultConfigDirectory() {}
19
20     public static DefaultConfigDirectory getInstance() {
21         return instance;
22     }
23
24     /**
25      * Set current path to config directory. This is set by org.columba.main.Bootstrap and depends on the
26      * selected profile.
27      *
28      * @param currentPath
29      */

30     public void setCurrentPath(File JavaDoc currentPath) {
31         this.currentPath = currentPath;
32     }
33
34     public File JavaDoc getCurrentPath() {
35         if ( currentPath == null) {
36             // fall back to default path
37
currentPath = DefaultConfigDirectory.getDefaultPath();
38         }
39
40         return currentPath;
41     }
42
43     /**
44      * Returns the default configuration path. This value depends on the
45      * underlying operating system. This method must never return null.
46      */

47     public static File JavaDoc getDefaultPath() {
48         if (OSInfo.isWindowsPlatform()) {
49             return new File JavaDoc("config"); //$NON-NLS-1$
50
}
51         return new File JavaDoc(System.getProperty("user.home"), ".columba"); //$NON-NLS-1$//$NON-NLS-2$
52
}
53 }
54
Popular Tags