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:net.sf.antcontrib.net.httpclient.PostMethodTask.java

public void setParameters(File parameters) {
    PostMethod post = getPostMethod();//w ww.  j  a v  a 2 s .  c  om
    Properties p = new Properties();
    Iterator it = p.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Map.Entry) it.next();
        post.addParameter(entry.getKey().toString(), entry.getValue().toString());
    }
}

From source file:pt.webdetails.browserid.spring.authorities.DomainWhitelistAuthoritiesService.java

/**
 * //from w w  w.  j  a v a2  s  .co  m
 * @param properties entries in the form &lt;domain&gt;=&lt;roleName&gt;[,&ltroleName&gt;]*&nbsp;
 */
public void setDomainMap(Properties properties) {
    Map<String, GrantedAuthority[]> domainMap = new HashMap<String, GrantedAuthority[]>(properties.size());
    for (Entry<Object, Object> entry : properties.entrySet()) {

        String domain = (String) entry.getKey();
        String authoritiesAsText = (String) entry.getValue();

        //parse authorities, may return empty
        String[] roles = StringUtils.commaDelimitedListToStringArray(authoritiesAsText);
        GrantedAuthority[] authorities = new GrantedAuthority[roles.length];
        int i = 0;
        for (String role : roles) {
            authorities[i++] = new GrantedAuthorityImpl(role);
        }

        domainMap.put(domain, authorities);

    }
    this.domainMap = domainMap;
}

From source file:org.apache.hupa.server.guice.ServerModulTest.java

@Test
public void testLoadDemoProperties() throws Exception {
    File tmp = File.createTempFile("foo", ".properties");
    tmp.deleteOnExit();//from   w  ww .  ja v  a  2 s . c  om
    Properties p = MockConstants.mockProperties;
    Collection<String> lines = new ArrayList<String>();
    for (Entry<Object, Object> e : p.entrySet()) {
        lines.add(e.getKey() + " = " + e.getValue());
    }
    FileUtils.writeLines(tmp, lines);

    System.setProperty(GuiceListener.SYS_PROP_CONFIG_FILE, tmp.getAbsolutePath());
    p = new GuiceListener().loadProperties();
    Assert.assertNotNull(p);
    Assert.assertEquals(MockConstants.mockSettings.getInboxFolderName(), p.get("DefaultInboxFolder"));
    Assert.assertEquals(MockConstants.mockSettings.getTrashFolderName(), p.get("DefaultTrashFolder"));
    Assert.assertEquals(MockConstants.mockSettings.getSentFolderName(), p.get("DefaultSentFolder"));
    System.clearProperty(GuiceListener.SYS_PROP_CONFIG_FILE);
}

From source file:org.imsglobal.basiclti.consumersecret.impl.PropertiesConsumerSecretServiceImpl.java

public List<OauthConsumerSecret> searchOauthConsumerSecrets() {
    Properties properties = getPropertiesInternal();
    List<OauthConsumerSecret> rv = new ArrayList<OauthConsumerSecret>(properties.size());
    for (Entry<Object, Object> entry : properties.entrySet()) {
        String consumerSecret = ObjectUtils.toString(entry.getValue());
        String consumerKey = ObjectUtils.toString(entry.getKey());
        if (StringUtils.isNotEmpty(consumerKey) && StringUtils.isNotEmpty(consumerSecret)) {
            rv.add(new OauthConsumerSecret(consumerKey, consumerSecret));
        }//from w w w  . j  ava2s.co m
    }
    return rv;
}

From source file:io.devpage.util.ReadMethodPerformanceInterceptorConfig.java

@Override
public void afterPropertiesSet() throws Exception {
    Properties prop = new Properties();
    InputStream in = ReadMethodPerformanceInterceptorConfig.class.getResourceAsStream("/p9e.properties");
    prop.load(in);/*from ww w. ja va  2s .co m*/
    Iterator<Entry<Object, Object>> itr = prop.entrySet().iterator();
    while (itr.hasNext()) {
        Entry<Object, Object> e = (Entry<Object, Object>) itr.next();
        if (e.getKey().toString().equalsIgnoreCase(matckKey)) {
            matchNameLike = e.getValue().toString();
            break;
        }
    }
    if (matchNameLike == null) {
        throw new Exception("?matchMethodClassNameLike?,??");
    }
}

