Properties added
authoramwaterhouse <Andrew Waterhouse>
Mon, 7 Feb 2005 17:06:17 +0000 (17:06 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 7 Feb 2005 17:06:17 +0000 (17:06 +0000)
src/jalview/bin/Cache.java

index b054bc3..a5231e1 100755 (executable)
@@ -1,15 +1,68 @@
-/********************
- * 2004 Jalview Reengineered
- * Barton Group
- * Dundee University
- *
- * AM Waterhouse
- *******************/
-
-
-package jalview.bin;
-
-public class Cache
-{
-  public static String LAST_DIRECTORY = ".";
-}
+/********************\r
+ * 2004 Jalview Reengineered\r
+ * Barton Group\r
+ * Dundee University\r
+ *\r
+ * AM Waterhouse\r
+ *******************/\r
+\r
+\r
+package jalview.bin;\r
+import java.util.*;\r
+import java.io.*;\r
+\r
+public class Cache\r
+{\r
+  public static Properties applicationProperties;\r
+  // Current properties include:\r
+  //\r
+  // LAST_DIRECTORY   , use this to cache record of where the user looked to find a file\r
+  // UNIPROT_CACHE\r
+\r
+  public static void loadProperties()\r
+  {\r
+    applicationProperties = new Properties();\r
+\r
+    try\r
+    {\r
+      FileInputStream in = new FileInputStream(System.getProperty("user.home") +\r
+                                               "/.jalview_properties");\r
+      applicationProperties = new Properties();\r
+      applicationProperties.load(in);\r
+      in.close();\r
+    }\r
+    catch (Exception ex)\r
+    {\r
+      ex.printStackTrace();\r
+    }\r
+\r
+\r
+  }\r
+\r
+  public static String getProperty(String key)\r
+  {\r
+    return  applicationProperties.getProperty(key);\r
+  }\r
+\r
+  public static void setProperty(String key, String obj)\r
+  {\r
+    try\r
+    {\r
+      FileOutputStream out = new FileOutputStream(System.getProperty(\r
+          "user.home") + "/.jalview_properties");\r
+\r
+      applicationProperties.setProperty(key, obj);\r
+\r
+      applicationProperties.store(out, "---JalviewX Properties File---");\r
+      out.close();\r
+    }\r
+    catch (Exception ex)\r
+    {}\r
+\r
+  }\r
+\r
+\r
+\r
+\r
+\r
+}\r