Example usage for java.util Properties stringPropertyNames

List of usage examples for java.util Properties stringPropertyNames

Introduction

In this page you can find the example usage for java.util Properties stringPropertyNames.

Prototype

public Set<String> stringPropertyNames() 

Source Link

Document

Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

Usage

From source file:edu.wustl.mir.erl.ihe.xdsi.util.RelatedGeneralSOPClasses.java

public void init(Properties props) {
    for (String cuid : props.stringPropertyNames())
        commonExtNegs.put(cuid, new CommonExtendedNegotiation(cuid, UID.StorageServiceClass,
                StringUtils.split(props.getProperty(cuid), ',')));
}

From source file:com.cognifide.qa.bb.config.ConfigStrategy.java

/**
 * Sets system properties for loaded properties that start with {@value ConfigKeys#WEBDRIVER_PROP_PREFIX}.
 *
 * @param properties loaded config//www.ja  va2  s . c o  m
 */
default void setSystemProperties(Properties properties) {
    properties.stringPropertyNames().stream().filter(key -> StringUtils.isBlank(System.getProperty(key)))
            .filter(key -> key.startsWith(ConfigKeys.WEBDRIVER_PROP_PREFIX))
            .forEach(key -> System.setProperty(key, properties.getProperty(key)));
}

From source file:org.xwiki.configuration.internal.SystemPropertiesConfigurationSource.java

@Override
public void initialize() throws InitializationException {
    BaseConfiguration configuration = new BaseConfiguration();
    configuration.setDelimiterParsingDisabled(true);

    Properties properties = System.getProperties();
    for (String key : properties.stringPropertyNames()) {
        configuration.setProperty(key, properties.get(key));
    }/*  ww w .  j  av  a  2s.  c o  m*/

    setConfiguration(configuration);
}

From source file:org.sonar.batch.scan.ProjectReactorBuilderTest.java

protected static Properties toProperties(File propertyFile) {
    Properties propsFromFile = new Properties();
    try (FileInputStream fileInputStream = new FileInputStream(propertyFile)) {
        propsFromFile.load(fileInputStream);
    } catch (IOException e) {
        throw new IllegalStateException(
                "Impossible to read the property file: " + propertyFile.getAbsolutePath(), e);
    }/* w ww  .  j av  a 2  s  .c om*/
    // Trim properties
    for (String propKey : propsFromFile.stringPropertyNames()) {
        propsFromFile.setProperty(propKey, StringUtils.trim(propsFromFile.getProperty(propKey)));
    }
    return propsFromFile;
}

From source file:no.dusken.common.plugin.PluginPropertyPlaceholderConfigurer.java

/**
 * Return a merged Properties instance containing both the
 * loaded properties and properties set on this FactoryBean.
 */// w  ww  . j a  v  a  2s  .  c om
@Override
protected Properties mergeProperties() throws IOException {
    PluginStore store = pluginStoreProvider.getStore(plugin);
    Properties properties = super.mergeProperties();
    for (String s : properties.stringPropertyNames()) {
        String value = store.getString(s, null);
        if (value == null) {
            store.setString(s, properties.getProperty(s));
        } else {
            properties.setProperty(s, value);
        }
    }
    if (exposedProperties != null) {
        properties.putAll(exposedProperties);
    }
    return properties;
}

From source file:com.netflix.ndbench.core.config.SystemPropertiesConfigSource.java

@Override
public void initialize() {
    super.initialize();

    Properties systemProps = System.getProperties();

    for (final String key : systemProps.stringPropertyNames()) {
        if (!key.startsWith(NdBenchConstants.WEBAPP_NAME)) {
            continue;
        }/*from w w w .j a  v  a  2 s  .c  o m*/
        final String value = systemProps.getProperty(key);
        if (!StringUtils.isEmpty(value)) {
            data.put(key, value);
        }
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.application.BuildProperties.java

public BuildProperties(ServletContext ctx) {
    Map<String, String> map = new HashMap<>();

    try (InputStream stream = ctx.getResourceAsStream(WEBAPP_PATH_BUILD_PROPERTIES)) {
        if (stream == null) {
            log.debug("Didn't find a resource at '" + WEBAPP_PATH_BUILD_PROPERTIES + "'.");
        } else {/* w  w  w.j  a  va  2 s  . co m*/
            Properties props = new Properties();
            props.load(stream);
            for (String key : props.stringPropertyNames()) {
                map.put(key, props.getProperty(key));
            }
        }
    } catch (IOException e) {
        throw new RuntimeException("Failed to load from '" + WEBAPP_PATH_BUILD_PROPERTIES + "'.", e);
    }
    propertyMap = Collections.unmodifiableMap(map);
}

From source file:edu.umass.cs.gigapaxos.PaxosConfig.java

/**
 * @return A map of names and socket addresses corresponding to servers
 *         hosting paxos replicas./*from   www.j  a  v  a 2s  . c om*/
 */
public static Map<String, InetSocketAddress> getActives() {
    Map<String, InetSocketAddress> map = new HashMap<String, InetSocketAddress>();
    Properties config = getAsProperties();

    Set<String> keys = config.stringPropertyNames();
    for (String key : keys) {
        if (key.trim().startsWith(DEFAULT_SERVER_PREFIX)) {
            map.put(key.replaceFirst(DEFAULT_SERVER_PREFIX, ""),
                    Util.getInetSocketAddressFromString(config.getProperty(key)));
        }
    }
    return map;
}

From source file:edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesImpl.java

public ConfigurationPropertiesImpl(InputStream stream, Map<String, String> preemptiveProperties,
        Map<String, String> buildProperties) throws IOException {
    Map<String, String> map = new HashMap<>(buildProperties);

    Properties props = loadFromPropertiesFile(stream);
    for (String key : props.stringPropertyNames()) {
        map.put(key, props.getProperty(key));
    }/*from  ww  w .  jav a  2 s  .c o m*/

    if (preemptiveProperties != null) {
        map.putAll(preemptiveProperties);
    }

    trimWhiteSpaceFromValues(map);

    this.propertyMap = Collections.unmodifiableMap(map);
    log.debug("Configuration properties are: " + map);
}

From source file:net.unit8.longadeseo.servlet.AbstractConfig.java

/**
 * Initializes the configuration with values from the given properties
 * @param props the configuration properties
 *///from  w  ww  .  j a  va2s.c  o  m
public void init(Properties props) throws ServletException {
    for (String name : props.stringPropertyNames()) {
        String mapName = toMapName(name, '.');
        try {
            if (map.containsKey(mapName)) {
                map.put(mapName, props.getProperty(name));
            }
        } catch (Exception e) {
            throw new ServletExceptionWithCause("Invalid configuration property: " + name, e);
        }
    }
}