From source file:org.apache.kylin.common.BackwardCompatibilityConfig.java

public Properties check(Properties props) {
    Properties result = new Properties();
    for (Entry<Object, Object> kv : props.entrySet()) {
        result.setProperty(check((String) kv.getKey()), (String) kv.getValue());
    }//from ww w. j  a va2s . com
    return result;
}

From source file:org.apache.archiva.redback.integration.mail.MailGeneratorTest.java

@Before
public void setUp() throws Exception {
    CacheManager.getInstance().clearAll();
    super.setUp();

    jdoFactory.setPassword("");

    jdoFactory.setProperty("org.jpox.transactionIsolation", "READ_COMMITTED"); //$NON-NLS-1$ //$NON-NLS-2$

    jdoFactory.setProperty("org.jpox.poid.transactionIsolation", "READ_COMMITTED"); //$NON-NLS-1$ //$NON-NLS-2$

    jdoFactory.setProperty("org.jpox.autoCreateSchema", "true"); //$NON-NLS-1$ //$NON-NLS-2$

    Properties properties = jdoFactory.getProperties();

    for (Entry<Object, Object> entry : properties.entrySet()) {
        System.setProperty((String) entry.getKey(), (String) entry.getValue());
    }/*from   ww  w. j av a 2s .  c om*/

    SchemaTool.createSchemaTables(
            new URL[] { getClass().getResource("/org/apache/archiva/redback/keys/jdo/package.jdo") }, //$NON-NLS-1$
            new URL[] {}, null, false, null);

    log.info("jdoFactory driverName {} ", jdoFactory.getDriverName());

    PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();

    assertNotNull(pmf);

    PersistenceManager pm = pmf.getPersistenceManager();

    pm.close();

}

From source file:com.progress.singapore.datadirect.jdbc.demo.saleskit.common.StaticMessageSource.java

public void addMessages(Properties messages, Locale locale) {
    Assert.notNull(messages, "Messages Map must not be null");
    for (Entry<Object, Object> entry : messages.entrySet()) {
        addMessage((String) entry.getKey(), locale, (String) entry.getValue());
    }//from  w  w w .j a  va  2s .c  o  m
}

From source file:com.amalto.core.save.generator.HazelcastAutoIncrementGenerator.java

@Override
public synchronized void init() {
    CONFIGURATION.evictAll();//www  . j av a2  s  .co  m
    try {
        ItemPOJOPK pk = new ItemPOJOPK(DC, AUTO_INCREMENT, IDS);
        ItemPOJO itempojo = ItemPOJO.load(pk);
        if (itempojo == null) {
            LOGGER.info("Could not load configuration from database, use default configuration.");
        } else {
            String xml = itempojo.getProjectionAsString();
            if (StringUtils.isNotBlank(xml)) {
                Properties properties = Util.convertAutoIncrement(xml);
                for (Entry<Object, Object> entry : properties.entrySet()) {
                    String key = entry.getKey().toString();
                    CONFIGURATION.lock(key);
                    try {
                        CONFIGURATION.put(key, Long.valueOf(entry.getValue().toString()));
                    } finally {
                        CONFIGURATION.unlock(key);
                    }
                }
            }
        }
        WAS_INIT_CALLED.set(1);
    } catch (Exception e) {
        LOGGER.error(e.getLocalizedMessage(), e);
    }
}

From source file:org.gvnix.dynamic.configuration.roo.addon.config.PropertiesDynamicConfiguration.java

/**
 * {@inheritDoc}// ww w. j av  a  2s.  c  o m
 */
public DynPropertyList read() {

    DynPropertyList dynProps = new DynPropertyList();

    try {

        // Get the properties file path
        MutableFile file = getFile();

        // If managed file not exists, nothing to do
        if (file != null) {

            Properties props = new Properties();
            props.load(file.getInputStream());
            for (Entry<Object, Object> prop : props.entrySet()) {

                dynProps.add(new DynProperty(prop.getKey().toString(), prop.getValue().toString()));
            }
        }
    } catch (IOException ioe) {

        throw new IllegalStateException(ioe);
    }

    return dynProps;
}