2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.ws.dbsources.das.api.DasSourceRegistryI;
24 import jalview.ws.dbsources.das.datamodel.DasSourceRegistry;
26 import java.awt.Color;
27 import java.io.BufferedReader;
29 import java.io.FileInputStream;
30 import java.io.FileOutputStream;
31 import java.io.InputStream;
32 import java.io.InputStreamReader;
33 import java.text.DateFormat;
34 import java.text.SimpleDateFormat;
35 import java.util.Collections;
36 import java.util.Date;
37 import java.util.Enumeration;
38 import java.util.Properties;
39 import java.util.TreeSet;
41 import org.apache.log4j.ConsoleAppender;
42 import org.apache.log4j.Level;
43 import org.apache.log4j.Logger;
44 import org.apache.log4j.SimpleLayout;
47 * Stores and retrieves Jalview Application Properties Lists and fields within
48 * list entries are separated by '|' symbols unless otherwise stated (|) clauses
49 * are alternative values for a tag. <br>
51 * Current properties include:
54 * logs.Axis.Level - one of the stringified Levels for log4j controlling the
55 * logging level for axis (used for web services) <br>
57 * <li>logs.Castor.Level - one of the stringified Levels for log4j controlling
58 * the logging level for castor (used for serialization) <br>
60 * <li>logs.Jalview.Level - Cache.log stringified level. <br>
62 * <li>SCREEN_WIDTH</li>
63 * <li>SCREEN_HEIGHT</li>
64 * <li>SCREEN_Y=285</li>
65 * <li>SCREEN_X=371</li>
66 * <li>SHOW_FULLSCREEN boolean</li>
67 * <li>FONT_NAME java font name for alignment text display</li>
68 * <li>FONT_SIZE size of displayed alignment text</li>
69 * <li>FONT_STYLE style of font displayed (sequence labels are always italic)</li>
70 * <li>GAP_SYMBOL character to treat as gap symbol (usually -,.,' ')</li>
71 * <li>LAST_DIRECTORY last directory for browsing alignment</li>
72 * <li>USER_DEFINED_COLOURS list of user defined colour scheme files</li>
73 * <li>SHOW_FULL_ID show id with '/start-end' numbers appended</li>
74 * <li>SHOW_IDENTITY show percentage identity annotation</li>
75 * <li>SHOW_QUALITY show alignment quality annotation</li>
76 * <li>SHOW_ANNOTATIONS show alignment annotation rows</li>
77 * <li>SHOW_CONSERVATION show alignment conservation annotation</li>
78 * <li>SORT_ANNOTATIONS currently either SEQUENCE_AND_LABEL or
79 * LABEL_AND_SEQUENCE</li>
80 * <li>SHOW_AUTOCALC_ABOVE true to show autocalculated annotations above
81 * sequence annotations</li>
82 * <li>CENTRE_COLUMN_LABELS centre the labels at each column in a displayed
84 * <li>DEFAULT_COLOUR default colour scheme to apply for a new alignment</li>
85 * <li>DEFAULT_FILE_FORMAT file format used to save</li>
86 * <li>STARTUP_FILE file loaded on startup (may be a fully qualified url)</li>
87 * <li>SHOW_STARTUP_FILE flag to control loading of startup file</li>
88 * <li>VERSION the version of the jalview build</li>
89 * <li>BUILD_DATE date of this build</li>
90 * <li>LATEST_VERSION the latest jalview version advertised on the
91 * www.jalview.org</li>
92 * <li>PIR_MODELLER boolean indicating if PIR files are written with MODELLER
94 * <li>(FASTA,MSF,PILEUP,CLUSTAL,BLC,PIR,PFAM)_JVSUFFIX boolean for adding jv
96 * <li>RECENT_URL list of recently retrieved URLs</li>
97 * <li>RECENT_FILE list of recently opened files</li>
98 * <li>USE_PROXY flag for whether a http proxy is to be used</li>
99 * <li>PROXY_SERVER the proxy</li>
100 * <li>PROXY_PORT</li>
101 * <li>NOQUESTIONNAIRES true to prevent jalview from checking the questionnaire
103 * <li>QUESTIONNAIRE last questionnaire:responder id string from questionnaire
105 * <li>USAGESTATS (false - user prompted) Enable google analytics tracker for
106 * collecting usage statistics</li>
107 * <li>DAS_LOCAL_SOURCE list of local das sources</li>
108 * <li>SHOW_OVERVIEW boolean for overview window display</li>
109 * <li>ANTI_ALIAS boolean for smooth fonts</li>
110 * <li>RIGHT_ALIGN_IDS boolean</li>
111 * <li>AUTO_CALC_CONSENSUS boolean for automatic recalculation of consensus</li>
112 * <li>PAD_GAPS boolean</li>
113 * <li>ID_ITALICS boolean</li>
114 * <li>SHOW_JV_SUFFIX</li>
115 * <li>WRAP_ALIGNMENT</li>
116 * <li>EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering
118 * <li>SORT_ALIGNMENT (No sort|Id|Pairwise Identity)</li>
119 * <li>SEQUENCE_LINKS list of name|URL pairs for opening a url with
121 * <li>GROUP_LINKS list of name|URL[|<separator>] tuples - see
122 * jalview.utils.GroupURLLink for more info</li>
123 * <li>DAS_REGISTRY_URL the registry to query</li>
124 * <li>DEFAULT_BROWSER for unix</li>
125 * <li>DAS_ACTIVE_SOURCE list of active sources</li>
126 * <li>SHOW_MEMUSAGE boolean show memory usage and warning indicator on desktop
128 * <li>VERSION_CHECK (true) check for the latest release version from
129 * www.jalview.org (or the alias given by the www.jalview.org property)</li>
130 * <li>SHOW_NPFEATS_TOOLTIP (true) show non-positional features in the Sequence
132 * <li>SHOW_DBREFS_TOOLTIP (true) show Database Cross References in the Sequence
134 * <li>SHOW_UNCONSERVED (false) only render unconserved residues - conserved
135 * displayed as '.'</li>
136 * <li>SORT_BY_TREE (false) sort the current alignment view according to the
137 * order of a newly displayed tree</li>
138 * <li>DBFETCH_USEPICR (false) use PICR to recover valid DB references from
139 * sequence ID strings before attempting retrieval from any datasource</li>
140 * <li>SHOW_GROUP_CONSENSUS (false) Show consensus annotation for groups in the
142 * <li>SHOW_GROUP_CONSERVATION (false) Show conservation annotation for groups
143 * in the alignment.</li>
144 * <li>SHOW_CONSENSUS_HISTOGRAM (false) Show consensus annotation row's
146 * <li>SHOW_CONSENSUS_LOGO (false) Show consensus annotation row's sequence
148 * <li>NORMALISE_CONSENSUS_LOGO (false) Show consensus annotation row's sequence
149 * logo normalised to row height rather than histogram height.</li>
150 * <li>FOLLOW_SELECTIONS (true) Controls whether a new alignment view should
151 * respond to selections made in other alignments containing the same sequences.
153 * <li>SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery
154 * warning dialog box is displayed.</li>
155 * <li>ANNOTATIONCOLOUR_MIN (orange) Shade used for minimum value of annotation
156 * when shading by annotation</li>
157 * <li>ANNOTATIONCOLOUR_MAX (red) Shade used for maximum value of annotation
158 * when shading by annotation</li>
159 * <li>www.jalview.org (http://www.jalview.org) a property enabling all HTTP
160 * requests to be redirected to a mirror of http://www.jalview.org</li>
161 * <li>FIGURE_AUTOIDWIDTH (false) Expand the left hand column of an exported
162 * alignment figure to accommodate even the longest sequence ID or annotation
164 * <li>FIGURE_FIXEDIDWIDTH Specifies the width to use for the left-hand column
165 * when exporting an alignment as a figure (setting FIGURE_AUTOIDWIDTH to true
166 * will override this).</li>
167 * <li>STRUCT_FROM_PDB (false) derive secondary structure annotation from PDB
169 * <li>USE_RNAVIEW (false) use RNAViewer to derive secondary structure</li>
170 * <li>ADD_SS_ANN (false) add secondary structure annotation to alignment
172 * <li>ADD_TEMPFACT_ANN (false) add Temperature Factor annotation to alignment
174 * <li>STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure
176 * <li>CHIMERA_PATH specify full path to Chimera program (if non-standard)</li>
179 * Deprecated settings:
182 * <li>DISCOVERY_START - Boolean - controls if discovery services are queried on
183 * startup (JWS1 services only)</li>
184 * <li>DISCOVERY_URLS - comma separated list of Discovery Service endpoints.
185 * (JWS1 services only)</li>
186 * <li>SHOW_JWS1_SERVICES (true) enable or disable the original Jalview 2
187 * services in the desktop GUI</li>
188 * <li>ENABLE_RSBS_EDITOR (false for 2.7 release) enable or disable RSBS editing
189 * panel in web service preferences</li>
193 * @version $Revision$
198 * property giving log4j level for CASTOR loggers
200 public static final String CASTORLOGLEVEL = "logs.Castor.level";
203 * property giving log4j level for AXIS loggers
205 public static final String AXISLOGLEVEL = "logs.Axis.level";
208 * property giving log4j level for Jalview Log
210 public static final String JALVIEWLOGLEVEL = "logs.Jalview.level";
212 public static final String DAS_LOCAL_SOURCE = "DAS_LOCAL_SOURCE";
214 public static final String DAS_REGISTRY_URL = "DAS_REGISTRY_URL";
216 public static final String DAS_ACTIVE_SOURCE = "DAS_ACTIVE_SOURCE";
219 * Initialises the Jalview Application Log
221 public static Logger log;
223 /** Jalview Properties */
224 public static Properties applicationProperties = new Properties() {
225 // override results in properties output in alphabetical order
227 public synchronized Enumeration<Object> keys() {
228 return Collections.enumeration(new TreeSet<Object>(super.keySet()));
232 /** Default file is ~/.jalview_properties */
233 static String propertiesFile;
235 private static boolean propsAreReadOnly = false;
237 public static void initLogger()
245 // TODO: redirect stdout and stderr here in order to grab the output of
248 ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),
250 ap.setName("JalviewLogger");
251 org.apache.log4j.Logger.getRootLogger().addAppender(ap); // catch all for
253 Logger laxis = Logger.getLogger("org.apache.axis");
254 Logger lcastor = Logger.getLogger("org.exolab.castor");
255 jalview.bin.Cache.log = Logger.getLogger("jalview.bin.Jalview");
257 laxis.setLevel(Level.toLevel(Cache.getDefault("logs.Axis.Level",
258 Level.INFO.toString())));
259 lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
260 Level.INFO.toString())));
261 lcastor = Logger.getLogger("org.exolab.castor.xml");
262 lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
263 Level.INFO.toString())));
264 // lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller");
265 // lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
266 // Level.INFO.toString())));
267 jalview.bin.Cache.log.setLevel(Level.toLevel(Cache.getDefault(
268 "logs.Jalview.level", Level.INFO.toString())));
269 // laxis.addAppender(ap);
270 // lcastor.addAppender(ap);
271 // jalview.bin.Cache.log.addAppender(ap);
272 // Tell the user that debug is enabled
273 jalview.bin.Cache.log.debug("Jalview Debugging Output Follows.");
274 } catch (Exception ex)
276 System.err.println("Problems initializing the log4j system\n");
277 ex.printStackTrace(System.err);
281 /** Called when Jalview is started */
282 public static void loadProperties(String propsFile)
284 propertiesFile = propsFile;
285 if (propsFile == null)
287 propertiesFile = System.getProperty("user.home") + File.separatorChar
288 + ".jalview_properties";
292 // don't corrupt the file we've been given.
293 propsAreReadOnly = true;
301 fis = new java.net.URL(propertiesFile).openStream();
302 System.out.println("Loading jalview properties from : "
305 .println("Disabling Jalview writing to user's local properties file.");
306 propsAreReadOnly = true;
308 } catch (Exception ex)
314 fis = new FileInputStream(propertiesFile);
316 applicationProperties.load(fis);
318 // remove any old build properties
320 deleteBuildProperties();
322 } catch (Exception ex)
324 System.out.println("Error reading properties file: " + ex);
327 if (getDefault("USE_PROXY", false))
329 String proxyServer = getDefault("PROXY_SERVER", ""), proxyPort = getDefault(
330 "PROXY_PORT", "8080");
332 System.out.println("Using proxyServer: " + proxyServer
333 + " proxyPort: " + proxyPort);
335 System.setProperty("http.proxyHost", proxyServer);
336 System.setProperty("http.proxyPort", proxyPort);
339 // LOAD THE AUTHORS FROM THE authors.props file
342 String authorDetails = "jar:".concat(Cache.class
343 .getProtectionDomain().getCodeSource().getLocation()
344 .toString().concat("!/authors.props"));
346 java.net.URL localJarFileURL = new java.net.URL(authorDetails);
348 InputStream in = localJarFileURL.openStream();
349 applicationProperties.load(in);
351 } catch (Exception ex)
353 System.out.println("Error reading author details: " + ex);
354 applicationProperties.remove("AUTHORS");
355 applicationProperties.remove("AUTHORFNAMES");
356 applicationProperties.remove("YEAR");
359 // FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar
360 // MUST FOLLOW READING OF LOCAL PROPERTIES FILE AS THE
361 // VERSION MAY HAVE CHANGED SINCE LAST USING JALVIEW
364 String buildDetails = "jar:".concat(Cache.class.getProtectionDomain()
365 .getCodeSource().getLocation().toString()
366 .concat("!/.build_properties"));
368 java.net.URL localJarFileURL = new java.net.URL(buildDetails);
370 InputStream in = localJarFileURL.openStream();
371 applicationProperties.load(in);
373 } catch (Exception ex)
375 System.out.println("Error reading build details: " + ex);
376 applicationProperties.remove("VERSION");
379 String jnlpVersion = System.getProperty("jalview.version");
380 String codeVersion = getProperty("VERSION");
382 if (codeVersion == null)
384 // THIS SHOULD ONLY BE THE CASE WHEN TESTING!!
385 codeVersion = "Test";
386 jnlpVersion = "Test";
389 System.out.println("Jalview Version: " + codeVersion);
391 // jnlpVersion will be null if we're using InstallAnywhere
392 // Dont do this check if running in headless mode
393 if (jnlpVersion == null
394 && getDefault("VERSION_CHECK", true)
395 && (System.getProperty("java.awt.headless") == null || System
396 .getProperty("java.awt.headless").equals("false")))
399 class VersionChecker extends Thread
403 String orgtimeout = System
404 .getProperty("sun.net.client.defaultConnectTimeout");
405 if (orgtimeout == null)
408 System.out.println("# INFO: Setting default net timeout to "
409 + orgtimeout + " seconds.");
411 String jnlpVersion = null;
414 System.setProperty("sun.net.client.defaultConnectTimeout",
416 java.net.URL url = new java.net.URL(Cache.getDefault(
417 "www.jalview.org", "http://www.jalview.org")
418 + "/webstart/jalview.jnlp");
419 BufferedReader in = new BufferedReader(new InputStreamReader(
422 while ((line = in.readLine()) != null)
424 if (line.indexOf("jalview.version") == -1)
429 line = line.substring(line.indexOf("value=") + 7);
430 line = line.substring(0, line.lastIndexOf("\""));
434 } catch (Exception ex)
437 .println("Non-fatal exceptions when checking version at www.jalview.org :");
438 System.out.println(ex);
439 jnlpVersion = getProperty("VERSION");
441 System.setProperty("sun.net.client.defaultConnectTimeout",
444 setProperty("LATEST_VERSION", jnlpVersion);
448 VersionChecker vc = new VersionChecker();
453 if (jnlpVersion != null)
455 setProperty("LATEST_VERSION", jnlpVersion);
459 applicationProperties.remove("LATEST_VERSION");
463 setProperty("VERSION", codeVersion);
465 // LOAD USERDEFINED COLOURS
466 jalview.gui.UserDefinedColours
467 .initUserColourSchemes(getProperty("USER_DEFINED_COLOURS"));
468 jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER",
472 private static void deleteBuildProperties()
474 applicationProperties.remove("LATEST_VERSION");
475 applicationProperties.remove("VERSION");
476 applicationProperties.remove("AUTHORS");
477 applicationProperties.remove("AUTHORFNAMES");
478 applicationProperties.remove("YEAR");
482 * Gets Jalview application property of given key. Returns null if key not
488 * @return Property value
490 public static String getProperty(String key)
492 return applicationProperties.getProperty(key);
496 * These methods are used when checking if the saved preference is different
497 * to the default setting
500 public static boolean getDefault(String property, boolean def)
502 String string = getProperty(property);
505 def = Boolean.valueOf(string).booleanValue();
512 * These methods are used when checking if the saved preference is different
513 * to the default setting
515 public static String getDefault(String property, String def)
517 String string = getProperty(property);
527 * Stores property in the file "HOME_DIR/.jalview_properties"
532 * String value of property
534 * @return String value of property
536 public static String setProperty(String key, String obj)
541 applicationProperties.setProperty(key, obj);
542 if (!propsAreReadOnly)
544 FileOutputStream out = new FileOutputStream(propertiesFile);
545 applicationProperties.store(out, "---JalviewX Properties File---");
548 } catch (Exception ex)
550 System.out.println("Error setting property: " + key + " " + obj
557 * remove the specified property from the jalview properties file
561 public static void removeProperty(String string)
563 applicationProperties.remove(string);
568 * save the properties to the jalview properties path
570 public static void saveProperties()
572 if (!propsAreReadOnly)
576 FileOutputStream out = new FileOutputStream(propertiesFile);
577 applicationProperties.store(out, "---JalviewX Properties File---");
579 } catch (Exception ex)
581 System.out.println("Error saving properties: " + ex);
587 * internal vamsas class discovery state
589 private static int vamsasJarsArePresent = -1;
592 * Searches for vamsas client classes on class path.
594 * @return true if vamsas client is present on classpath
596 public static boolean vamsasJarsPresent()
598 if (vamsasJarsArePresent == -1)
602 if (jalview.jbgui.GDesktop.class.getClassLoader().loadClass(
603 "uk.ac.vamsas.client.VorbaId") != null)
605 jalview.bin.Cache.log
606 .debug("Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)");
607 vamsasJarsArePresent = 1;
608 Logger lvclient = Logger.getLogger("uk.ac.vamsas");
609 lvclient.setLevel(Level.toLevel(Cache.getDefault(
610 "logs.Vamsas.Level", Level.INFO.toString())));
612 lvclient.addAppender(log.getAppender("JalviewLogger"));
613 // Tell the user that debug is enabled
614 lvclient.debug("Jalview Vamsas Client Debugging Output Follows.");
616 } catch (Exception e)
618 vamsasJarsArePresent = 0;
619 jalview.bin.Cache.log.debug("Vamsas Classes are not present");
622 return (vamsasJarsArePresent > 0);
626 * internal vamsas class discovery state
628 private static int groovyJarsArePresent = -1;
631 * Searches for vamsas client classes on class path.
633 * @return true if vamsas client is present on classpath
635 public static boolean groovyJarsPresent()
637 if (groovyJarsArePresent == -1)
641 if (Cache.class.getClassLoader().loadClass(
642 "groovy.lang.GroovyObject") != null)
644 jalview.bin.Cache.log
645 .debug("Found Groovy (groovy.lang.GroovyObject can be loaded)");
646 groovyJarsArePresent = 1;
647 Logger lgclient = Logger.getLogger("groovy");
648 lgclient.setLevel(Level.toLevel(Cache.getDefault(
649 "logs.Groovy.Level", Level.INFO.toString())));
651 lgclient.addAppender(log.getAppender("JalviewLogger"));
652 // Tell the user that debug is enabled
653 lgclient.debug("Jalview Groovy Client Debugging Output Follows.");
657 groovyJarsArePresent = 0;
658 jalview.bin.Cache.log.debug("Groovy Classes are not present", e);
659 } catch (Exception e)
661 groovyJarsArePresent = 0;
662 jalview.bin.Cache.log.debug("Groovy Classes are not present");
665 return (groovyJarsArePresent > 0);
669 * GA tracker object - actually JGoogleAnalyticsTracker null if tracking not
672 protected static Object tracker = null;
674 protected static Class trackerfocus = null;
676 protected static Class jgoogleanalyticstracker = null;
679 * Initialise the google tracker if it is not done already.
681 public static void initGoogleTracker()
685 if (jgoogleanalyticstracker == null)
687 // try to get the tracker class
690 jgoogleanalyticstracker = Cache.class
693 "com.boxysystems.jgoogleanalytics.JGoogleAnalyticsTracker");
694 trackerfocus = Cache.class.getClassLoader().loadClass(
695 "com.boxysystems.jgoogleanalytics.FocusPoint");
696 } catch (Exception e)
698 log.debug("com.boxysystems.jgoogleanalytics package is not present - tracking not enabled.");
700 jgoogleanalyticstracker = null;
705 // now initialise tracker
706 Exception re = null, ex = null;
708 String vrs = "No Version Accessible";
711 // Google analytics tracking code for Library Finder
712 tracker = jgoogleanalyticstracker.getConstructor(new Class[]
713 { String.class, String.class, String.class }).newInstance(
717 (vrs = jalview.bin.Cache.getProperty("VERSION")
719 + jalview.bin.Cache.getDefault("BUILD_DATE",
720 "unknown")), "UA-9060947-1" });
721 jgoogleanalyticstracker.getMethod("trackAsynchronously",
723 { trackerfocus }).invoke(tracker, new Object[]
724 { trackerfocus.getConstructor(new Class[]
725 { String.class }).newInstance(new Object[]
726 { "Application Started." }) });
727 } catch (RuntimeException e)
730 } catch (Exception e)
737 if (re != null || ex != null || err != null)
743 log.debug("Caught runtime exception in googletracker init:", re);
748 "Failed to initialise GoogleTracker for Jalview Desktop with version "
754 "Whilst initing GoogleTracker for Jalview Desktop version "
763 .println("Debug: Caught runtime exception in googletracker init:"
765 re.printStackTrace();
770 .println("Warning: Failed to initialise GoogleTracker for Jalview Desktop with version "
772 ex.printStackTrace();
778 .println("ERROR: Whilst initing GoogleTracker for Jalview Desktop version "
780 err.printStackTrace();
786 log.debug("Successfully initialised tracker.");
792 * get the user's default colour if available
798 public static Color getDefaultColour(String property, Color defcolour)
800 String colprop = getProperty(property);
805 Color col = jalview.schemes.ColourSchemeProperty
806 .getAWTColorFromName(colprop);
811 col = new jalview.schemes.UserColourScheme(colprop).findColour('A');
812 } catch (Exception ex)
814 log.warn("Couldn't parse '" + colprop + "' as a colour for "
819 return (col == null) ? defcolour : col;
823 * store a colour as a Jalview user default property
828 public static void setColourProperty(String property, Color colour)
830 setProperty(property, jalview.util.Format.getHexString(colour));
833 public static final DateFormat date_format = SimpleDateFormat
834 .getDateTimeInstance();
837 * store a date in a jalview property
842 public static void setDateProperty(String property, Date time)
844 setProperty(property, date_format.format(time));
848 * read a date stored in a jalview property
851 * @return valid date as stored by setDateProperty, or null
854 public static Date getDateProperty(String property)
856 String val = getProperty(property);
861 return date_format.parse(val);
862 } catch (Exception ex)
864 System.err.println("Invalid or corrupt date in property '"
865 + property + "' : value was '" + val + "'");
872 * get and parse a property as an integer. send any parsing problems to
876 * @return null or Integer
878 public static Integer getIntegerProperty(String property)
880 String val = getProperty(property);
881 if (val != null && (val = val.trim()).length() > 0)
885 return Integer.valueOf(val);
886 } catch (NumberFormatException x)
888 System.err.println("Invalid integer in property '" + property
889 + "' (value was '" + val + "')");
895 private static DasSourceRegistryI sourceRegistry = null;
900 * @return instance of the das source registry
902 public static DasSourceRegistryI getDasSourceRegistry()
904 if (sourceRegistry == null)
906 sourceRegistry = new DasSourceRegistry();
908 return sourceRegistry;
912 * Set the specified value, or remove it if null or empty. Does not save the
918 public static void setOrRemove(String propName, String value)
920 if (propName == null)
924 if (value == null || value.trim().length() < 1)
926 Cache.applicationProperties.remove(propName);
930 Cache.applicationProperties.setProperty(propName, value);