List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:Main.java
public static Map<String, String> propertiesAsMap(Properties properties) { Set<Entry<Object, Object>> entries = properties.entrySet(); Map<String, String> responseMap = new HashMap<String, String>(); for (Entry<Object, Object> entry : entries) { responseMap.put((String) entry.getKey(), (String) entry.getValue()); }/*from w w w. j a v a 2s . c om*/ return responseMap; }
From source file:Main.java
public static Map<String, String> convert(Properties props) { Map<String, String> _result = new HashMap<String, String>(); Set<Entry<Object, Object>> propsSet = props.entrySet(); for (Entry<Object, Object> p : propsSet) { Object value = p.getValue(); if (value == null) { _result.put(p.getKey().toString(), null); } else {//from w w w. j a v a 2 s . co m _result.put(p.getKey().toString(), value.toString()); } } return _result; }
From source file:com.enonic.cms.framework.util.PropertiesUtil.java
/** * Return a subset of properties.//from ww w .jav a 2 s .co m */ public static Properties getSubSet(final Properties props, final String base) { Properties sub = new Properties(); for (Map.Entry entry : props.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); if (key.startsWith(base)) { sub.setProperty(key.substring(base.length()), value); } } return sub; }
From source file:io.fabric8.maven.enricher.fabric8.DocLinkEnricher.java
/** * Replaces all text of the form <code>${foo}</code> with the value in the properties object */// ww w. j a v a2 s . com protected static String replaceProperties(String text, Properties properties) { Set<Map.Entry<Object, Object>> entries = properties.entrySet(); for (Map.Entry<Object, Object> entry : entries) { Object key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { String pattern = "${" + key + "}"; text = StringUtils.replace(text, pattern, value.toString()); } } return text; }
From source file:org.apache.ofbiz.base.start.StartupCommandUtil.java
private static final Map<String, String> populateMapFromProperties(final Properties properties) { return properties.entrySet().stream().collect(Collectors.toMap(entry -> String.valueOf(entry.getKey()), entry -> String.valueOf(entry.getValue()))); }
From source file:io.servicecomb.foundation.common.utils.Log4jUtils.java
private static String genFileContext(List<Resource> resList, Properties properties) throws IOException { List<Entry<Object, Object>> entryList = properties.entrySet().stream() .sorted(new Comparator<Entry<Object, Object>>() { @Override/*from ww w . j av a 2s . c om*/ public int compare(Entry<Object, Object> o1, Entry<Object, Object> o2) { return o1.getKey().toString().compareTo(o2.getKey().toString()); } }).collect(Collectors.toList()); StringBuilder sb = new StringBuilder(); for (Resource res : resList) { sb.append("#").append(res.getURL().getPath()).append("\n"); } for (Entry<Object, Object> entry : entryList) { sb.append(entry.getKey()).append("=").append(entry.getValue()).append("\n"); } return sb.toString(); }
From source file:PropertiesUtil.java
public static Map getByValue(Properties properties, String value) { Map map = new HashMap(); Iterator iter = properties.entrySet().iterator(); do {/* ww w . j a v a 2s . c o m*/ if (!iter.hasNext()) break; java.util.Map.Entry entry = (java.util.Map.Entry) iter.next(); if (entry.getValue().equals(value)) map.put(entry.getKey(), entry.getValue()); } while (true); return map; }
From source file:Main.java
/** * Convert a {@link Properties} into a {@link HashMap}.<br /> * @param properties//from w w w . j ava 2s .c o m * the properties to convert. * @return the map with the same objects. */ public static Map<String, String> convertPropertiesToMap(final Properties properties) { Objects.requireNonNull(properties); final Map<String, String> map = new HashMap<>(properties.size()); for (final Entry<Object, Object> property : properties.entrySet()) { // Properties are always Strings (left as Object in JDK for backward compatibility purposes) map.put((String) property.getKey(), (String) property.getValue()); } return map; }
From source file:com.net2plan.internal.CommandLineParser.java
/** * Gets the current parameters from the user-specified ones, taking default * values for unspecified parameters./*w w w. ja v a2 s . c om*/ * * @param defaultParameters Default parameters (key, value, and description) * @param inputParameters User parameters (key, value) * @return Current parameters (key, value) * @since 0.2.2 */ public static Map<String, String> getParameters(List<Triple<String, String, String>> defaultParameters, Properties inputParameters) { return getParameters(defaultParameters, inputParameters == null ? null : inputParameters.entrySet()); }
From source file:gobblin.util.PropertiesUtils.java
/** * Converts a {@link Properties} object to a {@link Map} where each key is a {@link String}. */// www .j a v a2 s . c o m public static Map<String, ?> propsToStringKeyMap(Properties properties) { ImmutableMap.Builder<String, Object> mapBuilder = ImmutableMap.builder(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { mapBuilder.put(entry.getKey().toString(), entry.getValue()); } return mapBuilder.build(); }