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
public static String getPostDataString(HashMap<String, String> params) { try {//from ww w .j a v a 2 s .co m StringBuilder result = new StringBuilder(); boolean first = true; for (Map.Entry<String, String> entry : params.entrySet()) { if (first) first = false; else result.append("&"); result.append(URLEncoder.encode(entry.getKey(), "UTF-8")); result.append("="); if (entry.getValue() == null) { result.append(URLEncoder.encode("", "UTF-8")); } else { result.append(URLEncoder.encode(entry.getValue(), "UTF-8")); } } return result.toString(); } catch (UnsupportedEncodingException e) { System.out.print(e.getMessage()); } return ""; }
From source file:Main.java
public static String generateBgsid(HashMap hashmap) { StringBuffer stringbuffer = new StringBuffer(); ArrayList arraylist = new ArrayList(); for (Iterator iterator = hashmap.entrySet().iterator(); iterator.hasNext(); arraylist .add(((java.util.Map.Entry) iterator.next()).getKey())) { }//from ww w . j a va 2 s .c o m Collections.sort(arraylist, String.CASE_INSENSITIVE_ORDER); for (Iterator iterator1 = arraylist.iterator(); iterator1.hasNext(); stringbuffer .append((String) hashmap.get((String) iterator1.next()))) { } stringbuffer.append("c18c24046606b2e084edd37f9fe9f94d"); return md5(stringbuffer.toString()); }
From source file:Main.java
@SuppressWarnings("rawtypes") public static String formCreateTableSqlString(String tableName, HashMap<String, String> columnNameAndType, String primary_key) {/*w ww. jav a 2 s . co m*/ StringBuffer sqlCreateTable = new StringBuffer("CREATE TABLE IF NOT EXISTS " + tableName + " ("); Iterator iterator = columnNameAndType.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); sqlCreateTable.append(" "); sqlCreateTable.append(entry.getKey()); sqlCreateTable.append(" "); sqlCreateTable.append(entry.getValue()); sqlCreateTable.append(","); } //sqlCreateTable.deleteCharAt(sqlCreateTable.lastIndexOf(",")); sqlCreateTable.append(primary_key); sqlCreateTable.append(");"); return sqlCreateTable.toString(); }
From source file:mamo.vanillaVotifier.utils.SubstitutionUtils.java
@NotNull public static String applyRegexReplacements(@Nullable String string, @Nullable HashMap<String, String> substitutions) { if (string == null || substitutions == null) { return string; }/*from ww w . j a v a 2 s .c o m*/ for (Entry<String, String> substitution : substitutions.entrySet()) { string = string.replaceAll(substitution.getKey(), substitution.getValue()); } return string; }
From source file:Main.java
public static void storeDistanceAndLocation(Context context, HashMap<String, String> params) { SharedPreferences sharedPref = context.getSharedPreferences("DistanceAndLocation", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); for (Map.Entry<String, String> entry : params.entrySet()) { editor.putString(entry.getKey(), entry.getValue()); }//from w w w. j a va 2s .com editor.apply(); }
From source file:in.flipbrain.Utils.java
public static String httpGet(String uri, HashMap<String, String> params) { StringBuilder query = new StringBuilder(); for (Map.Entry<String, String> entrySet : params.entrySet()) { String key = entrySet.getKey(); String value = entrySet.getValue(); query.append(URLEncoder.encode(key)).append("="); query.append(URLEncoder.encode(value)).append("&"); }//from w w w. j a va 2 s .co m if (query.length() > 0) { query.insert(0, "?").insert(0, uri); } String res = null; try { String fullUrl = query.toString(); logger.debug("Request URL: " + fullUrl); res = Request.Get(fullUrl).execute().returnContent().asString(); logger.debug("Response: " + res); } catch (IOException e) { logger.fatal("Failed to process request. ", e); } return res; }
From source file:in.flipbrain.Utils.java
public static String httpPost(String uri, HashMap<String, String> params) { List<NameValuePair> nvps = new ArrayList<NameValuePair>(); for (Map.Entry<String, String> entrySet : params.entrySet()) { String key = entrySet.getKey(); String value = entrySet.getValue(); nvps.add(new BasicNameValuePair(key, value)); }//from ww w. ja v a 2 s .c o m String res = null; try { res = Request.Post(uri).bodyForm(nvps).execute().returnContent().asString(); logger.debug("Response: " + res); } catch (IOException e) { logger.fatal("Failed to process request. ", e); } return res; }
From source file:edu.coeia.charts.LineChartPanel.java
private static CategoryDataset createCategoryDataset(String userName, String otherName, ArrayList<Message> data, ArrayList<Message> data2) throws ParseException { // row keys... final String series1 = userName; final String series2 = otherName; // create the dataset... final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); HashMap<String, Integer> sentMap = getDateMap(data, userName, otherName); for (Map.Entry<String, Integer> mapEntry : sentMap.entrySet()) { dataset.addValue(mapEntry.getValue(), series2, mapEntry.getKey()); }/*from ww w . ja v a 2 s . c om*/ HashMap<String, Integer> recMap = getDateMap(data2, otherName, userName); for (Map.Entry<String, Integer> mapEntry : recMap.entrySet()) { dataset.addValue(mapEntry.getValue(), series1, mapEntry.getKey()); } return dataset; }
From source file:net.sourceforge.jcctray.utils.ObjectPersister.java
private static void saveKeyValues(Writer writer, HashMap settings) throws IOException { writer.write(" <settings>\n"); for (Iterator iterator = settings.entrySet().iterator(); iterator.hasNext();) { Entry entry = (Entry) iterator.next(); writer.write(" <entry"); writer.write(" key=\"" + entry.getKey() + "\""); writer.write(" value=\"" + entry.getValue() + "\"/>\n"); }/*from www.j ava 2 s .c o m*/ writer.write(" </settings>\n"); }
From source file:de.upb.wdqa.wdvd.processors.statistics.ActionStatisticsProcessor.java
private static List<Map.Entry<String, Integer>> getSortedList2(HashMap<String, Integer> map) { List<Map.Entry<String, Integer>> entries = new ArrayList<Map.Entry<String, Integer>>(map.entrySet()); Collections.sort(entries, new Comparator<Map.Entry<String, Integer>>() { public int compare(Map.Entry<String, Integer> a, Map.Entry<String, Integer> b) { return a.getKey().compareTo(b.getKey()); }//from w w w. j a v a2 s. c o m }); return entries; }