Example usage for java.util Properties entrySet

List of usage examples for java.util Properties entrySet

Introduction

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

Prototype

@Override
    public Set<Map.Entry<Object, Object>> entrySet() 

Source Link

Usage

From source file:hudson.plugins.sonar.SonarRunner.java

/**
 * Visibility of a method has been relaxed for tests.
 *///ww w.  j  a va  2s .c  o m
ArgumentListBuilder buildCmdLine(BuildListener listener, SonarRunnerBuilder conf)
        throws IOException, InterruptedException {
    ArgumentListBuilder args = new ArgumentListBuilder();
    // Java
    args.add(getJavaExecutable(listener));
    // Java options
    args.addTokenized(envVars.expand(conf.getJavaOpts()));
    // Classpath
    args.add("-cp");
    args.add(runnerJar.getRemote() + getClasspathDelimiter() + bootstrapperJar.getRemote());
    // Main class
    args.add("org.sonar.runner.Main");
    // Server properties
    SonarInstallation si = conf.getSonarInstallation();
    if (si != null) {
        appendArg(args, "sonar.jdbc.driver", si.getDatabaseDriver());
        appendArg(args, "sonar.jdbc.url", si.getDatabaseUrl()); // TODO can be masked
        appendMaskedArg(args, "sonar.jdbc.username", si.getDatabaseLogin());
        appendMaskedArg(args, "sonar.jdbc.password", si.getDatabasePassword());
        appendArg(args, "sonar.host.url", si.getServerUrl());
    }
    // Path to project properties
    appendArg(args, "project.settings", conf.getProject());

    // Additional properties
    Properties p = new Properties();
    p.load(new ByteArrayInputStream(conf.getProperties().getBytes()));
    for (Entry<Object, Object> entry : p.entrySet()) {
        args.add("-D" + entry.getKey() + "=" + entry.getValue().toString());
    }
    return args;
}

From source file:ch.nydi.spring.config.SystemPropertiesFactoryBean.java

@Override
protected Properties createProperties() throws IOException {
    final Properties originalProperties = super.createProperties();
    final Properties propertiesReplaced = new Properties();

    final PropertyVariableParser propertyParser = new PropertyVariableParser();

    for (final Map.Entry<Object, Object> entry : originalProperties.entrySet()) {
        propertiesReplaced.put(entry.getKey(), propertyParser.replaceVariables((String) entry.getValue()));
    }// w  ww. j ava  2s. c om

    if (propagateToSystemProperties) {
        final Properties systemProperties = System.getProperties();
        systemProperties.putAll(propertiesReplaced);
        System.setProperties(systemProperties);
    }

    return propertiesReplaced;
}

From source file:energy.usef.core.workflow.step.WorkflowStepLoader.java

private void loadPbcConfig() {
    try {/*w  w w  . j a va 2s.  c  o  m*/
        Map<String, Class<WorkflowStep>> newlyMappedWorkflowSteps = new HashMap<>();
        File pbcCatalogInConfig = new File(AbstractConfig.getConfigurationFolder() + FILE_PBC_CATALOG);
        InputStream inputStream;
        if (pbcCatalogInConfig.exists() && !pbcCatalogInConfig.isDirectory()) {
            LOGGER.info("Using PBC catalog file {}.", pbcCatalogInConfig.getAbsolutePath());
            inputStream = new FileInputStream(pbcCatalogInConfig);
        } else {
            LOGGER.warn("PBC catalog  file {} not found, using default.", pbcCatalogInConfig.getAbsolutePath());
            inputStream = this.getClass().getClassLoader().getResourceAsStream(FILE_PBC_CATALOG);
        }
        // load the properties
        Properties properties = new Properties();
        properties.load(inputStream);
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            if (StringUtils.isEmpty((String) entry.getValue())) {
                LOGGER.error("Invalid configuration for WorkflowStep {}, class name can not be empty.",
                        entry.getKey());
            }
            Class<WorkflowStep> clazz = (Class<WorkflowStep>) Class.forName((String) entry.getValue());

            if (!hasWorkflowStepInterface(clazz)) {
                LOGGER.error(
                        "Keeping old configuration, error occurred: Class [{}] does not implement WorkflowStep interface.",
                        clazz);
                return;
            }
            newlyMappedWorkflowSteps.put((String) entry.getKey(), clazz);
        }
        // no exceptions occurred, override current map
        this.workflowStepsMap = newlyMappedWorkflowSteps;
        newlyMappedWorkflowSteps.forEach(
                (name, clazz) -> LOGGER.info("Successfully Loaded Step [{}] with Class [{}]", name, clazz));
    } catch (ClassNotFoundException | IOException e) {
        LOGGER.error("Keeping old configuration, exception occurred: " + e.getMessage(), e);
    }
}

