
org.intermine.util.PropertiesUtil Maven / Gradle / Ivy
package org.intermine.util;
/*
* Copyright (C) 2002-2022 FlyMine
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. See the LICENSE file for more
* information or http://www.gnu.org/copyleft/lesser.html.
*
*/
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.intermine.metadata.NonOverrideableProperties;
/**
* Convenience class for working with global properties
*
* @author Andrew Varley
*/
public final class PropertiesUtil
{
private static final Logger LOG = Logger.getLogger(PropertiesUtil.class);
private static Properties globalProperties;
private PropertiesUtil() {
// don't instantiate
}
/**
* Returns all InterMine properties
*
* @return the global properties for InterMine
*/
public static Properties getProperties() {
if (globalProperties == null) {
initGlobalProperties();
}
return globalProperties;
}
private static void initGlobalProperties() {
globalProperties = new Properties();
// Read Properties from the following files
// default.intermine.properties: Common runtime Properties
// intermine.properties: User runtime properties
loadGlobalProperties("default.intermine.properties");
loadGlobalProperties("intermine.properties");
}
/**
* Returns all Properties in props that begin with str
*
* @param str the String that the returned properties should start with
* @param props the Properties to search through
* @return a Properties object containing the subset of props
*/
public static Properties getPropertiesStartingWith(String str, Properties props) {
if (str == null) {
throw new NullPointerException("str cannot be null, props param: " + props);
}
if (props == null) {
throw new NullPointerException("props cannot be null, str param: " + str);
}
Properties subset = new Properties();
Enumeration
© 2015 - 2025 Weber Informatics LLC | Privacy Policy