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:org.apache.syncope.core.persistence.jpa.content.XMLContentLoader.java

private void createViews(final String domain, final DataSource dataSource) throws IOException {
    LOG.debug("[{}] Creating views", domain);

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    Properties views = PropertiesLoaderUtils.loadProperties(viewsXML.getResource());
    for (String idx : views.stringPropertyNames()) {
        LOG.debug("[{}] Creating view {}", domain, views.get(idx).toString());

        try {/*ww w.j  a v a  2  s  .  com*/
            jdbcTemplate.execute(views.get(idx).toString().replaceAll("\\n", " "));
        } catch (DataAccessException e) {
            LOG.error("[{}] Could not create view", domain, e);
        }
    }

    LOG.debug("Views created");
}

From source file:com.commercehub.bamboo.plugins.grailswrapper.GrailsWrapperTask.java

@NotNull
private Map<String, String> buildEnvironment(@NotNull TaskContext taskContext) {
    ConfigurationMap configurationMap = taskContext.getConfigurationMap();
    Map<String, String> environment = Maps.newHashMap(environmentVariableAccessor.getEnvironment(taskContext));
    Properties properties = loadEnvironmentProperties(taskContext);
    for (String key : properties.stringPropertyNames()) {
        environment.put(key, properties.getProperty(key));
    }//from  www . j  a  v  a  2s  .co  m
    String javaHome = getJavaHome(taskContext);
    String javaOpts = Strings.emptyToNull(configurationMap.get(GrailsWrapperTaskConfigurator.JVM_OPTIONS));
    if (javaHome != null) {
        environment.put("JAVA_HOME", javaHome);
    }
    if (javaOpts != null) {
        environment.put("JAVA_OPTS", javaOpts);
    }
    return environment;
}

From source file:org.jboss.seam.spring.extension.SpringContextBootstrapExtension.java

public void loadSpringContext(@Observes BeforeBeanDiscovery beforeBeanDiscovery, BeanManager beanManager) {
    InputStream inputStream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(Locations.SEAM_SPRING_CONTEXTS_LOCATION);
    if (inputStream != null) {
        Properties contextLocations = new Properties();
        try {//from w  ww  . j av a  2s  .  co  m
            contextLocations.load(inputStream);
            for (String contextName : contextLocations.stringPropertyNames()) {
                ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                        contextLocations.getProperty(contextName));
                contextDefinitions.put(contextName, context);
                for (String beanDefinitionName : context.getBeanDefinitionNames()) {
                    vetoedTypes.add(
                            context.getBeanFactory().getBeanDefinition(beanDefinitionName).getBeanClassName());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}

From source file:org.apache.syncope.core.persistence.jpa.content.XMLContentLoader.java

private void createIndexes(final String domain, final DataSource dataSource) throws IOException {
    LOG.debug("[{}] Creating indexes", domain);

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    Properties indexes = PropertiesLoaderUtils.loadProperties(indexesXML.getResource());
    for (String idx : indexes.stringPropertyNames()) {
        LOG.debug("[{}] Creating index {}", domain, indexes.get(idx).toString());

        try {//  www  .  ja v a  2s  . c o m
            jdbcTemplate.execute(indexes.get(idx).toString());
        } catch (DataAccessException e) {
            LOG.error("[{}] Could not create index", domain, e);
        }
    }

    LOG.debug("Indexes created");
}

From source file:org.gumtree.app.runtime.loader.PropertiesLoader.java

private Map<String, String> convertPropertiesToMap(Properties properties) {
    Map<String, String> map = new TreeMap<String, String>();
    for (String key : properties.stringPropertyNames()) {
        map.put(key, properties.getProperty(key));
    }/* ww w  . j  a v  a  2  s .  c om*/
    return map;
}

From source file:org.codice.ddf.platform.http.proxy.HttpProxyTest.java

@Test
public void testLoadProperties() throws IOException {
    HttpProxyService httpProxyService = mock(HttpProxyService.class);
    HttpProxy httpProxy = new HttpProxy(httpProxyService);
    Properties properties = httpProxy.getProperties();
    assertThat(0, is(properties.stringPropertyNames().size()));
}

From source file:org.commonjava.indy.stats.IndyDeprecatedApis.java

public IndyDeprecatedApis(Properties props) {
    this.props = props;

    Float minVersion = 0f;//from   w  w w .  j  a  v  a  2  s . com

    Set<String> keys = props.stringPropertyNames();
    for (String key : keys) {
        DeprecatedApiEntry et;
        String value = props.getProperty(key);

        Float startVersion;
        Float endVersion;

        if (key.indexOf(",") >= 0) // range
        {
            key = key.replaceAll("[\\[|\\]]", ""); // strip off square brackets if present
            String[] kv = key.split(",");
            startVersion = Float.parseFloat(kv[0].trim());
            endVersion = Float.parseFloat(kv[1].trim());
            et = new DeprecatedApiEntry(new FloatRange(startVersion, endVersion), value);
        } else {
            endVersion = Float.parseFloat(key.trim());
            et = new DeprecatedApiEntry(endVersion, value);
        }

        // Calculate minApiVersion
        if (et.isOff()) {
            minVersion = endVersion + 0.1f;
        }
        deprecatedApis.add(et);
    }

    minApiVersion = minVersion.toString();

    logger.debug("Parsed deprecatedApis:{}, minApiVersion:{}", deprecatedApis, minApiVersion);
}

From source file:de.codesourcery.jasm16.ide.WorkspaceConfig.java

protected void loadConfig() throws IOException {
    boolean success = false;
    if (configFile.exists()) {
        try {/* w  w w  .  j av  a 2s.  c o  m*/
            final Properties props = loadPropertiesFile(configFile);
            for (String key : props.stringPropertyNames()) {
                configProperties.put(key, props.getProperty(key));
            }
            success = true;
        } catch (IOException e) {
            LOG.error("loadConfiguration(): Failed to load workspace configuration");
        }
    }

    if (!success) {
        configProperties.clear();
        configProperties.putAll(createDefaultConfiguration());
        saveConfiguration();
    }
}

From source file:de.tud.inf.db.sparqlytics.bench.LDBCBenchmark.java

public LDBCBenchmark() {
    globalVariables = new HashMap<>();
    Properties systemProperties = System.getProperties();
    for (String name : systemProperties.stringPropertyNames()) {
        globalVariables.put(name, systemProperties.getProperty(name));
    }/*from w ww  . j  a v a2 s  . com*/
}

From source file:org.sakaiproject.component.app.help.DefaultGlossary.java

/**
 * initialize glossary/*from  w w w .  j  a  v  a  2s  .  c  om*/
 */
protected void init() {
    URL glossaryFile = this.getClass().getResource(getFile());
    Properties glossaryTerms = new Properties();
    try {
        glossaryTerms.load(glossaryFile.openStream());

        for (String term : glossaryTerms.stringPropertyNames()) {
            glossary.put(term.toLowerCase(),
                    new GlossaryEntryBean(term.toLowerCase(), glossaryTerms.getProperty(term)));
        }
        initialized = true;
    } catch (IOException e) {
        logger.error(e);
    }
}