From source file:org.vbossica.springbox.config.PropertyPlaceholderDebuggingConfigurer.java

@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
        throws BeansException {
    super.processProperties(beanFactoryToProcess, props);

    if (log.isDebugEnabled()) {
        log.debug("Processing properties");
        for (Map.Entry<Object, Object> entry : props.entrySet()) {
            log.debug("{}: '{}'", entry.getKey(), entry.getValue());
        }/*from   w ww . jav  a 2s  .c om*/
    }
}

From source file:jp.tricreo.schemagenerator.domain.lifecycle.repository.impl.DataSourceRepositoryInProperties.java

/**
 * {@link Properties}????????{@link Map}???
 * /*  w  w w  . j  a  v a 2 s . c  o  m*/
 * @param properties {@link Properties}
 * @return ?????{@link Map}
 */
private Map<String, DataSource> parseProperties(Properties properties) {
    Validate.notNull(properties);
    Map<String, DataSource> dataSourceMap = Maps.newHashMap();
    for (Entry<Object, Object> propertiesEntry : properties.entrySet()) {
        String key = (String) propertiesEntry.getKey();
        if (key.startsWith("dataSources.") == false) {
            continue;
        }
        String value = (String) propertiesEntry.getValue();
        String[] split = key.split("\\.");
        String identity = split[1];
        DataSource dataSource = getDataSoruceFromMap(dataSourceMap, identity);
        String propertyName = split[2];
        setProperty(dataSource, propertyName, value);
    }
    return dataSourceMap;
}

From source file:com.ibm.watson.developer_cloud.professor_languo.endpoints.AskAQuestionResource.java

/**
 * Read the credentials and urls from the properties
 * //from   w w w . ja va  2  s .  c o m
 * @param appProperties properties object to read from
 */
private void initialize(Properties appProperties) {

    logger.debug(appProperties.entrySet().toString());

    // read credentials and endpoint urls
    username = appProperties.getProperty(RetrieveAndRankConstants.USERNAME, "");
    password = appProperties.getProperty(RetrieveAndRankConstants.PASSWORD, "");
    final String retrieve_and_rank_endpoint = appProperties.getProperty(RetrieveAndRankConstants.RNR_ENDPOINT,
            "");
    ranker_id = appProperties.getProperty(RetrieveAndRankConstants.RANKER_ID, "");
    ranker_url = retrieve_and_rank_endpoint + RetrieveAndRankConstants.RNR_ENDPOINT_VERSION
            + RetrieveAndRankConstants.RANKERS_URL + ranker_id + RetrieveAndRankConstants.RERANK_URL;
    checkStrings(username, password, retrieve_and_rank_endpoint, ranker_id, ranker_url);

    // connect the client
    client = RankerCreationUtil.createHttpClient(AuthScope.ANY,
            new UsernamePasswordCredentials(username, password));
}

From source file:io.smartspaces.configuration.FileSystemConfigurationStorageManager.java

/**
 * Load the contents of a configuration file into a configuration.
 *
 * @param configuration//from  w  w  w .ja  v a 2s .  co m
 *          the configuration to place values in
 * @param configFile
 *          the file to load into the configuration
 */
private void loadConfigFile(Configuration configuration, File configFile) {
    InputStream in = null;
    try {
        log.debug(String.format("Loading config file %s", configFile));

        in = new FileInputStream(configFile);

        Properties configProperties = new Properties();
        configProperties.load(in);

        for (Entry<Object, Object> entry : configProperties.entrySet()) {
            configuration.setProperty(entry.getKey().toString(), entry.getValue().toString());
        }
    } catch (Exception e) {
        log.error("Could not load configuration", e);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (Exception e) {
                // Don't care.
            }
        }
    }
}

From source file:com.tacitknowledge.flip.spring.config.FeatureServiceHandlerParserTest.java

