List of usage examples for java.util Map entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:com.ibm.sbt.security.encryption.HMACEncryptionUtility.java
public static String generateParameterString(Map<String, String> paramsMap) { StringBuilder parameterString = new StringBuilder(); for (Map.Entry<String, String> entry : paramsMap.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); parameterString.append(key).append("=").append(percentEncode(value)).append("&"); }/*from ww w.j av a 2s .com*/ // Now remove the last & and return the string. return parameterString.deleteCharAt(parameterString.length() - 1).toString(); }
From source file:net.sephy.postman.util.PostmanUtils.java
/** * ?/*from w w w. j a va2s . c o m*/ * @param builder * @param params */ public static void setParameter(RequestBuilder builder, Map<String, Object> params) { if (params != null && params.size() > 0) { for (Map.Entry<String, Object> entry : params.entrySet()) { builder.addParameter(entryToNameAndValuePair(entry)); } } }
From source file:net.sephy.postman.util.PostmanUtils.java
/** * ?/*from w ww. j av a2 s . c o m*/ * @param builder * @param header */ public static void setHeader(RequestBuilder builder, Map<String, Object> header) { if (header != null && header.size() > 0) { for (Map.Entry<String, Object> entry : header.entrySet()) { builder.addHeader(entryToHeader(entry)); } } }
From source file:com.mirth.connect.donkey.util.purge.PurgeUtil.java
/** * Iterates through a Map and purges entries. If the entry is a collection, array, or map, the * size will be saved. All other entries are removed. *//* w w w . j a v a 2s. co m*/ public static Map<?, ?> getPurgedMap(Map<?, ?> originalEntry) { Map<String, Object> purgedData = new HashMap<String, Object>(); for (Map.Entry<?, ?> entry : originalEntry.entrySet()) { Map.Entry<?, ?> purgedEntry = getPurgedEntry(entry); // If data has been properly purged, add to purged data map. if (purgedEntry != null) { purgedData.put(purgedEntry.getKey().toString(), purgedEntry.getValue()); } } return purgedData; }
From source file:gov.nih.nci.cabig.caaers.utils.JSONUtils.java
public static String toJSON(Object o) throws Exception { Map<String, Object> map = describe(o); StringBuilder sb = new StringBuilder("{"); boolean useComma = false; for (Map.Entry e : map.entrySet()) { if (useComma) sb.append(","); useComma = true;/* w w w. j a v a 2 s .co m*/ String key = (String) e.getKey(); sb.append(delimiter).append(key).append(delimiter).append(colon); Object value = e.getValue(); if (value == null) { sb.append("null"); continue; } else if (e instanceof Collection) { sb.append("["); for (Object c : (Collection) value) { sb.append(toJSON(c)); } sb.append("]"); } else if (value instanceof Number || value instanceof Boolean) { sb.append(String.valueOf(value)); } else if (value instanceof String || value instanceof Character) { sb.append(delimiter).append(String.valueOf(value)).append(delimiter); } else { sb.append(toJSON(value)); } } sb.append("}"); return sb.toString(); }
From source file:com.github.yihtserns.logback.spring.config.LogbackObjectPropertiesAssembler.java
/** * Use Logback's API to set values to setXXX(value) and addXXX(value) methods because Spring only supports the former. * * @param logbackObject object to set property values to * @param property2ValueList property-to-value pairs (see {@link LogbackNamespaceHandler.Pair}) * @return the given object//from w w w. j a v a 2 s .com */ public static Object assemble(Object logbackObject, List<Map<String, Object>> property2ValueList) { Context logbackContext = (Context) LoggerFactory.getILoggerFactory(); LogbackComponent logbackComponent = new LogbackComponent(logbackObject, logbackContext); for (Map<String, Object> property2Value : property2ValueList) { for (Entry<String, Object> entry : property2Value.entrySet()) { String propertyName = entry.getKey(); Object propertyValue = entry.getValue(); logbackComponent.setOrAddProperty(propertyName, propertyValue); } } return logbackObject; }
From source file:com.evolveum.midpoint.cli.common.ToolsUtils.java
public static void setNamespaceDeclarations(Element element, Map<String, String> rootNamespaceDeclarations) { for (Map.Entry<String, String> entry : rootNamespaceDeclarations.entrySet()) { setNamespaceDeclaration(element, entry.getKey(), entry.getValue()); }//w w w .j av a2s. co m }
From source file:com.facebook.data.types.DatumUtils.java
/** * recursively converts the mapDatum into a valid JSONObject * * @param mapDatum/*from w ww . j ava 2 s .c om*/ * @return JSONObject */ public static JSONObject buildJSON(MapDatum mapDatum) { JSONObject jsonObject = new JSONObject(); Map<Datum, Datum> map = mapDatum.getMap(); try { for (Map.Entry<Datum, Datum> entry : map.entrySet()) { String key = entry.getKey().asString(); DatumType valueDatumType = entry.getValue().getType(); if (valueDatumType == DatumType.LIST) { jsonObject.put(key, buildJSON((ListDatum) entry.getValue())); } else if (valueDatumType == DatumType.MAP) { jsonObject.put(key, buildJSON((MapDatum) entry.getValue())); } else { jsonObject.put(key, entry.getValue().asRaw()); } } return jsonObject; } catch (JSONException e) { throw new RuntimeException("error converting json object to string", e); } }
From source file:com.microsoft.azure.engagement.shared.EngagementDataPushReceiver.java
@TargetApi(9) public static Map<String, String> getPendingDataPushes(Context context) { Map<String, String> smap = new TreeMap<String, String>(); SharedPreferences settings = context.getSharedPreferences(ENGAGEMENT_PREFERENCES, 0/*MODE_PRIVATE*/); Map<String, ?> m = settings.getAll(); // convert to treemap to keep the order by timestamp for (Map.Entry<String, ?> entry : m.entrySet()) { smap.put(entry.getKey(), entry.getValue().toString()); }/*from w w w .ja v a 2 s .c o m*/ // remove all settings.edit().clear().apply(); return smap; }
From source file:com.cybernostics.jsp2thymeleaf.api.util.AlternateFormatStrings.java
private static String asString(Map<String, Object> values) { return values.entrySet().stream().map(i -> i.getKey() + "=" + i.getValue().toString()).collect(joining()); }