List of usage examples for java.util Map toString
public String toString()
From source file:test.dynamotest.dynamotest.java
public static void test_dynamo_db_query() { AmazonDynamoDB client = DynamoDBConnection.getDynamoDBClient(); Map<String, AttributeValue> expressionAttributeValues = new HashMap<>(); Map<String, String> expressionAttributeNames = new HashMap<>(); expressionAttributeValues.put(":given", new AttributeValue().withS("kazem")); expressionAttributeNames.put("#name", "name"); expressionAttributeNames.put("#jsondocument", "json-document"); ScanRequest scanRequest = new ScanRequest().withTableName(DynamoDBConnection.PATIENT_TABLE) .withFilterExpression(//from ww w . j a v a 2 s.c o m "(#jsondocument.#name[0].given[0] = :given) AND (#jsondocument.#name[0].given[0] = :given)") .withExpressionAttributeNames(expressionAttributeNames) .withExpressionAttributeValues(expressionAttributeValues); ScanResult result = client.scan(scanRequest); System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); for (Map<String, AttributeValue> item : result.getItems()) { System.out.println(item.toString()); } System.out.println("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); }
From source file:com.datumbox.opensource.examples.DPMMExample.java
/** * Demo of Dirichlet Process Mixture Model with Gaussian *//*from www.j av a2 s .c o m*/ public static void GDPMM() { System.out.println("Gaussian DPMM"); //Data points to cluster List<Point> pointList = new ArrayList<>(); //cluster 1 pointList.add(new Point(0, new ArrayRealVector(new double[] { 5.0, 1.0 }))); pointList.add(new Point(1, new ArrayRealVector(new double[] { 5.1, 1.1 }))); pointList.add(new Point(2, new ArrayRealVector(new double[] { 4.9, 0.9 }))); //cluster 2 pointList.add(new Point(3, new ArrayRealVector(new double[] { 15.0, 11.0 }))); pointList.add(new Point(4, new ArrayRealVector(new double[] { 15.1, 11.1 }))); pointList.add(new Point(5, new ArrayRealVector(new double[] { 14.9, 10.9 }))); //cluster 3 pointList.add(new Point(6, new ArrayRealVector(new double[] { 1.0, 5.0 }))); pointList.add(new Point(7, new ArrayRealVector(new double[] { 1.1, 5.1 }))); pointList.add(new Point(8, new ArrayRealVector(new double[] { 0.9, 4.9 }))); //Dirichlet Process parameter Integer dimensionality = 2; double alpha = 1.0; //Hyper parameters of Base Function int kappa0 = 0; int nu0 = 1; RealVector mu0 = new ArrayRealVector(new double[] { 0.0, 0.0 }); RealMatrix psi0 = new BlockRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }); //Create a DPMM object DPMM dpmm = new GaussianDPMM(dimensionality, alpha, kappa0, nu0, mu0, psi0); int maxIterations = 100; int performedIterations = dpmm.cluster(pointList, maxIterations); if (performedIterations < maxIterations) { System.out.println("Converged in " + String.valueOf(performedIterations)); } else { System.out.println("Max iterations of " + String.valueOf(performedIterations) + " reached. Possibly did not converge."); } //get a list with the point ids and their assignments Map<Integer, Integer> zi = dpmm.getPointAssignments(); System.out.println(zi.toString()); }
From source file:com.datumbox.opensource.examples.DPMMExample.java
/** * Demo of Dirichlet Process Mixture Model with Multinomial *//*www . j a v a 2s. c o m*/ public static void MDPMM() { System.out.println("Multinomial DPMM"); //Data points to cluster List<Point> pointList = new ArrayList<>(); //cluster 1 pointList.add(new Point(0, new ArrayRealVector(new double[] { 10.0, 13.0, 5.0, 6.0, 5.0, 4.0, 0.0, 0.0, 0.0, 0.0 }))); pointList.add(new Point(1, new ArrayRealVector(new double[] { 11.0, 11.0, 6.0, 7.0, 7.0, 3.0, 0.0, 0.0, 1.0, 0.0 }))); pointList.add(new Point(2, new ArrayRealVector(new double[] { 12.0, 12.0, 10.0, 16.0, 4.0, 6.0, 0.0, 0.0, 0.0, 2.0 }))); //cluster 2 pointList.add(new Point(3, new ArrayRealVector(new double[] { 10.0, 13.0, 0.0, 0.0, 0.0, 0.0, 5.0, 6.0, 5.0, 4.0 }))); pointList.add(new Point(4, new ArrayRealVector(new double[] { 11.0, 11.0, 0.0, 0.0, 1.0, 0.0, 6.0, 7.0, 7.0, 3.0 }))); pointList.add(new Point(5, new ArrayRealVector(new double[] { 12.0, 12.0, 0.0, 0.0, 0.0, 2.0, 10.0, 16.0, 4.0, 6.0 }))); //cluster 3 pointList.add(new Point(6, new ArrayRealVector(new double[] { 10.0, 13.0, 5.0, 6.0, 5.0, 4.0, 5.0, 6.0, 5.0, 4.0 }))); pointList.add(new Point(7, new ArrayRealVector(new double[] { 11.0, 11.0, 6.0, 7.0, 7.0, 3.0, 6.0, 7.0, 7.0, 3.0 }))); pointList.add(new Point(8, new ArrayRealVector(new double[] { 12.0, 12.0, 10.0, 16.0, 4.0, 6.0, 10.0, 16.0, 4.0, 6.0 }))); //Dirichlet Process parameter Integer dimensionality = 10; double alpha = 1.0; //Hyper parameters of Base Function double alphaWords = 1.0; //Create a DPMM object DPMM dpmm = new MultinomialDPMM(dimensionality, alpha, alphaWords); int maxIterations = 100; int performedIterations = dpmm.cluster(pointList, maxIterations); if (performedIterations < maxIterations) { System.out.println("Converged in " + String.valueOf(performedIterations)); } else { System.out.println("Max iterations of " + String.valueOf(performedIterations) + " reached. Possibly did not converge."); } //get a list with the point ids and their assignments Map<Integer, Integer> zi = dpmm.getPointAssignments(); System.out.println(zi.toString()); }
From source file:org.deeplearning4j.examples.dataexamples.BasicCSVClassifier.java
public static void logAnimals(Map<Integer, Map<String, Object>> animals) { for (Map<String, Object> a : animals.values()) log.info(a.toString()); }
From source file:de.fhg.fokus.odp.portal.managedatasets.utils.HashMapUtils.java
/** * Map to meta data./*from w w w . j a va2s . c om*/ * * @param map * the map * @return the meta data bean * @throws ParseException * the parse exception */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static MetaDataBean mapToMetaData(Map map) throws ParseException { log.debug("HashMap to convert to MetaDataBean: " + map.toString()); MetaDataBean metaData = new MetaDataBean(); metaData.setTitle((String) map.get("title")); metaData.setName((String) map.get("name")); metaData.setAuthor((String) map.get("author")); metaData.setAuthor_email((String) map.get("author_email")); metaData.setMaintainer((String) map.get("maintainer")); metaData.setMaintainer_email((String) map.get("maintainer_email")); metaData.setUrl((String) map.get("url")); metaData.setNotes((String) map.get("notes")); metaData.setLicense_id((String) map.get("license_id")); metaData.setCkanId((String) map.get("id")); metaData.setMetadata_created(DateUtils.stringToDateMetaData((String) map.get("metadata_created"))); metaData.setMetadata_modified(DateUtils.stringToDateMetaData((String) map.get("metadata_modified"))); Map<String, String> extrasMap = new HashMap<String, String>(); extrasMap = (Map) map.get("extras"); metaData.setDate_released(DateUtils.stringToDateTemporalCoverage(extrasMap.get("date_released"))); metaData.setDate_updated(DateUtils.stringToDateTemporalCoverage(extrasMap.get("date_updated"))); metaData.setTemporal_coverage_from(extrasMap.get("temporal_coverage_from")); metaData.setTemporal_coverage_to(extrasMap.get("temporal_coverage_to")); metaData.setTemporal_granularity(extrasMap.get("temporal_granularity")); metaData.setGeographical_coverage(extrasMap.get("geographical_coverage")); metaData.setGeographical_granularity(extrasMap.get("geographical_granularity")); metaData.setOthers(extrasMap.get("others")); metaData.setGroups((List<String>) map.get("groups")); StringBuilder tagsBuilder = new StringBuilder(); for (String tag : (List<String>) map.get("tags")) { tag.trim(); tagsBuilder.append(tag).append(","); } if (tagsBuilder.length() > 0) { tagsBuilder = tagsBuilder.deleteCharAt(tagsBuilder.length() - 1); } metaData.setTags(tagsBuilder.toString()); metaData.setVersion((String) map.get("version")); List<Map<String, String>> resorcesList; resorcesList = (List) map.get("resources"); for (Map<String, String> resMap : resorcesList) { Resource resource = new Resource(); resource.setFormat(resMap.get("format").toUpperCase()); resource.setDescription(resMap.get("description")); resource.setUrl(resMap.get("url")); resource.setLanguage(resMap.get("language")); metaData.getResources().add(resource); } return metaData; }
From source file:net.itransformers.bgpPeeringMap.BgpPeeringMap.java
public static void discover() throws Exception { Map<String, String> settings = loadProperties(new File(settingsFile)); logger.info("Settings" + settings.toString()); String folderPlaceholder = settings.get("output.dir"); File outputDir = new File(projectDir + File.separator + folderPlaceholder, label); System.out.println(outputDir.getAbsolutePath()); boolean result = outputDir.mkdir(); File graphmlDir = new File(outputDir, "undirected"); result = outputDir.mkdir();/*from w w w . ja va2 s . c o m*/ XsltTransformer transformer = new XsltTransformer(); logger.info("SNMP walk start"); byte[] rawData = snmpWalk(settings); logger.info("SNMP walk end"); File rawDataFile = new File(outputDir, "raw-data-bgpPeeringMap.xml"); FileUtils.writeStringToFile(rawDataFile, new String(rawData)); logger.info("Raw-data written to a file in folder " + outputDir); logger.info("First-transformation has started with xsltTransformator " + settings.get("xsltFileName1")); ByteArrayOutputStream outputStream1 = new ByteArrayOutputStream(); File xsltFileName1 = new File(projectDir, settings.get("xsltFileName1")); ByteArrayInputStream inputStream1 = new ByteArrayInputStream(rawData); transformer.transformXML(inputStream1, xsltFileName1, outputStream1, settings); logger.info("First transformation finished"); File intermediateDataFile = new File(outputDir, "intermediate-bgpPeeringMap.xml"); FileUtils.writeStringToFile(intermediateDataFile, new String(outputStream1.toByteArray())); logger.trace("First transformation output"); logger.trace(outputStream1.toString()); logger.info("Second transformation started with xsltTransformator " + settings.get("xsltFileName2")); ByteArrayOutputStream outputStream2 = new ByteArrayOutputStream(); File xsltFileName2 = new File(projectDir, settings.get("xsltFileName2")); ByteArrayInputStream inputStream2 = new ByteArrayInputStream(outputStream1.toByteArray()); transformer.transformXML(inputStream2, xsltFileName2, outputStream2, settings); logger.info("Second transformation info"); logger.trace("Second transformation Graphml output"); logger.trace(outputStream2.toString()); ByteArrayInputStream inputStream3 = new ByteArrayInputStream(outputStream2.toByteArray()); ByteArrayOutputStream outputStream3 = new ByteArrayOutputStream(); File xsltFileName3 = new File(System.getProperty("base.dir"), settings.get("xsltFileName3")); transformer.transformXML(inputStream3, xsltFileName3, outputStream3, null); File outputFile = new File(graphmlDir, "undirected-bgpPeeringMap.graphml"); FileUtils.writeStringToFile(outputFile, new String(outputStream3.toByteArray())); logger.info("Output Graphml saved in a file in" + graphmlDir); //FileUtils.writeStringToFile(nodesFileListFile, "bgpPeeringMap.graphml"); FileWriter writer = new FileWriter(new File(outputDir, "undirected" + ".graphmls"), true); writer.append("undirected-bgpPeeringMap.graphml").append("\n"); writer.close(); }
From source file:com.apptentive.android.sdk.module.metric.MetricModule.java
public static void sendMetric(Context context, Event.EventLabel type, String trigger, Map<String, String> data) { Configuration config = Configuration.load(context); if (config.isMetricsEnabled()) { Log.v("Sending Metric: %s, trigger: %s, data: %s", type.getLabelName(), trigger, data != null ? data.toString() : "null"); Event event = new Event(type.getLabelName(), trigger); event.putData(data);/* www .ja va2s . co m*/ EventManager.sendEvent(context, event); } }
From source file:yodlee.ysl.api.io.HTTP.java
public static String doGet(String url, Map<String, String> sessionTokens) throws IOException, URISyntaxException { String mn = "doIO(GET :" + url + ", sessionTokens = " + sessionTokens.toString() + " )"; System.out.println(fqcn + " :: " + mn); URL myURL = new URL(url); System.out.println(fqcn + " :: " + mn + ": Request URL=" + url.toString()); HttpURLConnection conn = (HttpURLConnection) myURL.openConnection(); //conn.setRequestMethod("GET"); conn.setRequestProperty("User-Agent", userAgent); //conn.setRequestProperty("Content-Type", contentTypeJSON); //conn.setRequestProperty("Accept",); conn.setRequestProperty("Authorization", sessionTokens.toString()); conn.setDoOutput(true);//from w w w . j a v a 2s.c o m System.out.println(fqcn + " :: " + mn + " : " + "Sending 'HTTP GET' request"); int responseCode = conn.getResponseCode(); System.out.println(fqcn + " :: " + mn + " : " + "Response Code : " + responseCode); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; StringBuilder jsonResponse = new StringBuilder(); while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); jsonResponse.append(inputLine); } in.close(); System.out.println(fqcn + " :: " + mn + " : " + jsonResponse.toString()); return new String(jsonResponse); }
From source file:yodlee.ysl.api.io.HTTP.java
public static String doPut(String url, String param, Map<String, String> sessionTokens) throws IOException, URISyntaxException { String mn = "doIO(PUT :" + url + ", sessionTokens = " + sessionTokens.toString() + " )"; System.out.println(fqcn + " :: " + mn); param = param.replace("\"", "%22").replace("{", "%7B").replace("}", "%7D").replace(",", "%2C") .replace("[", "%5B").replace("]", "%5D").replace(":", "%3A").replace(" ", "+"); String processedURL = url + "?MFAChallenge=" + param;//"%7B%22loginForm%22%3A%7B%22formType%22%3A%22token%22%2C%22mfaTimeout%22%3A%2299380%22%2C%22row%22%3A%5B%7B%22id%22%3A%22token_row%22%2C%22label%22%3A%22Security+Key%22%2C%22form%22%3A%220001%22%2C%22fieldRowChoice%22%3A%220001%22%2C%22field%22%3A%5B%7B%22id%22%3A%22token%22%2C%22name%22%3A%22tokenValue%22%2C%22type%22%3A%22text%22%2C%22value%22%3A%22123456%22%2C%22isOptional%22%3Afalse%2C%22valueEditable%22%3Atrue%2C%22maxLength%22%3A%2210%22%7D%5D%7D%5D%7D%7D"; URL myURL = new URL(processedURL); System.out.println(fqcn + " :: " + mn + ": Request URL=" + processedURL.toString()); HttpURLConnection conn = (HttpURLConnection) myURL.openConnection(); conn.setRequestMethod("PUT"); conn.setRequestProperty("Accept-Charset", "UTF-8"); conn.setRequestProperty("Content-Type", contentTypeURLENCODED); conn.setRequestProperty("Authorization", sessionTokens.toString()); conn.setDoOutput(true);/*from w w w . ja v a2s. c om*/ System.out.println(fqcn + " :: " + mn + " : " + "Sending 'HTTP PUT' request"); int responseCode = conn.getResponseCode(); System.out.println(fqcn + " :: " + mn + " : " + "Response Code : " + responseCode); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; StringBuilder jsonResponse = new StringBuilder(); while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); jsonResponse.append(inputLine); } in.close(); System.out.println(fqcn + " :: " + mn + " : " + jsonResponse.toString()); return new String(jsonResponse); }
From source file:yodlee.ysl.api.io.HTTP.java
public static String doPutNew(String url, String param, Map<String, String> sessionTokens) throws IOException, URISyntaxException { String mn = "doIO(PUT :" + url + ", sessionTokens = " + sessionTokens.toString() + " )"; System.out.println(fqcn + " :: " + mn); //param=param.replace("\"", "%22").replace("{", "%7B").replace("}", "%7D").replace(",", "%2C").replace("[", "%5B").replace("]", "%5D").replace(":", "%3A").replace(" ", "+"); String processedURL = url;//+"?MFAChallenge="+param;//"%7B%22loginForm%22%3A%7B%22formType%22%3A%22token%22%2C%22mfaTimeout%22%3A%2299380%22%2C%22row%22%3A%5B%7B%22id%22%3A%22token_row%22%2C%22label%22%3A%22Security+Key%22%2C%22form%22%3A%220001%22%2C%22fieldRowChoice%22%3A%220001%22%2C%22field%22%3A%5B%7B%22id%22%3A%22token%22%2C%22name%22%3A%22tokenValue%22%2C%22type%22%3A%22text%22%2C%22value%22%3A%22123456%22%2C%22isOptional%22%3Afalse%2C%22valueEditable%22%3Atrue%2C%22maxLength%22%3A%2210%22%7D%5D%7D%5D%7D%7D"; URL myURL = new URL(processedURL); System.out.println(fqcn + " :: " + mn + ": Request URL=" + processedURL.toString()); HttpURLConnection conn = (HttpURLConnection) myURL.openConnection(); conn.setRequestMethod("PUT"); conn.setRequestProperty("Accept-Charset", "UTF-8"); conn.setRequestProperty("Content-Type", contentTypeJSON); conn.setRequestProperty("Authorization", sessionTokens.toString()); conn.setDoOutput(true);//from w w w.ja v a 2 s . c o m DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); wr.writeBytes(param); wr.flush(); wr.close(); System.out.println(fqcn + " :: " + mn + " : " + "Sending 'HTTP PUT' request"); int responseCode = conn.getResponseCode(); System.out.println(fqcn + " :: " + mn + " : " + "Response Code : " + responseCode); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; StringBuilder jsonResponse = new StringBuilder(); while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); jsonResponse.append(inputLine); } in.close(); System.out.println(fqcn + " :: " + mn + " : " + jsonResponse.toString()); return new String(jsonResponse); }