1 41 42 package com.mullassery.act.util; 43 import java.io.File ; 44 45 import org.w3c.dom.Element ; 46 47 51 public final class ResourceUtil { 52 public static final String ACT_BUNDLE_NAME = "act"; 53 public static final String ACT_HOME = "ACT_HOME"; 54 public static final String ACT_MRU_FILE_PROPERTY_NAME = "mruFile"; 55 public static final String ACT_MRU_XML = "act-mru.xml"; 56 public static final String ACT_TASKS_FILE_PROPERTY_NAME = "tasksFile"; 57 public static final String ACT_TASKS_XML = "act-tasks.xml"; 58 public static final String ACT_SETTINGS_FILE_PROPERTY_NAME = "settingsFile"; 59 public static final String ACT_SETTINGS_XML = "act-settings.xml"; 60 public static Element actMRUElement; 61 public static File actMRUFile; 62 public static Element actSettingsElement; 63 public static File actSettingsFile; 64 public static Element actTasksElement; 65 public static File actTasksFile; 66 67 public static String actDir; 68 69 72 private ResourceUtil() { 73 } 74 75 public static File getMRUFile() { 76 if (actMRUFile != null) 77 return actMRUFile; 78 actMRUFile = new File (ACT_MRU_XML); 79 return actMRUFile; 80 } 81 82 public static File getTasksFile() { 83 if (actTasksFile != null) 84 return actTasksFile; 85 actTasksFile = new File (ACT_TASKS_XML); 86 return actTasksFile; 87 } 88 89 public static File getSettingsFile() { 90 if (actSettingsFile != null) 91 return actSettingsFile; 92 actSettingsFile = searchFile(ACT_SETTINGS_XML); 93 return actSettingsFile; 94 } 95 96 public static File searchFile(String fName) { 99 String dir = actDir; 100 File f = null; 101 if (dir != null && dir.length() > 0) { 102 f = new File (dir + File.separator + fName); 103 if (f.exists() && f.isFile()) 104 return f; 105 } 106 dir = "."; 107 if (dir != null && dir.length() > 0) { 108 f = new File (dir + File.separator + fName); 109 if (f.exists() && f.isFile()) 110 return f; 111 } 112 dir = System.getProperty("user.home"); 113 if (dir != null && dir.length() > 0) { 114 f = new File (dir + File.separator + fName); 115 if (f.exists() && f.isFile()) 116 return f; 117 } 118 dir = System.getProperty(ACT_HOME); 119 if (dir != null && dir.length() > 0) { 120 f = new File (dir + File.separator + fName); 121 if (f.exists() && f.isFile()) 122 return f; 123 } 124 return new File ("." + File.separator + fName); 125 } 126 127 } 128 | Popular Tags |