List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:org.apache.hadoop.hive.hwi.query.QueryStore.java
/** * Properties specified in hive-default.xml override the properties * specified in jpox.properties./*from w ww . j a v a 2 s. c o m*/ */ private static Properties getDataSourceProps(Configuration conf) { Properties prop = new Properties(); Iterator<Map.Entry<String, String>> iter = conf.iterator(); while (iter.hasNext()) { Map.Entry<String, String> e = iter.next(); if (e.getKey().contains("datanucleus") || e.getKey().contains("jdo")) { Object prevVal = prop.setProperty(e.getKey(), conf.get(e.getKey())); if (l4j.isDebugEnabled() && !e.getKey().equals(HiveConf.ConfVars.METASTOREPWD.varname)) { l4j.debug("Overriding " + e.getKey() + " value " + prevVal + " from jpox.properties with " + e.getValue()); } } } if (l4j.isDebugEnabled()) { for (Entry<Object, Object> e : prop.entrySet()) { if (!e.getKey().equals(HiveConf.ConfVars.METASTOREPWD.varname)) { l4j.debug(e.getKey() + " = " + e.getValue()); } } } return prop; }
From source file:com.streamsets.datacollector.cluster.ClusterProviderImpl.java
private static List<URL> findJars(String name, URLClassLoader cl, @Nullable String stageClazzName) throws IOException { Properties properties = readDataCollectorProperties(cl); List<String> blacklist = new ArrayList<>(); for (Map.Entry entry : properties.entrySet()) { String key = (String) entry.getKey(); if (stageClazzName != null && key.equals(CLUSTER_MODE_JAR_BLACKLIST + stageClazzName)) { String value = (String) entry.getValue(); blacklist.addAll(Splitter.on(",").trimResults().omitEmptyStrings().splitToList(value)); } else if (key.equals(CLUSTER_MODE_JAR_BLACKLIST + ALL_STAGES)) { String value = (String) entry.getValue(); blacklist.addAll(Splitter.on(",").trimResults().omitEmptyStrings().splitToList(value)); }//from w ww .ja v a 2s. c o m } if (IS_TRACE_ENABLED) { LOG.trace("Blacklist for '{}': '{}'", name, blacklist); } List<URL> urls = new ArrayList<>(); for (URL url : cl.getURLs()) { if (blacklist.isEmpty()) { urls.add(url); } else { if (exclude(blacklist, FilenameUtils.getName(url.getPath()))) { LOG.trace("Skipping '{}' for '{}' due to '{}'", url, name, blacklist); } else { urls.add(url); } } } return urls; }
From source file:com.gnizr.db.dao.GnizrBasicDataSource.java
/** * Sets the connection property by reading configurations from the input <code>Properties</code> * object. When reading configurations from <code>props</code>, key/value pairs in <code>props</code> * are assumed to be of type <code>String</code>. The key is the name of the property, and the value * is the value to be set for that property. * @param props an instantiated properties object -- keys are the connection property names, * and values are the values to be set for the corresponding connection properties. *//*from w w w . j a va 2s . c o m*/ @SuppressWarnings("unchecked") public void setConnectionProperties(Properties props) { for (Iterator iter = props.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); addConnectionProperty((String) entry.getKey(), (String) entry.getValue()); } }
From source file:gobblin.util.ConfigUtils.java
/** * Convert all the keys that start with a <code>prefix</code> in {@link Properties} to a {@link Config} instance. * * <p>//w ww . j a v a 2 s . c om * This method will throw an exception if (1) the {@link Object#toString()} method of any two keys in the * {@link Properties} objects returns the same {@link String}, or (2) if any two keys are prefixes of one another, * see the Java Docs of {@link ConfigFactory#parseMap(Map)} for more details. * </p> * * @param properties the given {@link Properties} instance * @param prefix of keys to be converted * @return a {@link Config} instance */ public static Config propertiesToConfig(Properties properties, Optional<String> prefix) { Set<String> blacklistedKeys = new HashSet<>(); if (properties.containsKey(GOBBLIN_CONFIG_BLACKLIST_KEYS)) { blacklistedKeys = new HashSet<>(Splitter.on(',').omitEmptyStrings().trimResults() .splitToList(properties.getProperty(GOBBLIN_CONFIG_BLACKLIST_KEYS))); } Set<String> fullPrefixKeys = findFullPrefixKeys(properties, prefix); ImmutableMap.Builder<String, Object> immutableMapBuilder = ImmutableMap.builder(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { String entryKey = entry.getKey().toString(); if (StringUtils.startsWith(entryKey, prefix.or(StringUtils.EMPTY)) && !blacklistedKeys.contains(entryKey)) { if (fullPrefixKeys.contains(entryKey)) { entryKey = sanitizeFullPrefixKey(entryKey); } else if (entryKey.endsWith(STRIP_SUFFIX)) { throw new RuntimeException("Properties are not allowed to end in " + STRIP_SUFFIX); } immutableMapBuilder.put(entryKey, entry.getValue()); } } return ConfigFactory.parseMap(immutableMapBuilder.build()); }
From source file:com.splicemachine.derby.utils.SpliceAdmin.java
/** * Tag each property value with a 'type'. The structure of the map changes from: * {key --> value}//from ww w.ja v a 2 s . c o m * to: * {key --> [value, type]} * * @param props Map of properties to tag with type * @param type Type of property (JVM, SERVICE, DATABASE, APP, etc.) * @param derbySpliceOnly If true, only include properties with keys that start with "derby" or "splice". * @return the new map of typed properties */ private static Properties addTypeToProperties(Properties props, String type, boolean derbySpliceOnly) { Properties typedProps = new Properties(); if (props != null) { for (Entry<Object, Object> objectObjectEntry : props.entrySet()) { Entry prop = (Entry) objectObjectEntry; String key = (String) prop.getKey(); if (key == null) continue; if (derbySpliceOnly) { String lowerKey = key.toLowerCase(); if (!lowerKey.startsWith("derby") && !lowerKey.startsWith("splice")) { continue; } } String[] typedValue = new String[2]; typedValue[0] = (String) prop.getValue(); typedValue[1] = type; typedProps.put(key, typedValue); } } return typedProps; }
From source file:net.oauth.v2.example.provider.core.SampleOAuth2Provider.java
public static synchronized void loadConsumers() throws IOException { Properties p = consumerProperties; if (p == null) { p = new Properties(); String resourceName = "" + SampleOAuth2Provider.class.getPackage().getName().replace(".", "/") + "/provider.properties"; URL resource = SampleOAuth2Provider.class.getClassLoader().getResource(resourceName); if (resource == null) { throw new IOException("resource not found: " + resourceName); }//from ww w . ja v a 2 s . c om InputStream stream = resource.openStream(); try { p.load(stream); } finally { stream.close(); } } consumerProperties = p; // for each entry in the properties file create a OAuthConsumer for (Map.Entry prop : p.entrySet()) { String consumer_key = (String) prop.getKey(); // make sure it's key not additional properties if (!consumer_key.contains(".")) { String consumer_secret = (String) prop.getValue(); if (consumer_secret != null) { String consumer_description = (String) p.getProperty(consumer_key + ".description"); String consumer_callback_url = (String) p.getProperty(consumer_key + ".callbackURL"); // Create OAuthConsumer w/ key and secret OAuth2Client client = new OAuth2Client(consumer_callback_url, consumer_key, consumer_secret); client.setProperty("name", consumer_key); client.setProperty("description", consumer_description); ALL_CLIENTS.put(consumer_key, client); } } } }
From source file:com.kuzumeji.platform.standard.SystemHelperTest.java
@Test public final void testSystem() { final Properties property = System.getProperties(); for (final Entry<Object, Object> entry : property.entrySet()) { LOG.debug("{} : {}", entry.getKey(), entry.getValue()); }//from w w w . j av a 2 s . c o m }
From source file:org.apache.hadoop.hbase.util.TestShowProperties.java
@Test public void testShowProperty() { Properties properties = System.getProperties(); for (java.util.Map.Entry<Object, Object> prop : properties.entrySet()) { LOG.info("Property " + prop.getKey() + "=" + prop.getValue()); }//w w w. j a v a 2 s . c om }
From source file:org.cloudfoundry.reconfiguration.play.StandardPropertySetter.java
private void setProperties(Properties properties) { for (Map.Entry<Object, Object> entry : properties.entrySet()) { System.setProperty(entry.getKey().toString(), entry.getValue().toString()); }//from ww w . j a v a 2 s.c o m }
From source file:eu.larkc.csparql.common.config.Config.java
public void setConfigParams(Properties properties) { for (Entry<Object, Object> entry : properties.entrySet()) config.setProperty(entry.getKey().toString(), entry.getValue()); }