@Test
public void testFeatureServiceFactoryProperties() {
    BeanDefinition beanDefinition = context.getBeanDefinition("featureServiceFactory");

    // Test ContextProviders setup
    PropertyValue contextProvidersProperty = beanDefinition.getPropertyValues()
            .getPropertyValue("contextProviders");
    assertNotNull(contextProvidersProperty);
    assertTrue(contextProvidersProperty.getValue() instanceof List);
    List contextProvidersList = ((List) contextProvidersProperty.getValue());
    assertEquals(2, contextProvidersList.size());

    assertTrue(contextProvidersList.get(0) instanceof BeanDefinitionHolder);
    assertEquals(SystemPropertiesContextProvider.class.getName(),
            ((BeanDefinitionHolder) contextProvidersList.get(0)).getBeanDefinition().getBeanClassName());

    assertTrue(contextProvidersList.get(1) instanceof BeanReference);
    assertEquals("contextProviderBean", ((BeanReference) contextProvidersList.get(1)).getBeanName());

    // Test PropertyReaders setup
    PropertyValue propertyReadersProperty = beanDefinition.getPropertyValues()
            .getPropertyValue("propertyReaders");
    assertNotNull(propertyReadersProperty);
    assertTrue(propertyReadersProperty.getValue() instanceof List);
    List propertyReadersList = ((List) propertyReadersProperty.getValue());
    assertEquals(2, propertyReadersList.size());

    assertTrue(propertyReadersList.get(0) instanceof BeanDefinitionHolder);
    assertEquals(XmlPropertyReader.class.getName(),
            ((BeanDefinitionHolder) propertyReadersList.get(0)).getBeanDefinition().getBeanClassName());

    assertTrue(propertyReadersList.get(1) instanceof BeanReference);
    assertEquals("propertyReaderBean", ((BeanReference) propertyReadersList.get(1)).getBeanName());

    // Test properties setup
    PropertyValue propertiesProperty = beanDefinition.getPropertyValues().getPropertyValue("properties");
    assertNotNull(propertiesProperty);//  w w w  .  j  a  v  a 2  s  .  c o  m
    assertTrue(propertiesProperty.getValue() instanceof Properties);
    Properties properties = ((Properties) propertiesProperty.getValue());
    assertEquals(1, properties.size());

    for (Map.Entry entry : properties.entrySet()) {
        assertEquals("aa", ((TypedStringValue) entry.getKey()).getValue());
        assertEquals("bb", ((TypedStringValue) entry.getValue()).getValue());
    }
}

From source file:ca.ubc.ece.netsyslab.tagvalue.system.TaggingSystem.java

/**
 * Append the the parameters to the base URL and encode it to produce a URL
 * encoded string representation of it./*from  ww w  . j  a va2  s .c  om*/
 *
 * @param parameters
 * @return a URL enconded string
 * @throws UnsupportedEncodingException
 */
protected String buildURL(Properties parameters) throws UnsupportedEncodingException {
    StringBuffer parameterString = new StringBuffer();
    for (Map.Entry<Object, Object> entry : parameters.entrySet()) {
        parameterString.append(entry.getKey());
        parameterString.append("=");
        parameterString.append(URLEncoder.encode((String) entry.getValue(), "UTF-8"));
        parameterString.append("&");
    }
    return url + parameterString.toString();
}

From source file:com.icesoft.net.messaging.MessageServiceClient.java

private static void addMessageProperties(final Properties messageProperties, final Message message) {

    if (messageProperties == null) {
        return;//from www .  jav a2 s . c  om
    }
    Iterator _messageProperties = messageProperties.entrySet().iterator();
    while (_messageProperties.hasNext()) {
        Map.Entry _messageProperty = (Map.Entry) _messageProperties.next();
        Object _value = _messageProperty.getValue();
        if (_value instanceof Boolean) {
            message.setBooleanProperty((String) _messageProperty.getKey(), ((Boolean) _value).booleanValue());
        } else if (_value instanceof Byte) {
            message.setByteProperty((String) _messageProperty.getKey(), ((Byte) _value).byteValue());
        } else if (_value instanceof Double) {
            message.setDoubleProperty((String) _messageProperty.getKey(), ((Double) _value).doubleValue());
        } else if (_value instanceof Float) {
            message.setFloatProperty((String) _messageProperty.getKey(), ((Float) _value).floatValue());
        } else if (_value instanceof Integer) {
            message.setIntProperty((String) _messageProperty.getKey(), ((Integer) _value).intValue());
        } else if (_value instanceof Long) {
            message.setLongProperty((String) _messageProperty.getKey(), ((Long) _value).longValue());
        } else if (_value instanceof Short) {
            message.setShortProperty((String) _messageProperty.getKey(), ((Short) _value).shortValue());
        } else if (_value instanceof String) {
            message.setStringProperty((String) _messageProperty.getKey(), (String) _value);
        } else {
            message.setObjectProperty((String) _messageProperty.getKey(), _value);
        }
    }
}