2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.bin;
\r
24 import java.util.jar.*;
\r
27 public class Cache {
\r
28 public static String VERSION = "Release 2.0";
\r
29 public static String BUILD_DATE = "";
\r
30 public static Properties applicationProperties;
\r
32 // Current properties include:
\r
34 // LAST_DIRECTORY , use this to cache record of where the user looked to find a file
\r
36 // USER_DEFINED_COLOUR - file describing last user set colours
\r
40 // logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services)
\r
41 // logs.Castor.Level - one of the stringified Levels for log4j controlling the logging level for castor (used for serialization)
\r
42 // jalview.browser - used in the jalview.utils.browserLauncher class if it doesn't know what else to do.
\r
43 public static void loadProperties() {
\r
44 // get last build time.
\r
48 String localFile = Cache.class.getProtectionDomain().getCodeSource()
\r
49 .getLocation().toString();
\r
50 localFile = localFile.concat("!/");
\r
52 String tmpString = "jar:";
\r
53 String localJarFileString = tmpString.concat(localFile);
\r
54 java.net.URL localJarFileURL = new java.net.URL(localJarFileString);
\r
55 java.net.JarURLConnection localJarFile = (java.net.JarURLConnection) localJarFileURL.openConnection();
\r
56 date = localJarFile.getLastModified();
\r
57 } catch (Exception ex) {
\r
58 ex.printStackTrace();
\r
62 // this is called for unpackaged class files, ie not in a Jar file
\r
63 // InstallAnywhere version will find build date this way
\r
64 // not entirely accurate as it only tells you when Cache.class was last compiled
\r
65 java.io.File f = new java.io.File(System.getProperty("user.dir") +
\r
66 "/jalview/bin/Cache.class");
\r
67 date = f.lastModified();
\r
71 BUILD_DATE = new Date(date).toString();
\r
74 applicationProperties = new Properties();
\r
77 FileInputStream in = new FileInputStream(System.getProperty(
\r
78 "user.home") + "/.jalview_properties");
\r
79 applicationProperties = new Properties();
\r
80 applicationProperties.load(in);
\r
82 } catch (Exception ex) {
\r
86 public static String getProperty(String key) {
\r
87 return applicationProperties.getProperty(key);
\r
90 public static String setProperty(String key, String obj) {
\r
92 FileOutputStream out = new FileOutputStream(System.getProperty(
\r
93 "user.home") + "/.jalview_properties");
\r
95 applicationProperties.setProperty(key, obj);
\r
97 applicationProperties.store(out, "---JalviewX Properties File---");
\r
99 } catch (Exception ex) {
\r