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:io.lightlink.excel.ExcelImportExportTest.java
private void compareAssertMap(String position, HashMap<String, Object> data, Map<String, Object> loadedData) { assertEquals("Sizez must be equal", data.size(), loadedData.size()); for (Map.Entry<String, Object> entry : data.entrySet()) { Object expected = entry.getValue(); Object found = loadedData.get(entry.getKey()); compareAssertObject(position + "." + entry.getKey(), expected, found); }//from w w w.j av a2s. co m }
From source file:eu.europa.ec.fisheries.uvms.exchange.dao.bean.ExchangeLogDaoBean.java
private void setQueryParameters(Query query, HashMap<ExchangeSearchField, List<SearchValue>> orderedValues) { for (Map.Entry<ExchangeSearchField, List<SearchValue>> criteria : orderedValues.entrySet()) { if (criteria.getValue().size() > 1) { query.setParameter(criteria.getKey().getSQLReplacementToken(), criteria.getValue()); } else {/*from w w w. j a v a 2s .c o m*/ query.setParameter(criteria.getKey().getSQLReplacementToken(), SearchFieldMapper .buildValueFromClassType(criteria.getValue().get(0), criteria.getKey().getClazz())); } } }
From source file:ch.asadzia.cognitive.EmotionDetect.java
public ServiceResult process() { HttpClient httpclient = HttpClients.createDefault(); try {/*from ww w.ja va 2 s. com*/ URIBuilder builder = new URIBuilder("https://api.projectoxford.ai/emotion/v1.0/recognize"); URI uri = builder.build(); HttpPost request = new HttpPost(uri); request.setHeader("Content-Type", "application/octet-stream"); request.setHeader("Ocp-Apim-Subscription-Key", apikey); // Request body FileEntity reqEntity = new FileEntity(imageData); request.setEntity(reqEntity); HttpResponse response = httpclient.execute(request); HttpEntity entity = response.getEntity(); if (entity != null) { String responseStr = EntityUtils.toString(entity); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { System.err.println(responseStr); return null; } JSONArray jsonArray = (JSONArray) new JSONParser().parse(responseStr); JSONObject jsonObject = (JSONObject) jsonArray.get(0); HashMap<char[], Double> scores = (HashMap) jsonObject.get("scores"); Map.Entry<char[], Double> maxEntry = null; for (Map.Entry<char[], Double> entry : scores.entrySet()) { System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); if (maxEntry == null || entry.getValue().compareTo(maxEntry.getValue()) > 0) { maxEntry = entry; } } Object key = maxEntry.getKey(); String winningEmotionName = (String) key; ServiceResult result = new ServiceResult(translateEmotion(winningEmotionName), winningEmotionName); System.out.println(responseStr); return result; } } catch (Exception e) { System.err.println(e.toString()); } return null; }
From source file:ANNFileDetect.detectFile.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed Iterator it = invt.entrySet().iterator(); String toPrint = ""; for (int i = 0; i < scores.size(); i++) toPrint = toPrint + scores.get(i) + "\n"; toPrint = toPrint + "\n\n"; while (it.hasNext()) { Map.Entry entries = (Map.Entry) it.next(); toPrint = toPrint + "Network: " + entries.getKey() + "\n"; HashMap tmphm = (HashMap) entries.getValue(); Iterator at = tmphm.entrySet().iterator(); while (at.hasNext()) { Map.Entry ent = (Map.Entry) at.next(); toPrint = toPrint + "File: " + ent.getKey() + " Score: " + ent.getValue() + "\n"; }// w w w . ja va 2 s . co m toPrint = toPrint + "\n\n"; } //new Thread(new Display(toPrint)).start(); Display disp = new Display(toPrint); disp.setVisible(true); }
From source file:com.github.reinert.jjschema.v1.CustomSchemaWrapper.java
protected void processProperties() { HashMap<Method, Field> properties = findProperties(); for (Entry<Method, Field> prop : properties.entrySet()) { PropertyWrapper propertyWrapper = new PropertyWrapper(this, managedReferences, prop.getKey(), prop.getValue());/* w w w. ja va 2 s .c om*/ if (!propertyWrapper.isEmptyWrapper()) addProperty(propertyWrapper); } }
From source file:com.jaxio.celerio.output.FileTracker.java
public HashSet<FileMetaData> deleteGeneratedFileIfIdentical(File projectDir, List<String> excludedPatterns) throws IOException { SCMStatus scmStatus = getSCMStatus(projectDir); HashSet<FileMetaData> scmFiles = newHashSet(); HashSet<FileMetaData> deletedFiles = newHashSet(); HashSet<FileMetaData> notFoundFiles = newHashSet(); File xmlFileMetaDatas = new File(projectDir, getFilename()); if (!xmlFileMetaDatas.exists()) { info("CANNOT FIND FILE TRACKER METADATA " + xmlFileMetaDatas.getAbsolutePath()); return deletedFiles; }//from w w w. j a va2 s. co m HashMap<String, FileMetaData> filesToScan = loadFromProjectDir(projectDir); for (Entry<String, FileMetaData> entry : filesToScan.entrySet()) { FileMetaData oldFmd = entry.getValue(); String relativePath = entry.getKey(); File oldFile = new File(projectDir, relativePath); if (oldFile.exists()) { if (scmStatus.isUnderSCM(relativePath)) { info("skip delete (file now under SCM): " + entry.getKey()); scmFiles.add(oldFmd); continue; } if (oldFmd.isBootstrapFile()) { info("skip file generated during bootstrap: " + entry.getKey()); continue; } FileMetaData recentFmd = new FileMetaData(null, null, entry.getKey(), oldFile); // info("recent: " +recentFmd.toString()); // info("old: " + oldFmd.toString()); if (oldFmd.equals(recentFmd)) { if (mustExcludeFile(relativePath, excludedPatterns)) { info("skip delete (present in excludedFiles): " + entry.getKey()); } else { info("delete: " + entry.getKey()); oldFile.delete(); ioUtil.pruneEmptyDirs(oldFile); deletedFiles.add(recentFmd); } } else { info("skip delete (potential user modifications): " + entry.getKey()); } } else { info("skip delete (no longer exists): " + entry.getKey()); notFoundFiles.add(oldFmd); } } for (FileMetaData fmd : scmFiles) { filesToScan.remove(fmd.getFileRelativePath()); } for (FileMetaData fmd : deletedFiles) { filesToScan.remove(fmd.getFileRelativePath()); } for (FileMetaData fmd : notFoundFiles) { filesToScan.remove(fmd.getFileRelativePath()); } info("rewrite file tracker metadata: " + getFilename()); saveToProjectDir(filesToScan, projectDir); return deletedFiles; }
From source file:org.owasp.benchmark.score.report.Scatter.java
private void dedupify(HashMap<Point2D, String> map) { for (Entry<Point2D, String> e1 : map.entrySet()) { Entry<Point2D, String> e2 = getMatch(map, e1); while (e2 != null) { StringBuilder label = new StringBuilder(); if (e1.getValue() != null) label.append(e1.getValue()); if (e1.getValue() != null && e2.getValue() != null) label.append(","); if (e2.getValue() != null) label.append(e2.getValue()); e1.setValue(label.toString()); e2.setValue(null);/* w w w . j av a2 s .c o m*/ e2 = getMatch(map, e1); } } }
From source file:Logica.SesionWeb.java
@Override public void notificarUsuariosLogeados(HashMap<String, Usuario> usuariosConectados) { try {/* w ww . ja v a2s .c o m*/ if (sesion.isOpen()) { JSONObject objetoJSON = new JSONObject(); JSONArray usuarios = new JSONArray(); for (Map.Entry<String, Usuario> entry : usuariosConectados.entrySet()) { String nick = entry.getKey(); usuarios.put(nick); } objetoJSON.put("usuarios", usuarios); objetoJSON.append("tipo", "CONTACTOS"); sesion.getBasicRemote().sendText(objetoJSON.toString()); } } catch (IOException ex) { Logger.getLogger(SesionWeb.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.android.providers.contacts.ContactsSyncAdapter.java
private static <A, B> HashMap<B, A> swapMap(HashMap<A, B> originalMap) { HashMap<B, A> newMap = new HashMap<B, A>(); for (Map.Entry<A, B> entry : originalMap.entrySet()) { final B originalValue = entry.getValue(); if (newMap.containsKey(originalValue)) { throw new IllegalArgumentException("value " + originalValue + " was already encountered"); }// w w w.j a v a 2 s.c o m newMap.put(originalValue, entry.getKey()); } return newMap; }
From source file:edu.lternet.pasta.portal.statistics.GrowthStats.java
private Long[] buildSortedList(HashMap<String, Long> map) { Long[] list = new Long[map.size()]; int i = 0;/*ww w .j a v a 2 s . co m*/ for (Map.Entry<String, Long> entry : map.entrySet()) { list[i++] = entry.getValue(); } Arrays.sort(list); return list; }