List of usage examples for java.util Map entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:Main.java
/******* * It is easy to accidentally create GStrings instead of String in a groovy file. This will auto correct the problem * for byon node definitions by calling the toString() methods for map keys and values. * * @param originalNodesList// w w w .j a va 2 s . c o m * . * @return the */ public static List<Map<String, String>> convertToStringMap(final List<Map<Object, Object>> originalNodesList) { List<Map<String, String>> nodesList; nodesList = new LinkedList<Map<String, String>>(); for (final Map<Object, Object> originalMap : originalNodesList) { final Map<String, String> newMap = new LinkedHashMap<String, String>(); final Set<Entry<Object, Object>> entries = originalMap.entrySet(); for (final Entry<Object, Object> entry : entries) { newMap.put(entry.getKey().toString(), entry.getValue().toString()); } nodesList.add(newMap); } return nodesList; }
From source file:Main.java
public static ImmutableMap<Path, Path> applyFilenameFormat(Map<String, Path> filesToHashes, Path deviceDir, String filenameFormat) {/* w w w . jav a2 s . c o m*/ ImmutableMap.Builder<Path, Path> filesBuilder = ImmutableMap.builder(); for (Map.Entry<String, Path> entry : filesToHashes.entrySet()) { filesBuilder.put(deviceDir.resolve(String.format(filenameFormat, entry.getKey())), entry.getValue()); } return filesBuilder.build(); }
From source file:controllers.oer.NtToEs.java
private static void process(Map<String, StringBuilder> map) { for (Entry<String, StringBuilder> e : map.entrySet()) { String mapKey = e.getKey(); try {/* w ww . j ava 2s .co m*/ String jsonLd = rdfToJsonLd(e.getValue().toString(), Lang.NTRIPLES); String parent = findParent(jsonLd); String key = uuidForFileName(mapKey); indexData(key, jsonLd, INDEX, TYPE, parent); } catch (Exception x) { System.err.printf("Could not process file %s due to %s\n", mapKey, x.getMessage()); x.printStackTrace(); } } }
From source file:com.lightydev.dk.json.Json.java
public static ContentValues parseObject(JSONObject object, Map<String, String> projection) throws JSONException { final ContentValues values = new ContentValues(); for (final Map.Entry<String, String> entry : projection.entrySet()) { if (object.has(entry.getValue())) { if (object.isNull(entry.getValue())) { values.putNull(entry.getKey()); } else { values.put(entry.getKey(), String.valueOf(object.get(entry.getValue()))); }//from w w w . j a v a 2 s . c om } } return values; }
From source file:com.zimbra.common.httpclient.HttpClientUtil.java
public static HttpState newHttpState(ZAuthToken authToken, String host, boolean isAdmin) { HttpState state = new HttpState(); if (authToken != null) { Map<String, String> cookieMap = authToken.cookieMap(isAdmin); if (cookieMap != null) { for (Map.Entry<String, String> ck : cookieMap.entrySet()) { state.addCookie(new Cookie(host, ck.getKey(), ck.getValue(), "/", null, false)); }//from w w w . j ava 2 s . c o m } } return state; }
From source file:org.iglootools.hchelpers.core.DefaultHttpClientFactory.java
public static BasicHttpParams httpParams(Map<String, Object> params) { BasicHttpParams httpParams = new BasicHttpParams(); for (Entry<String, Object> e : params.entrySet()) { httpParams.setParameter(e.getKey(), e.getValue()); }/*from ww w .j a v a 2 s . c om*/ return httpParams; }
From source file:Main.java
public static <V> Map<String, V> cleanupMap(Map<String, V> map) { if (map == null || map.isEmpty()) { return null; }/*www . j a v a 2 s .co m*/ Map<String, V> result = new HashMap<String, V>(map.size()); Set<Entry<String, V>> entries = map.entrySet(); for (Entry<String, V> entry : entries) { if (entry.getValue() != null) { result.put(entry.getKey(), entry.getValue()); } } return result; }
From source file:com.glaf.jbpm.util.SqlParamUtils.java
@SuppressWarnings("unchecked") public static List<Object> getValues(Map<String, Object> paramMap, SqlExecutor executor) { java.util.Date now = new java.util.Date(); List<Object> values = new java.util.ArrayList<Object>(); Object parameter = executor.getParameter(); if (parameter instanceof Map) { Map<String, Object> params = (Map<String, Object>) parameter; Set<Entry<String, Object>> entrySet = params.entrySet(); for (Entry<String, Object> entry : entrySet) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof String) { String tmp = (String) value; if (StringUtils.isNotEmpty(tmp)) { if (tmp.equals("now()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("date()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("time()")) { value = new java.sql.Time(now.getTime()); } else if (tmp.equals("timestamp()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("dateTime()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("currentTimeMillis()")) { value = Long.valueOf(System.currentTimeMillis()); } else if (tmp.equals("#{rowId}")) { value = paramMap.get("rowId"); } else if (tmp.equals("#{processInstanceId}")) { value = ParamUtils.getString(paramMap, "processInstanceId"); } else if (tmp.equals("#{processName}")) { value = ParamUtils.getString(paramMap, "processName"); } else if (tmp.equals("#{status}")) { value = paramMap.get("status"); } else if (tmp.startsWith("#P{") && tmp.endsWith("}")) { tmp = StringTools.replaceIgnoreCase(tmp, "#P{", ""); tmp = StringTools.replaceIgnoreCase(tmp, "}", ""); value = paramMap.get(tmp); } else if (tmp.startsWith("#{") && tmp.endsWith("}")) { value = DefaultExpressionEvaluator.evaluate(tmp, paramMap); }//w w w .j ava 2s . co m } } } values.add(value); } } return values; }
From source file:Main.java
public static String mapToString(Map<? extends Object, ? extends Object> map) { if (map == null) return "null"; StringBuilder sb = new StringBuilder(); for (Map.Entry<? extends Object, ? extends Object> entry : map.entrySet()) { Object key = entry.getKey(); Object val = entry.getValue(); sb.append(key).append("="); if (val == null) sb.append("null"); else/*from ww w . ja va 2 s .co m*/ sb.append(val); sb.append("\n"); } return sb.toString(); }
From source file:Main.java
/** * Converts <code>params</code> into an application/x-www-form-urlencoded encoded string. *//* ww w . j av a2 s . c o m*/ public static byte[] encodeParamsToBytes(Map<String, String> params, String paramsEncoding) { StringBuilder encodedParams = new StringBuilder(); try { for (Map.Entry<String, String> entry : params.entrySet()) { encodedParams.append(URLEncoder.encode(entry.getKey(), paramsEncoding)); encodedParams.append('='); encodedParams.append(URLEncoder.encode(entry.getValue(), paramsEncoding)); encodedParams.append('&'); } return encodedParams.toString().getBytes(paramsEncoding); } catch (UnsupportedEncodingException uee) { throw new RuntimeException("Encoding not supported: " + paramsEncoding, uee); } }