List of usage examples for java.util HashMap entrySet
Set entrySet
To view the source code for java.util HashMap entrySet.
Click Source Link
From source file:main.java.com.skillselector.client.root.Neo4JRequest.java
public static void lireMapFromNeo4J(Map<String, HashMap<String, String>> content) { Iterator it1 = content.entrySet().iterator(); while (it1.hasNext()) { Map.Entry pair = (Map.Entry) it1.next(); String key = (String) pair.getKey(); System.out.println(key);//consultant HashMap<String, String> map = (HashMap<String, String>) pair.getValue(); Iterator it2 = map.entrySet().iterator(); while (it2.hasNext()) { Map.Entry submap = (Map.Entry) it2.next(); String subkey = (String) submap.getKey(); String subvalue = (String) submap.getValue(); System.out.print(subkey);//skill System.out.println(" " + subvalue);//anne }/*from ww w .j a v a2 s. com*/ } }
From source file:com.knowbout.hibernate.HibernateUtil.java
/** * This will add properties to the hibernate configuration for each entry that has * a non null value and will remove properties for entries will a null value. It will also attempt * to close the old SessionFactory and create a new one based on the new properties. * All sessions must be closed before this method is called. * @param properties//from w w w . ja va 2 s. com */ public synchronized static void setProperties(HashMap<String, String> properties) { Properties currentProps = config.getProperties(); Set<Entry<String, String>> entries = properties.entrySet(); for (Entry<String, String> entry : entries) { if (entry.getValue() == null) { currentProps.remove(entry.getKey()); } else { currentProps.setProperty(entry.getKey(), entry.getValue()); } } if (sessionFactory != null) { sessionFactory.close(); sessionFactory = null; } }
From source file:com.intuit.tank.http.BaseRequestHandler.java
/** * Set all the header keys//from w w w . j a v a 2s.co m * * @param connection */ @SuppressWarnings("rawtypes") public static void setHeaders(HttpMethod method, HashMap<String, String> headerInformation) { try { Set set = headerInformation.entrySet(); Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry mapEntry = (Map.Entry) iter.next(); method.setRequestHeader((String) mapEntry.getKey(), (String) mapEntry.getValue()); } } catch (Exception ex) { logger.warn(LogUtil.getLogMessage("Unable to set header: " + ex.getMessage(), LogEventType.System)); } }
From source file:de.schaeuffelhut.android.openvpn.tun.DeviceDetails.java
private static void readSystemProperties(StringBuilder sb) { sb.append("System Properties (ro.build*, ro.product*, ro.revision) :\n"); HashMap<String, String> properties = SystemPropertyUtil.getProperties(); ArrayList<Entry<String, String>> entrySet = new ArrayList<Entry<String, String>>(properties.entrySet()); Collections.sort(entrySet, new Comparator<Entry<String, String>>() { public int compare(Entry<String, String> lhs, Entry<String, String> rhs) { return lhs.getKey().compareTo(rhs.getKey()); }/*from www. j ava 2s .c o m*/ }); for (Map.Entry<String, String> e : entrySet) { String key = e.getKey(); if (key.startsWith("ro.build") || key.startsWith("ro.product") || key.startsWith("ro.revision")) { sb.append(key); sb.append(": "); sb.append(e.getValue()); sb.append('\n'); } } sb.append("\n"); }
From source file:Main.java
/** * Checks if a value userExists in a HashMap that matches the specified Predicate. * @param map the HashMap to check against * @param condition the Predicate to check * @param <K> the type of the Key in the HashMap * @param <V> the type of the Value in the HashMap * @return true if condition is true//from w ww . j a v a2 s . c o m * @throws IllegalArgumentException if HashMap or Predicate is null */ public static <K, V> boolean doesItemExistInHashMap(final HashMap<K, V> map, final Predicate<V> condition) { if (map == null) throw new IllegalArgumentException("HashMap cannot be null!"); if (condition == null) throw new IllegalArgumentException("Predicate cannot be null!"); for (final Map.Entry<K, V> entry : map.entrySet()) if (condition.test(entry.getValue())) return true; return false; }
From source file:og.android.tether.system.WebserviceTask.java
public static void report(String url, HashMap<String, Object> paramMap) { List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); Set<Entry<String, Object>> a = paramMap.entrySet(); for (Entry<String, Object> e : a) { Object o = e.getValue();/*from w w w. ja v a2 s . co m*/ if (o != null) { params.add(new BasicNameValuePair(e.getKey(), o.toString())); } } try { HttpResponse response = makeRequest(url, params); StatusLine status = response.getStatusLine(); Log.d(MSG_TAG, "Request returned status " + status); if (status.getStatusCode() == 200) { HttpEntity entity = response.getEntity(); Log.d(MSG_TAG, "Request returned: " + entity.getContent()); } } catch (Exception e) { Log.d(MSG_TAG, "Can't report stats '" + url + "' (" + e.toString() + ")."); } }
From source file:main.java.com.skillselector.client.root.Neo4JRequest.java
public static JSONObject calculateScoresFromJsonNeo4J(Skill requestedSkills[], int requestedSkillsNumber, double power, Map<String, HashMap<String, String>> content) { System.out.print("Enter calculateScoresFromJsonNeo4J "); int nbConsultant = 0; Iterator it1c = content.entrySet().iterator(); while (it1c.hasNext()) { Map.Entry pair = (Map.Entry) it1c.next(); nbConsultant++;//w w w . j a v a2s .c o m } System.out.print("nbConsultant " + nbConsultant);//skill double totalScore = 0.0; DecimalFormat df = new DecimalFormat("00.00"); int nbConsultants = 0; JSONObject jsonReturn = new JSONObject(); int nbskillsConsultant = 0; Iterator it1 = content.entrySet().iterator(); while (it1.hasNext()) { Map.Entry pair = (Map.Entry) it1.next(); String key = (String) pair.getKey(); HashMap<String, String> map = (HashMap<String, String>) pair.getValue(); Iterator it2 = map.entrySet().iterator(); nbskillsConsultant = 0; while (it2.hasNext()) { Map.Entry submap = (Map.Entry) it2.next(); nbskillsConsultant++; } String[][] skillsTab = new String[nbskillsConsultant][2]; Iterator it3 = map.entrySet().iterator(); int it3Number = -1; while (it3.hasNext()) { it3Number++; Map.Entry submap = (Map.Entry) it3.next(); String subkey = (String) submap.getKey(); String subvalue = (String) submap.getValue(); skillsTab[it3Number][0] = subkey; skillsTab[it3Number][1] = subvalue; } it3Number = -1; // Test if skills in consultant and calculate score for (int j = 0; j < requestedSkillsNumber; j++) { totalScore += SkillsRequest.matchedSkill(requestedSkills[j], skillsTab, nbskillsConsultant - 1, power); } nbskillsConsultant = 0; System.out.print("\nConsultant " + key + " score " + totalScore);//consultant int ts = (int) totalScore; String chTotalScore = String.valueOf(ts); if (!chTotalScore.contentEquals("0")) { jsonReturn.append(key, (String) chTotalScore); } totalScore = 0; } return jsonReturn; }
From source file:com.nridge.core.io.gson.IOJSON.java
/** * Writes a JSON field name/value.// ww w .j a v a 2 s. co m * * @param aWriter JSON writer output stream. * @param aName Field name. * @param aValue Field value. * * @throws IOException I/O related exception. */ public static void writeNameValue(JsonWriter aWriter, String aName, HashMap<String, String> aValue) throws IOException { if (aValue.size() > 0) { aWriter.name(aName).beginObject(); for (Map.Entry<String, String> featureEntry : aValue.entrySet()) { aWriter.name(featureEntry.getKey()); aWriter.value(featureEntry.getValue()); } aWriter.endObject(); } }
From source file:de.upb.wdqa.wdvd.processors.statistics.ActionStatisticsProcessor.java
private static List<Map.Entry<String, HashMap<String, Integer>>> getSortedList( HashMap<String, HashMap<String, Integer>> map) { List<Map.Entry<String, HashMap<String, Integer>>> entries = new ArrayList<Map.Entry<String, HashMap<String, Integer>>>( map.entrySet()); Collections.sort(entries, new Comparator<Map.Entry<String, HashMap<String, Integer>>>() { public int compare(Map.Entry<String, HashMap<String, Integer>> a, Map.Entry<String, HashMap<String, Integer>> b) { return a.getKey().compareTo(b.getKey()); }/*from ww w .j a v a2 s .co m*/ }); return entries; }
From source file:com.sugarcrm.candybean.webservices.WS.java
/** * Send a DELETE, GET, POST, or PUT http request * * @param op The type of http request * @param uri The http endpoint/*from ww w .j a v a2 s . c o m*/ * @param payload Map of key value pairs for the body * @param postHeaders List of Maps of header key value pairs * @param body String representation of the request body (ignored) * @return Key Value pairs of the response * @throws Exception When http request failed * @deprecated This is a work around for old compatibility, use {@link #request(OP, String, Map, String, ContentType)} * or {@link #request(OP, String, Map, Map)} */ @Deprecated public static Map<String, Object> request(OP op, String uri, Map<String, String> payload, String body, ArrayList<HashMap<String, String>> postHeaders) throws Exception { HashMap<String, String> headers = new HashMap<>(); for (HashMap<String, String> map : postHeaders) { for (Map.Entry<String, String> entry : map.entrySet()) { headers.put(entry.getKey(), entry.getValue()); } } HashMap<String, Object> newPayload = new HashMap<>(); for (Map.Entry<String, String> entry : payload.entrySet()) { newPayload.put(entry.getKey(), entry.getValue()); } if (body == null) { return request(op, uri, headers, newPayload); } else { return request(op, uri, headers, body, ContentType.DEFAULT_TEXT); } }