List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:fr.xebia.springframework.security.core.userdetails.memory.ExtendedUserMapBuilder.java
/** * Build {@link org.springframework.security.core.userdetails.memory.UserMap} from user attributes. * Attributes are defined by :// w ww. j ava2 s .c o m * <code>username=password,grantedAuthority[,grantedAuthority][,enabled|disabled][,@(allowedIpAddresses)]</code> * @param userMap {@link org.springframework.security.core.userdetails.memory.UserMap} to populate. * @param usersAttributes {@link java.util.Properties} describing users and their attributes. * @return updated <code>userMap</code>. */ public static UserMap buildUserMapFromProperties(UserMap userMap, Properties usersAttributes) { if (usersAttributes == null) { return userMap; } for (Map.Entry<Object, Object> entry : usersAttributes.entrySet()) { String userAttributes = entry.getKey() + "=" + entry.getValue(); UserDetails user = buildExtendedUser(userAttributes); if (user != null) { userMap.addUser(user); } } return userMap; }
From source file:Main.java
/** * This isn't what the RI does. The RI doesn't have hard-coded defaults, so * supplying your own "content.types.user.table" means you don't get any of * the built-ins, and the built-ins come from * "$JAVA_HOME/lib/content-types.properties". *//*from w ww. j a va 2 s . co m*/ private static void applyOverrides() { // Get the appropriate InputStream to read overrides from, if any. InputStream stream = getContentTypesPropertiesStream(); if (stream == null) { return; } try { try { // Read the properties file... Properties overrides = new Properties(); overrides.load(stream); // And translate its mapping to ours... for (Map.Entry<Object, Object> entry : overrides.entrySet()) { String extension = (String) entry.getKey(); String mimeType = (String) entry.getValue(); add(mimeType, extension); } } finally { stream.close(); } } catch (IOException ignored) { } }
From source file:ch.algotrader.config.spring.ConfigLoader.java
static void loadResource(final Map<String, String> paramMap, final Resource resource) throws IOException { try (InputStream inputStream = resource.getInputStream()) { Properties props = new Properties(); props.load(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); for (Map.Entry<Object, Object> entry : props.entrySet()) { String paramName = (String) entry.getKey(); String paramValue = (String) entry.getValue(); if (StringUtils.isNotBlank(paramName)) { paramMap.put(paramName, paramValue); }//from w ww.ja v a 2s . c om } } }
From source file:com.sap.prd.mobile.ios.mios.EffectiveBuildSettings.java
private static String toString(Properties buildSettings) { String ls = System.getProperty("line.separator"); StringBuilder sb = new StringBuilder(ls); for (Map.Entry<?, ?> e : buildSettings.entrySet()) { sb.append(e.getKey()).append("=").append(e.getValue()).append(ls); }/*from w ww. j av a 2 s . co m*/ return sb.toString(); }
From source file:ddf.security.PropertiesLoader.java
@SuppressWarnings("unchecked") public static <K, V> Map<K, V> toMap(Properties properties) { if (properties != null) { final Set<Map.Entry<Object, Object>> entries = properties.entrySet(); Map<K, V> map = new HashMap<K, V>(entries.size() * 2); for (Map.Entry<Object, Object> entry : entries) { map.put((K) entry.getKey(), (V) entry.getValue()); }//from www . j av a 2s .co m return map; } return new HashMap<K, V>(); }
From source file:com.asakusafw.yaess.tools.GenerateExecutionId.java
static Configuration parseConfiguration(String[] args) throws ParseException { assert args != null; CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(OPTIONS, args); String batchId = cmd.getOptionValue(OPT_BATCH_ID.getOpt()); String flowId = cmd.getOptionValue(OPT_FLOW_ID.getOpt()); Properties arguments = cmd.getOptionProperties(OPT_ARGUMENT.getOpt()); SortedMap<String, String> pairs = new TreeMap<>(); for (Map.Entry<Object, Object> entry : arguments.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (key instanceof String && value instanceof String) { pairs.put((String) key, (String) value); }/*w ww . ja v a2 s .co m*/ } Configuration result = new Configuration(); result.batchId = batchId; result.flowId = flowId; result.arguments = pairs; return result; }
From source file:io.fabric8.profiles.ProfilesHelpers.java
public static void merge(Properties target, Properties source) { if (source.contains(DELETED)) { target.clear();//from w w w . j av a 2 s . com } else { for (Map.Entry<Object, Object> entry : source.entrySet()) { if (DELETED.equals(entry.getValue())) { target.remove(entry.getKey()); } else { target.put(entry.getKey(), entry.getValue()); } } } }
From source file:com.haulmont.cuba.core.entity.LocaleHelper.java
public static String convertFromSimpleKeyLocales(String enumValue, String localeBundle) { Properties result = new Properties(); Properties properties = loadProperties(localeBundle); if (properties != null) { for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); result.put(key + "/" + enumValue, entry.getValue()); }// w w w. j a v a 2s. c o m } return convertPropertiesToString(result); }
From source file:com.haulmont.cuba.core.entity.LocaleHelper.java
public static String convertToSimpleKeyLocales(String localeBundle) { Properties result = new Properties(); Properties properties = loadProperties(localeBundle); if (properties != null) { for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = (String) entry.getKey(); key = key.substring(0, key.indexOf("/")); result.put(key, entry.getValue()); }//from w w w. jav a 2 s.co m } return convertPropertiesToString(result); }
From source file:ch.entwine.weblounge.test.util.TestSiteUtils.java
/** * Loads the greetings from <code>/greetings.properties</code> into a * <code>Map</code> and returns them. * <p>//from w w w . j av a 2s . c om * Note that we need to do a conversion from the <code>ISO-LATIN-1</code> * (which is assumed by the <code>Properties</code> implementation) to * <code>utf-8</code>. * * @return the greetings * @throws Exception * if loading fails */ public static Map<String, String> loadGreetings() { Map<String, String> greetings = new HashMap<String, String>(); InputStream is = TestSiteUtils.class.getResourceAsStream(GREETING_PROPS); try { Properties props = new Properties(); props.load(is); for (Entry<Object, Object> entry : props.entrySet()) { try { String isoLatin1Value = entry.getValue().toString(); String utf8Value = new String(isoLatin1Value.getBytes("ISO-8859-1"), "utf-8"); greetings.put((String) entry.getKey(), utf8Value); } catch (UnsupportedEncodingException e) { logger.error("I can't believe the platform does not support encoding {}", e.getMessage()); } } } catch (IOException e) { logger.error("Error reading greetings from " + GREETING_PROPS, e); return null; } finally { IOUtils.closeQuietly(is); } return greetings; }