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:de.lmu.ifi.dbs.jfeaturelib.utils.Extractor.java
/** * submits an ExtractionTask for each tuple to the thread pool * * @param tuples//from w ww . j av a 2s . co m */ private void processImages(HashMap<File, File> tuples) { log.debug("process images"); for (Map.Entry<File, File> entry : tuples.entrySet()) { pool.submit(new ExtractionTask(entry.getKey(), entry.getValue())); } }
From source file:com.yahoo.ycsb.db.JdbcDBClient.java
@Override public Status update(String tableName, String key, HashMap<String, ByteIterator> values) { try {//from ww w . j av a 2s . c o m int i = 0; StringBuilder update = new StringBuilder("UPDATE "); update.append(tableName); update.append(" SET "); for (Map.Entry<String, ByteIterator> entry : values.entrySet()) { String field = entry.getValue().toString(); if (i > 0) { update.append(", "); } update.append(COLUMN_PREFIX); update.append(i); update.append("="); update.append("'"); update.append(StringEscapeUtils.escapeSql(field)); update.append("'"); i++; } update.append(" WHERE "); update.append(PRIMARY_KEY); update.append(" = "); update.append("'"); update.append(StringEscapeUtils.escapeSql(key)); update.append("'"); Statement updateStatement = getShardConnectionByKey(key).createStatement(); int result = updateStatement.executeUpdate(update.toString()); if (result == 1) { return Status.OK; } return Status.UNEXPECTED_STATE; } catch (SQLException e) { System.err.println("Error in processing update to table: " + tableName + e); return Status.ERROR; } }
From source file:io.personium.test.jersey.PersoniumRestAdapter.java
/** * Stream?PUT.//from www . j ava 2 s.c o m * @param url PUT?URL * @param headers ?? * @param is PUT? * @return DcResponse * @throws PersoniumException DAO */ public final PersoniumResponse put(final String url, final HashMap<String, String> headers, final InputStream is) throws PersoniumException { String contentType = headers.get(HttpHeaders.CONTENT_TYPE); HttpUriRequest req = makePutRequestByStream(url, contentType, is); for (Map.Entry<String, String> entry : headers.entrySet()) { req.setHeader(entry.getKey(), entry.getValue()); } req.addHeader("X-Personium-Version", PersoniumCoreTestConfig.getCoreVersion()); debugHttpRequest(req, "body is InputStream..."); PersoniumResponse res = request(req); return res; }
From source file:br.unicamp.cst.learning.QLearning.java
/** * This print Q values./*from w w w . ja v a 2s . c om*/ */ public void printQ() { System.out.println("------ Printed Q -------"); Iterator<Entry<String, HashMap<String, Double>>> itS = this.Q.entrySet().iterator(); while (itS.hasNext()) { Entry<String, HashMap<String, Double>> pairs = itS.next(); HashMap<String, Double> tempA = pairs.getValue(); Iterator<Entry<String, Double>> itA = tempA.entrySet().iterator(); double val = 0; System.out.print("State(" + pairs.getKey() + ") actions: "); while (itA.hasNext()) { Entry<String, Double> pairsA = itA.next(); val = pairsA.getValue(); System.out.print("[" + pairsA.getKey() + ": " + val + "] "); } System.out.println(""); } System.out.println("----------------------------"); }
From source file:com.microsoft.azure.storage.core.Utility.java
/** * Serializes the parsed StorageException. If an exception is encountered, returns empty string. * /*from w w w.java2 s . c om*/ * @param ex * The StorageException to serialize. * @param opContext * The operation context which provides the logger. */ public static void logHttpError(StorageException ex, OperationContext opContext) { if (Logger.shouldLog(opContext)) { try { StringBuilder bld = new StringBuilder(); bld.append("Error response received. "); bld.append("HttpStatusCode= "); bld.append(ex.getHttpStatusCode()); bld.append(", HttpStatusMessage= "); bld.append(ex.getMessage()); bld.append(", ErrorCode= "); bld.append(ex.getErrorCode()); StorageExtendedErrorInformation extendedError = ex.getExtendedErrorInformation(); if (extendedError != null) { bld.append(", ExtendedErrorInformation= {ErrorMessage= "); bld.append(extendedError.getErrorMessage()); HashMap<String, String[]> details = extendedError.getAdditionalDetails(); if (details != null) { bld.append(", AdditionalDetails= { "); for (Entry<String, String[]> detail : details.entrySet()) { bld.append(detail.getKey()); bld.append("= "); for (String value : detail.getValue()) { bld.append(value); } bld.append(","); } bld.setCharAt(bld.length() - 1, '}'); } bld.append("}"); } Logger.debug(opContext, bld.toString()); } catch (Exception e) { // Do nothing } } }
From source file:com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.java
private void createIntegrationResponses(Integration integration, HashMap<String, HashMap> integ) { // todo: avoid unchecked casts HashMap<String, HashMap> responses = (HashMap<String, HashMap>) integ.get("responses"); responses.entrySet().forEach(e -> { String pattern = e.getKey().equals("default") ? null : e.getKey(); HashMap response = e.getValue(); String status = (String) response.get("statusCode"); PutIntegrationResponseInput input = new PutIntegrationResponseInput() .withResponseParameters((Map<String, String>) response.get("responseParameters")) .withResponseTemplates((Map<String, String>) response.get("responseTemplates")) .withSelectionPattern(pattern); integration.putIntegrationResponse(input, status); });//from w w w . j ava 2 s . c om }
From source file:br.unicamp.cst.learning.QLearning.java
/** * Gets all actions from state./*from w ww. j av a 2s . co m*/ * @param state * @return actons */ public String getAllActionsFromState(String state) { String actions = ""; if (this.Q.get(state) != null) { HashMap<String, Double> actionsH = this.Q.get(state); Iterator<Entry<String, Double>> it = actionsH.entrySet().iterator(); while (it.hasNext()) { Entry<String, Double> pairs = it.next(); double qVal = (Double) pairs.getValue(); String act = (String) pairs.getKey(); actions = actions + "{" + act + ":" + qVal + "} "; } } else { actions = "{}"; } return actions; }
From source file:de.ingrid.importer.udk.strategy.v1.IDCStrategy1_0_6_fixSysListInspire.java
protected void fixSysList5100() throws Exception { if (log.isInfoEnabled()) { log.info("Fixing syslist 5100 values in sys_list and t011_obj_serv ..."); }//from w w w . j a v a 2s. co m // new syslist 5100 values HashMap<Integer, String> mapKeyToNewValueList = new HashMap<Integer, String>(); mapKeyToNewValueList.put(1, "Suchdienste"); mapKeyToNewValueList.put(2, "Darstellungsdienste"); mapKeyToNewValueList.put(3, "Download-Dienste"); mapKeyToNewValueList.put(4, "Transformationsdienste"); mapKeyToNewValueList.put(5, "Dienste zum Abrufen von Geodatendiensten"); mapKeyToNewValueList.put(6, "Sonstige Dienste"); Iterator<Entry<Integer, String>> entryIt = mapKeyToNewValueList.entrySet().iterator(); while (entryIt.hasNext()) { Entry<Integer, String> entry = entryIt.next(); // fix sys_list int numUpdated = jdbc.executeUpdate("UPDATE sys_list SET " + "name = '" + entry.getValue() + "' " + "where " + "lst_id = 5100" + " and lang_id = 'de'" + " and entry_id = " + entry.getKey()); if (log.isDebugEnabled()) { log.debug("sys_list 5100: updated " + numUpdated + " rows -> entry_id(" + entry.getKey() + "), " + "new name(" + entry.getValue() + ")"); } // fix data: existing keys with wrong value ! ONLY IF GERMAN ! if ("de".equals(UtilsLanguageCodelist.getShortcutFromCode(readCatalogLanguageKey()))) { numUpdated = jdbc.executeUpdate("UPDATE t011_obj_serv SET " + "type_value = '" + entry.getValue() + "' " + "where " + "type_key = " + entry.getKey()); if (log.isDebugEnabled()) { log.debug("t011_obj_serv: updated " + numUpdated + " rows -> existing type_key(" + entry.getKey() + "), " + "new type_value(" + entry.getValue() + ")"); } } } }
From source file:com.userweave.domain.service.impl.SurveyStatisticsServiceImpl.java
@Override public Set<Entry<String, Integer>> evaluateSurveyExecutionsInLocales(List<SurveyExecution> surveyExecutions) { HashMap<String, Integer> map = new HashMap<String, Integer>(); for (SurveyExecution exec : surveyExecutions) { if (exec.getLocale() != null && exec.getState() != SurveyExecutionState.INVALID && exec.getState() != SurveyExecutionState.NOT_STARTED) { String lang = exec.getLocale().getDisplayLanguage(); if (map.containsKey(lang)) { map.put(lang, new Integer(map.get(lang) + 1)); } else { map.put(lang, new Integer(1)); }//from ww w . j a va 2 s . c o m } } return map.entrySet(); }
From source file:com.globalsight.machineTranslation.domt.DoMTProxy.java
private HashMap<Integer, HashMap<Integer, String>> getTargetGroups(HashMap<Integer, String> targets) { HashMap<Integer, HashMap<Integer, String>> result = new HashMap<Integer, HashMap<Integer, String>>(); Iterator<Entry<Integer, String>> trgIt = targets.entrySet().iterator(); while (trgIt.hasNext()) { Entry<Integer, String> entry = trgIt.next(); int[] indexes = getIndexes(entry.getKey()); HashMap<Integer, String> subSet = result.get(indexes[0]); if (subSet == null) { subSet = new HashMap<Integer, String>(); result.put(indexes[0], subSet); }//from w w w . j a va 2 s.c o m subSet.put(indexes[1], entry.getValue()); } return result; }