List of usage examples for java.util HashMap keySet
public Set<K> keySet()
From source file:bencoding.securely.Converters.java
@SuppressWarnings("rawtypes") public static Object toJSON(Object object) throws JSONException { if (object instanceof HashMap) { JSONObject json = new JSONObject(); HashMap hashmap = (HashMap) object; for (Object key : hashmap.keySet()) { json.put(key.toString(), toJSON(hashmap.get(key))); }//from www . ja va 2 s .co m return json; } else if (object instanceof Map) { JSONObject json = new JSONObject(); Map map = (Map) object; for (Object key : map.keySet()) { json.put(key.toString(), toJSON(map.get(key))); } return json; } else if (object instanceof Iterable) { JSONArray json = new JSONArray(); for (Object value : ((Iterable) object)) { json.put(toJSON(value)); } return json; } else { return object; } }
From source file:sas.BarChart.java
public static CategoryDataset createProfitDataset(HashMap<String, Float> lsh) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); for (String sh : lsh.keySet()) { defaultcategorydataset.addValue(lsh.get(sh), "Profit", sh); }/*from ww w .j ava 2 s. c o m*/ return defaultcategorydataset; }
From source file:sas.BarChart.java
public static CategoryDataset createPriceDataset(HashMap<String, Float> lsh) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); for (String sh : lsh.keySet()) { defaultcategorydataset.addValue(lsh.get(sh), "Prices", sh); }/* w ww .jav a 2 s .co m*/ return defaultcategorydataset; }
From source file:utilities.itext.Turnover.java
private static Image createPieChart(HashMap<String, BigDecimal> map, String title) throws Exception { DefaultPieDataset data = new DefaultPieDataset(); for (String key : map.keySet()) { data.setValue(key, map.get(key).doubleValue()); }// w ww . j av a 2 s.c o m JFreeChart pieChart = ChartFactory.createPieChart(title, data, true, false, Locale.GERMAN); // PiePlot plot = (PiePlot) pieChart.getPlot(); // plot.setLabelGenerator(null); BufferedImage pie = pieChart.createBufferedImage(500, 500); File tempPie = File.createTempFile("png", null); ImageIO.write(pie, "png", tempPie); Image img = Image.getInstance(tempPie.getPath()); return img; }
From source file:model.SongMeaningsScraper.java
public static String validateArtist(String artist) { HashMap<String, String> artists = DataManager.getArtistMap(); for (String artistFromMap : artists.keySet()) { int levDist = StringUtils.getLevenshteinDistance(artistFromMap.toUpperCase(), artist.toUpperCase()); double ratio = (artistFromMap.length() - levDist + 0.0) / (artistFromMap.length() + 0.0); if (ratio == 1.0) { Logger.LogToStatusBar(artistFromMap + " exactly matches"); return artistFromMap; } else if (ratio >= 0.5) { ArrayList<String> matches = DataManager.getArtistMatches().get(artist); if (matches == null) { matches = new ArrayList<String>(); matches.add(artistFromMap); DataManager.getArtistMatches().put(artist, matches); } else { matches.add(artistFromMap); DataManager.getArtistMatches().remove(artist); DataManager.getArtistMatches().put(artist, matches); }// www . ja va 2s .co m } } return ""; }
From source file:com.symphony.jirabot.clients.QuandlClient.java
private static String mapToQueryString(HashMap<String, Object> parameters) { if (parameters == null || parameters.size() == 0) { return ""; }//ww w. j a va 2 s . c o m StringBuilder queryString = new StringBuilder("&"); for (String key : parameters.keySet()) { queryString.append(urlEncodeUTF8(key)); queryString.append("="); queryString.append(urlEncodeUTF8(parameters.get(key).toString())); queryString.append("&"); } if (queryString.charAt(queryString.length() - 1) == '&') { queryString = queryString.deleteCharAt(queryString.length() - 1); } return queryString.toString(); }
From source file:sas.BarChart.java
public static CategoryDataset createSaleDataset(java.util.HashMap<String, Float> lsh) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); for (String sh : lsh.keySet()) { defaultcategorydataset.addValue(lsh.get(sh), "Sales", sh); }// w w w .java2s . c o m return defaultcategorydataset; }
From source file:model.SongMeaningsScraper.java
private static String validateSong(String artist, String title) { HashMap<String, String> songList = DataManager.getSongMap().get(artist); for (String songFromMap : songList.keySet()) { int levDist = StringUtils.getLevenshteinDistance(songFromMap.toUpperCase(), title.toUpperCase()); double ratio = (songFromMap.length() - levDist + 0.0) / (songFromMap.length() + 0.0); if (ratio == 1.0) { Logger.LogToStatusBar(songFromMap + " exactly matches"); return songFromMap; } else if (ratio >= 0.5) { ArrayList<String> matches = DataManager.getSongMatches().get(artist + " " + title); if (matches == null) { matches = new ArrayList<String>(); matches.add(songFromMap); DataManager.getSongMatches().put(artist + " " + title, matches); } else { matches.add(songFromMap); DataManager.getSongMatches().remove(artist + " " + title); DataManager.getSongMatches().put(artist + " " + title, matches); }/*from ww w . java 2s . co m*/ } } return ""; }
From source file:com.sugarcrm.candybean.datasource.CsvDataAdapterSystemTest.java
private static void printDataSource(HashMap<String, DataSource> dataSourceHashMap) { for (String filenameNoExt : dataSourceHashMap.keySet()) { System.out.println(//from w w w . j a v a2s . c o m "CsvDataAdapterTest: printDataSourceData(): dataSource filenameNoExt = " + filenameNoExt); DataSource ds = dataSourceHashMap.get(filenameNoExt); printDataSourceFieldSet(ds); } }
From source file:cooccurrence.Omer_Levy.java
/** * Method to populate the apache matrix from cooccur hashmap * @param matrixR/* w ww . j a v a 2 s . co m*/ * @param cooccur * @param rowStrings * @param colStrings */ private static void populateMatrixR(RealMatrix matrixR, HashMap<String, HashMap<String, Double>> cooccur, ArrayList<String> rowStrings, ArrayList<String> colStrings) { Iterator iter = cooccur.keySet().iterator(); while (iter.hasNext()) { String row = iter.next().toString(); int i = rowStrings.indexOf(row); HashMap<String, Double> inner = cooccur.get(row); for (String col : inner.keySet()) { int j = colStrings.indexOf(col); double val = inner.get(col); matrixR.setEntry(i, j, val); } iter.remove(); } }