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:org.mobicents.charging.server.ratingengine.http.HTTPClientSbb.java
private HttpPost buildHTTPRequest(HashMap params) { HttpPost httpPost = new HttpPost(httpURLString); tracer.info("------ HTTP Request Params to Rating Engine ------"); String httpRequestParams = ""; List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(params.size()); for (Object o : params.entrySet()) { Map.Entry entry = (Map.Entry) o; String key = null;/*from www .j av a2 s . co m*/ String val = null; if (entry.getKey() != null) { key = entry.getKey().toString(); } if (entry.getValue() != null) { val = entry.getValue().toString(); } if (key == null || val == null) { continue; } nameValuePairs.add(new BasicNameValuePair(key, val)); httpRequestParams += key + "=" + val + "; "; } try { httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } tracer.info(httpRequestParams); return httpPost; }
From source file:freenet.client.async.ContainerInserter.java
private Metadata makeManifest(HashMap<String, Object> manifestElements, String archivePrefix) { SimpleManifestComposer smc = new Metadata.SimpleManifestComposer(); for (Map.Entry<String, Object> me : manifestElements.entrySet()) { String name = me.getKey(); Object o = me.getValue(); if (o instanceof HashMap) { @SuppressWarnings("unchecked") HashMap<String, Object> hm = (HashMap<String, Object>) o; HashMap<String, Object> subMap = new HashMap<String, Object>(); //System.out.println("Decompose: "+name+" (SubDir)"); smc.addItem(name, makeManifest(hm, archivePrefix + name + '/')); if (logDEBUG) Logger.debug(this, "Sub map for " + name + " : " + subMap.size() + " elements from " + hm.size()); } else if (o instanceof Metadata) { //already Metadata, take it as is //System.out.println("Decompose: "+name+" (Metadata)"); smc.addItem(name, (Metadata) o); } else {//from ww w . ja v a 2s . c o m ManifestElement element = (ManifestElement) o; String mimeType = element.getMimeType(); ClientMetadata cm; if (mimeType == null || mimeType.equals(DefaultMIMETypes.DEFAULT_MIME_TYPE)) cm = null; else cm = new ClientMetadata(mimeType); Metadata m; if (element.targetURI != null) { //System.out.println("Decompose: "+name+" (ManifestElement, Redirect)"); m = new Metadata(DocumentType.SIMPLE_REDIRECT, null, null, element.targetURI, cm); } else { //System.out.println("Decompose: "+name+" (ManifestElement, Data)"); containerItems.add(new ContainerElement(element.getData(), archivePrefix + name)); m = new Metadata(DocumentType.ARCHIVE_INTERNAL_REDIRECT, null, null, archivePrefix + element.fullName, cm); } smc.addItem(name, m); } } return smc.getMetadata(); }
From source file:com.elsevier.spark_xml_utils.xpath.XPathProcessor.java
/** * Set the namespaces in the XPathCompiler. * //from w w w . j a va 2 s . c o m * @param xpathCompiler * @param namespaceMappings Namespace prefix to Namespace uri mappings */ private void setPrefixNamespaceMappings(XPathCompiler xpathCompiler, HashMap<String, String> namespaceMappings) { if (namespaceMappings != null) { // Get the mappings Set<Entry<String, String>> mappings = namespaceMappings.entrySet(); // If mappings exist, set the namespaces if (mappings != null) { Iterator<Entry<String, String>> it = mappings.iterator(); while (it.hasNext()) { Entry<String, String> entry = it.next(); xpathCompiler.declareNamespace(entry.getKey(), entry.getValue()); } } } // Add in the defaults xpathCompiler.declareNamespace("xml", NamespaceConstant.XML); xpathCompiler.declareNamespace("xs", NamespaceConstant.SCHEMA); xpathCompiler.declareNamespace("fn", NamespaceConstant.FN); }
From source file:org.imsglobal.basiclti.provider.servlet.filter.BasicLTISecurityFilterTest.java
public void testDoFilterHMACSHA1() throws Exception { ServletRunner runner = new ServletRunner(BasicLTISecurityFilterTest.class.getResourceAsStream("web.xml"), "/admin"); ServletUnitClient client = runner.newClient(); OAuthServiceProvider serviceProvider = new OAuthServiceProvider(null, null, null); OAuthConsumer consumer = new OAuthConsumer(null, "one", "secret", serviceProvider); OAuthAccessor accessor = new OAuthAccessor(consumer); HashMap<String, String> map = new HashMap<String, String>(); map.put("lti_message_type", "basic-lti-launch-request"); map.put("roles", "Teacher"); map.put("resource_link_id", "LINK_ID"); map.put("user_id", "USER_ID"); map.put("context_id", "CONTEXT_ID"); map.put(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1); OAuthMessage newRequestMessage = accessor.newRequestMessage("GET", "http://localhost/admin/test", map.entrySet()); GetMethodWebRequest method = new GetMethodWebRequest("http://localhost/admin/test"); List<Entry<String, String>> parameters = newRequestMessage.getParameters(); for (Entry<String, String> entry : parameters) { method.setParameter(entry.getKey(), entry.getValue()); }//w w w. ja v a2 s . c om WebResponse response = client.getResponse(method); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getInputStream())); try { String readLine = reader.readLine(); assertEquals("OK!", readLine); } finally { reader.close(); } }
From source file:com.roncoo.pay.reconciliation.fileDown.impl.WinXinFileDown.java
/** * ????xml//from w w w . ja v a 2 s. c o m * * @param appId * * @param mchId * * @param billDate * , ?(???) * @param billType * ? * @param appSecret * , ?? * @return */ public String generateXml() { HashMap<String, String> params = new HashMap<String, String>(); params.put("appid", appid); params.put("mch_id", mch_id); params.put("bill_date", bill_date); params.put("bill_type", bill_type); // ??32??? params.put("nonce_str", WeiXinBaseUtils.createNoncestr()); // for (Iterator<Entry<String, String>> it = params.entrySet().iterator(); it.hasNext();) { Entry<String, String> entry = it.next(); if (StringUtils.isEmpty(entry.getValue())) { it.remove(); } } String sign = SignHelper.getSign(params, appSecret); params.put("sign", sign.toUpperCase()); return WeiXinBaseUtils.arrayToXml(params); }
From source file:org.imsglobal.basiclti.provider.servlet.filter.BasicLTISecurityFilterTest.java
public void testDoFilterPlain() throws Exception { ServletRunner runner = new ServletRunner(BasicLTISecurityFilterTest.class.getResourceAsStream("web.xml"), "/admin"); ServletUnitClient client = runner.newClient(); OAuthServiceProvider serviceProvider = new OAuthServiceProvider(null, null, null); OAuthConsumer consumer = new OAuthConsumer(null, "one", "secret", serviceProvider); OAuthAccessor accessor = new OAuthAccessor(consumer); HashMap<String, String> map = new HashMap<String, String>(); map.put("lti_message_type", "basic-lti-launch-request"); map.put("roles", "Teacher"); map.put("resource_link_id", "LINK_ID"); map.put("user_id", "USER_ID"); map.put("context_id", "CONTEXT_ID"); // map.put(OAuth.OAUTH_SIGNATURE_METHOD, "PLAINTEXT"); OAuthMessage newRequestMessage = accessor.newRequestMessage("GET", "http://localhost/admin/test", map.entrySet()); GetMethodWebRequest method = new GetMethodWebRequest("http://localhost/admin/test"); List<Entry<String, String>> parameters = newRequestMessage.getParameters(); for (Entry<String, String> entry : parameters) { method.setParameter(entry.getKey(), entry.getValue()); }//www . j a v a 2 s . c o m WebResponse response = client.getResponse(method); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getInputStream())); try { String readLine = reader.readLine(); assertEquals("OK!", readLine); } finally { reader.close(); } }
From source file:com.example.zillowapplication.SlidingTabsBasicFragment.java
public void passImagesToFragment(HashMap<Integer, Bitmap> yearToImageMap) { for (Entry<Integer, Bitmap> entry : yearToImageMap.entrySet()) { chartHeaders.add(String.format(Constants.CHART_HEADER, entry.getKey() + (entry.getKey() > 1 ? " years" : " year"))); chartImages.add(new BitmapDrawable(getResources(), entry.getValue())); }//from w w w .j a v a2 s. c o m //TODO Handle Timeout }
From source file:com.k42b3.neodym.oauth.Oauth.java
private String getNormalizedParameters(HashMap<String, String> params) { Iterator<Entry<String, String>> it = params.entrySet().iterator(); List<String> keys = new ArrayList<String>(); while (it.hasNext()) { Entry<String, String> e = it.next(); keys.add(e.getKey());/* w w w. ja v a 2s . c om*/ } // sort params Collections.sort(keys); // build normalized params StringBuilder normalizedParams = new StringBuilder(); for (int i = 0; i < keys.size(); i++) { normalizedParams.append(urlEncode(keys.get(i)) + "=" + urlEncode(params.get(keys.get(i))) + "&"); } String str = normalizedParams.toString(); // remove trailing & str = str.substring(0, str.length() - 1); return str; }
From source file:com.nuance.expertassistant.ReadExcelFile.java
public HashMap<String, ArrayList<HashMap<String, String>>> evaluateFromRatingDB(String ProjectID) { HashMap<String, ArrayList<HashMap<String, String>>> EvalMap = new HashMap<String, ArrayList<HashMap<String, String>>>(); HashMap<String, HashMap<String, String>> QAList = new HashMap<String, HashMap<String, String>>(); try {/* w w w . j a v a 2s .c om*/ QAList = QueryDB.fetchQAList(ProjectID); Iterator it = QAList.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair1 = (Map.Entry) it.next(); HashMap<String, String> ratedResponses = (HashMap<String, String>) pair1.getValue(); String Question = pair1.getKey().toString(); Iterator it2 = ratedResponses.entrySet().iterator(); ArrayList<HashMap<String, String>> responseArray4Question = new ArrayList<HashMap<String, String>>(); while (it2.hasNext()) { Map.Entry pair2 = (Map.Entry) it2.next(); System.out.println(Question + " = " + pair2.getKey()); /** * *********************************** */ HashMap<String, String> queryAnalysis = new HashMap<String, String>(); System.out.println(" The QueryList String is " + Question); System.out.println(" The ExpectedResultList String is " + pair2.getKey()); queryAnalysis.put("Query", Question); queryAnalysis.put("ExpectedResult", pair2.getKey().toString()); queryAnalysis.put("UserRating", pair2.getValue().toString()); queryAnalysis.put("GoldResponses", String.valueOf(ratedResponses.size())); queryAnalysis.put("Found", "NO"); queryAnalysis.put("Rank", "-1"); queryAnalysis.put("PassageLength", "-1"); queryAnalysis.put("numResponses", "-1"); ArrayList<Integer> resultArray = new ArrayList<Integer>(); resultArray = retrieveAnswers(ProjectID, Question, pair2.getKey().toString()); System.out.println("Result Array" + resultArray.toString()); if (resultArray.get(0) == 1) { queryAnalysis.put("Found", "YES"); queryAnalysis.put("Rank", resultArray.get(1).toString()); queryAnalysis.put("PassageLength", resultArray.get(2).toString()); queryAnalysis.put("numResponses", resultArray.get(3).toString()); } responseArray4Question.add(queryAnalysis); /** * ************************************ */ } System.out.println("*************************************"); System.out.println("**************EVALUTE****************"); System.out.println("*************************************"); for (int i = 0; i < responseArray4Question.size(); i++) { System.out.println("" + responseArray4Question.get(i).get("Query")); System.out.println("" + responseArray4Question.get(i).get("ExpectedResult")); System.out.println("" + responseArray4Question.get(i).get("UserRating")); System.out.println("" + responseArray4Question.get(i).get("GoldResponses")); System.out.println("" + responseArray4Question.get(i).get("Found")); System.out.println("" + responseArray4Question.get(i).get("Rank")); System.out.println("" + responseArray4Question.get(i).get("PassageLength")); } EvalMap.put(Question, responseArray4Question); } } catch (Exception e) { e.printStackTrace(); return null; } System.out.println("*************************************"); System.out.println("**************Print EvalMap****************"); System.out.println("*************************************"); Iterator it = EvalMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ArrayList<HashMap<String, String>> responseArray = (ArrayList<HashMap<String, String>>) pair.getValue(); for (int i = 0; i < responseArray.size(); i++) { System.out.println("" + responseArray.get(i).get("Query")); System.out.println("" + responseArray.get(i).get("ExpectedResult")); System.out.println("" + responseArray.get(i).get("Found")); System.out.println("" + responseArray.get(i).get("Rank")); System.out.println("" + responseArray.get(i).get("PassageLength")); } } System.out.println("*************************************"); System.out.println("**************Print[ed] EvalMap****************"); System.out.println("*************************************"); return EvalMap; }
From source file:gr.forth.ics.isl.maze.restservices.X3mlServices.java
@GET @Path("/target_schema/coveredelements/{mappid}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public CoverageTargetSchemaList getCoveredElementsTargetSchema(@PathParam("mappid") String id) { try {//from www . j a v a 2 s . co m Document x3mlDocument = Utils.retreiveX3MLfile_toXML(id); X3ML x3ml = Utils.unmarshal_X3ML_WithID(id); CoverageTargetSchemaList results = new CoverageTargetSchemaList(); if (x3ml != null) { HashMap<String, String> x3mlClasses = X3MLUtils.findReferencedClasses(x3mlDocument, x3ml); HashMap<String, String> x3mlProp = X3MLUtils.findReferencedProperties(x3mlDocument, x3ml); for (Map.Entry<String, String> entry : x3mlClasses.entrySet()) { String label = entry.getKey().trim(); //x3mlClasses label String ns = entry.getValue().trim(); String uri = ns + label; results.addCoveredClass(uri); } for (Map.Entry<String, String> entry : x3mlProp.entrySet()) { String label = entry.getKey().trim(); //x3mlClasses label String ns = entry.getValue().trim(); String uri = ns + label; results.addCoveredProperty(uri); } } return results; } catch (Exception ex) { logger.error("Cannot generage covered elements target schema for Mapping:" + id, ex); return null; } }