1 package cx.fbn.nevernote.config;
8 * Things that can only be changed at startup
12 public class StartupConfig {
14 // Init to default values
15 private String name = "NeverNote";
16 private String homeDirPath;
17 private String programDirPath;
18 private boolean disableViewing = false;
21 public String getName() {
25 public void setName(String n) {
27 name = "NeverNote-" + n;
31 public String getProgramDirPath() {
32 if (programDirPath == null) {
33 programDirPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
34 if (programDirPath.endsWith(".jar")) {
35 programDirPath = programDirPath.substring(0,programDirPath.lastIndexOf("/"));
37 if (programDirPath.endsWith("/")) {
38 programDirPath = programDirPath.substring(0,programDirPath.length()-1);
40 programDirPath = programDirPath.substring(0,programDirPath.lastIndexOf("/"));
43 return programDirPath;
46 public String getHomeDirPath() {
47 if (homeDirPath == null) {
48 homeDirPath = System.getProperty("user.home") + File.separator
49 + "." +name.toLowerCase() + File.separator;
54 public void setHomeDirPath(String path) {
55 if (isNonEmpty(path)) {
60 public void setProgramDirPath(String path) {
61 if (isNonEmpty(path)) {
62 programDirPath = path;
67 public boolean getDisableViewing() {
68 return disableViewing;
71 public void setDisableViewing(boolean disableViewing) {
72 this.disableViewing = disableViewing;
75 private static boolean isNonEmpty(String n) {
76 return n != null && !n.trim().equals("");