List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:aot.util.IOUtil.java
public static void logProperties(String name, Properties properties) { // log.info("Log properties '{}'", name); for (Map.Entry<Object, Object> prop : properties.entrySet()) { // log.info("{}: '{}'", prop.getKey(), prop.getValue()); }//from w ww .j a v a2s . c o m }
From source file:Main.java
public static Map<String, String> convertProperties2Map(Properties properties) { if (properties == null) { return null; }//from ww w . j a v a 2s .c om Map<String, String> map = new LinkedHashMap<String, String>(); Set<Entry<Object, Object>> entrySet = properties.entrySet(); for (Entry<Object, Object> entry : entrySet) { map.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } return map; }
From source file:com.alibaba.rocketmq.storm.internal.tools.ConfigUtils.java
public static Config init(String configFile) { Config config = new Config(); //1.//from w w w. ja v a2s .com Properties prop = ConfigUtils.getResource(configFile); for (Entry<Object, Object> entry : prop.entrySet()) { config.put((String) entry.getKey(), entry.getValue()); } //2. String topic = (String) config.get(ConfigUtils.CONFIG_TOPIC); String consumerGroup = (String) config.get(ConfigUtils.CONFIG_CONSUMER_GROUP); String topicTag = (String) config.get(ConfigUtils.CONFIG_TOPIC_TAG); //Integer pullBatchSize = (Integer) config.get(ConfigUtils.CONFIG_PREFETCH_SIZE); Integer pullBatchSize = Integer.parseInt((String) config.get(ConfigUtils.CONFIG_PREFETCH_SIZE)); RocketMQConfig mqConfig = new RocketMQConfig(consumerGroup, topic, topicTag); if (pullBatchSize != null && pullBatchSize > 0) { mqConfig.setPullBatchSize(pullBatchSize); } boolean ordered = BooleanUtils .toBooleanDefaultIfNull(Boolean.valueOf((String) (config.get("rocketmq.spout.ordered"))), false); mqConfig.setOrdered(ordered); config.put(CONFIG_ROCKETMQ, mqConfig); return config; }
From source file:com.tansun.rocketmq.connect.tools.ConfigUtils.java
public static Map<Object, Object> init(String configFile) { Map<Object, Object> config = new HashMap<>(); //1./* www . java2 s. c o m*/ Properties prop = ConfigUtils.getResource(configFile); for (Entry<Object, Object> entry : prop.entrySet()) { config.put((String) entry.getKey(), entry.getValue()); } //2. String namesrvAddr = (String) config.get(ConfigUtils.CONFIG_NAMESRV_ADDR); String topic = (String) config.get(ConfigUtils.CONFIG_TOPIC); String consumerGroup = (String) config.get(ConfigUtils.CONFIG_CONSUMER_GROUP); String topicTag = (String) config.get(ConfigUtils.CONFIG_TOPIC_TAG); //Integer pullBatchSize = (Integer) config.get(ConfigUtils.CONFIG_PREFETCH_SIZE); Integer pullBatchSize = Integer.parseInt((String) config.get(ConfigUtils.CONFIG_PREFETCH_SIZE)); RocketMQConfig mqConfig = new RocketMQConfig(namesrvAddr, consumerGroup, topic, topicTag); if (pullBatchSize != null && pullBatchSize > 0) { mqConfig.setPullBatchSize(pullBatchSize); } boolean ordered = BooleanUtils.toBooleanDefaultIfNull( Boolean.valueOf((String) (config.get("rocketmq.elasticsearch.ordered"))), false); mqConfig.setOrdered(ordered); config.put(CONFIG_ROCKETMQ, mqConfig); return config; }
From source file:io.fluo.stress.trie.NumberIngest.java
private static void loadConfig(JobConf conf, Properties props) { for (Entry<Object, Object> entry : props.entrySet()) { conf.set((String) entry.getKey(), (String) entry.getValue()); }//from w w w. j a v a2 s. c o m }
From source file:com.microsoft.windowsazure.Configuration.java
public static Configuration load() throws IOException { final Configuration config = new Configuration(); final InputStream stream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("META-INF/com.microsoft.windowsazure.properties"); if (stream != null) { final Properties properties = new Properties(); properties.load(stream);/*from w w w. ja va 2 s. c om*/ for (Map.Entry<Object, Object> key : properties.entrySet()) { config.setProperty(key.getKey().toString(), key.getValue()); } } return config; }
From source file:com.asakusafw.testdriver.tools.runner.BatchTestCollector.java
private static Map<String, String> toMap(Properties p) { assert p != null; Map<String, String> results = new TreeMap<>(); for (Map.Entry<Object, Object> entry : p.entrySet()) { results.put((String) entry.getKey(), (String) entry.getValue()); }//w ww . j a v a 2s. c om return results; }
From source file:org.apache.ode.dao.jpa.hibernate.HibernateUtil.java
private static void addEntries(String prefix, Properties odeConfig, Map props) { if (odeConfig != null) { for (Map.Entry me : odeConfig.entrySet()) { String key = (String) me.getKey(); if (key.startsWith(prefix)) { String jpaKey = key.substring(prefix.length() - 1); String val = (String) me.getValue(); if (val == null || val.trim().length() == 0) { props.remove(jpaKey); } else { props.put(jpaKey, me.getValue()); }/*w ww .jav a 2 s .c o m*/ } else if (key.startsWith("hibernate")) { props.put(key, me.getValue()); } } } }
From source file:Main.java
public static Map<String, String> toMap(Properties properties) { if (properties == null) { return new HashMap<String, String>(0); }//w ww. j a v a2 s. co m Map<String, String> map = new HashMap<String, String>(properties.size()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { map.put(entry.getKey().toString(), entry.getValue().toString()); } return map; }
From source file:org.apache.kylin.source.kafka.util.KafkaClient.java
private static Properties constructDefaultKafkaConsumerProperties(String brokers, String consumerGroup, Properties properties) { Properties props = new Properties(); if (properties != null) { for (Map.Entry entry : properties.entrySet()) { props.put(entry.getKey(), entry.getValue()); }//from w w w. java2 s .c o m } props.put("bootstrap.servers", brokers); props.put("key.deserializer", StringDeserializer.class.getName()); props.put("value.deserializer", StringDeserializer.class.getName()); props.put("group.id", consumerGroup); props.put("enable.auto.commit", "false"); return props; }