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:keel.Algorithms.UnsupervisedLearning.AssociationRules.Visualization.keelassotiationrulesbarchart.ResultsProccessor.java
private void calcMeans() { //HashMap<String, Double> measuresFirst = algorithmMeasures.get(actualAlgorithm); for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet()) { String alg = entry.getKey(); HashMap<String, Double> measuresFirst = entry.getValue(); for (Map.Entry<String, Double> measure : measuresFirst.entrySet()) { String measureName = measure.getKey(); if (!excludedFromAverage.contains(measureName)) { Double measureValue = measure.getValue() / algorithmTotalRules.get(alg); algorithmMeasures.get(alg).put(measureName, measureValue); }//from w w w .j a v a 2 s .c o m } } }
From source file:com.ibm.storlet.sbus.SBusDatagram.java
private HashMap<String, String> prepareMetadata(HashMap<String, ?> Orig) { HashMap<String, String> Result = new HashMap<String, String>(); String value;//from www . java2 s. c o m for (Entry<String, ?> e : Orig.entrySet()) { if (e.getKey().toString().equals("type")) { value = convertFileTypeToString(e.getValue().toString()); } else { value = e.getValue().toString(); } Result.put(e.getKey().toString(), value); } return Result; }
From source file:org.esigate.DriverFactory.java
/** * Loads all instances according to the properties parameter. * /*from w w w .j av a 2s . c om*/ * @param props * properties to use for configuration */ public static void configure(Properties props) { Properties defaultProperties = new Properties(); HashMap<String, Properties> driversProps = new HashMap<String, Properties>(); for (Enumeration<?> enumeration = props.propertyNames(); enumeration.hasMoreElements();) { String propertyName = (String) enumeration.nextElement(); String value = props.getProperty(propertyName); int idx = propertyName.lastIndexOf('.'); if (idx < 0) { defaultProperties.put(propertyName, value); } else { String prefix = propertyName.substring(0, idx); String name = propertyName.substring(idx + 1); Properties driverProperties = driversProps.get(prefix); if (driverProperties == null) { driverProperties = new Properties(); driversProps.put(prefix, driverProperties); } driverProperties.put(name, value); } } // Merge with default properties Map<String, Driver> newInstances = new HashMap<String, Driver>(); for (Entry<String, Properties> entry : driversProps.entrySet()) { String name = entry.getKey(); Properties properties = new Properties(); properties.putAll(defaultProperties); properties.putAll(entry.getValue()); newInstances.put(name, createDriver(name, properties)); } if (newInstances.get(DEFAULT_INSTANCE_NAME) == null && Parameters.REMOTE_URL_BASE.getValue(defaultProperties) != null) { newInstances.put(DEFAULT_INSTANCE_NAME, createDriver(DEFAULT_INSTANCE_NAME, defaultProperties)); } instances = new IndexedInstances(newInstances); }
From source file:de.uni_potsdam.hpi.bpt.promnicat.importer.bpmai.BpmaiImporter.java
/** * Transform given meta data into an other format * @param properties current meta data//from w w w . j av a 2 s .c om * @return original given meta data, but the value is represented as an array */ private HashMap<String, String[]> parseMetadata(HashMap<String, String> properties) { HashMap<String, String[]> newMap = new HashMap<String, String[]>(); for (Entry<String, String> e : properties.entrySet()) { String[] newValue = { e.getValue() }; newMap.put(e.getKey(), newValue); } return newMap; }
From source file:keel.Algorithms.UnsupervisedLearning.AssociationRules.Visualization.keelassotiationrulesboxplot.ResultsProccessor.java
public void writeToFile(String outName) throws FileNotFoundException, UnsupportedEncodingException, IOException { //calcMeans(); // Create JFreeChart Dataset DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); HashMap<String, ArrayList<Double>> measuresFirst = algorithmMeasures.entrySet().iterator().next() .getValue();//from w w w. j av a 2s.co m for (Map.Entry<String, ArrayList<Double>> measure : measuresFirst.entrySet()) { String measureName = measure.getKey(); //Double measureValue = measure.getValue(); dataset.clear(); for (Map.Entry<String, HashMap<String, ArrayList<Double>>> entry : algorithmMeasures.entrySet()) { String alg = entry.getKey(); ArrayList<Double> measureValues = entry.getValue().get(measureName); // Parse algorithm name to show it correctly String aName = alg.substring(0, alg.length() - 1); int startAlgName = aName.lastIndexOf("/"); aName = aName.substring(startAlgName + 1); dataset.add(measureValues, aName, measureName); } // Tutorial: http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm final CategoryAxis xAxis = new CategoryAxis("Algorithm"); final NumberAxis yAxis = new NumberAxis("Value"); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); // Black and White int numItems = algorithmMeasures.size(); for (int i = 0; i < numItems; i++) { Color color = Color.DARK_GRAY; if (i % 2 == 1) { color = Color.LIGHT_GRAY; } renderer.setSeriesPaint(i, color); renderer.setSeriesOutlinePaint(i, Color.BLACK); } renderer.setMeanVisible(false); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); Font font = new Font("SansSerif", Font.BOLD, 10); //ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jchart = new JFreeChart("Assotiation Rules Measures - BoxPlot", font, plot, true); //StandardChartTheme.createLegacyTheme().apply(jchart); int width = 640 * 2; /* Width of the image */ int height = 480 * 2; /* Height of the image */ // JPEG File chart = new File(outName + "_" + measureName + "_boxplot.jpg"); ChartUtilities.saveChartAsJPEG(chart, jchart, width, height); // SVG SVGGraphics2D g2 = new SVGGraphics2D(width, height); Rectangle r = new Rectangle(0, 0, width, height); jchart.draw(g2, r); File BarChartSVG = new File(outName + "_" + measureName + "_boxplot.svg"); SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement()); } }
From source file:com.intuit.tank.httpclient4.TankHttpClient4.java
/** * Set all the header keys//from w ww. ja v a2 s. c o m * * @param connection */ @SuppressWarnings("rawtypes") private void setHeaders(BaseRequest request, HttpRequestBase method, HashMap<String, String> headerInformation) { try { Set set = headerInformation.entrySet(); Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry mapEntry = (Map.Entry) iter.next(); method.setHeader((String) mapEntry.getKey(), (String) mapEntry.getValue()); } } catch (Exception ex) { LOG.warn(request.getLogUtil().getLogMessage("Unable to set header: " + ex.getMessage(), LogEventType.System)); } }
From source file:cr.ac.siua.tec.utils.impl.ProficiencyPDFGenerator.java
/** * Fills the PDF file (suficiencia.pdf) with the ticket values and returns base64 encoded string. *//* ww w . j av a 2 s . c o m*/ @Override public String generate(HashMap<String, String> formValues) { String originalPdf = PDFGenerator.RESOURCES_PATH + "suficiencia.pdf"; try { PDDocument _pdfDocument = PDDocument.load(originalPdf); PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog(); PDAcroForm acroForm = docCatalog.getAcroForm(); formValues.remove("Queue"); //Iterates through all custom field values. for (Map.Entry<String, String> entry : formValues.entrySet()) { acroForm.getField(entry.getKey()).setValue(entry.getValue()); } return encodePDF(_pdfDocument); } catch (IOException e) { e.printStackTrace(); System.out.println("Excepcin al llenar el PDF."); return null; } }
From source file:eu.domibus.common.dao.ErrorLogDao.java
public List<ErrorLogEntry> findPaged(int from, int max, String column, boolean asc, HashMap<String, Object> filters) { CriteriaBuilder cb = this.em.getCriteriaBuilder(); CriteriaQuery<ErrorLogEntry> cq = cb.createQuery(ErrorLogEntry.class); Root<ErrorLogEntry> ele = cq.from(ErrorLogEntry.class); cq.select(ele);/*from w w w. j a v a 2 s .c o m*/ List<Predicate> predicates = new ArrayList<Predicate>(); for (Map.Entry<String, Object> filter : filters.entrySet()) { if (filter.getValue() != null) { if (filter.getValue() instanceof String) { if (!filter.getValue().toString().isEmpty()) { switch (filter.getKey().toString()) { case "": break; case "timestampFrom": predicates.add(cb.greaterThanOrEqualTo(ele.<Date>get("timestamp"), Timestamp.valueOf(filter.getValue().toString()))); break; case "timestampTo": predicates.add(cb.lessThanOrEqualTo(ele.<Date>get("timestamp"), Timestamp.valueOf(filter.getValue().toString()))); break; case "notifiedFrom": predicates.add(cb.greaterThanOrEqualTo(ele.<Date>get("notified"), Timestamp.valueOf(filter.getValue().toString()))); break; case "notifiedTo": predicates.add(cb.lessThanOrEqualTo(ele.<Date>get("notified"), Timestamp.valueOf(filter.getValue().toString()))); break; default: predicates.add(cb.like(ele.<String>get(filter.getKey()), (String) filter.getValue())); break; } } } else { predicates.add(cb.equal(ele.<String>get(filter.getKey()), filter.getValue())); } } } cq.where(cb.and(predicates.toArray(new Predicate[predicates.size()]))); if (column != null) { if (asc) { cq.orderBy(cb.asc(ele.get(column))); } else { cq.orderBy(cb.desc(ele.get(column))); } } final TypedQuery<ErrorLogEntry> query = this.em.createQuery(cq); query.setFirstResult(from); query.setMaxResults(max); return query.getResultList(); }
From source file:de.hbz.lobid.helper.CompareJsonMaps.java
public boolean writeFileAndTestJson(final JsonNode actual, final JsonNode expected) { // generated data to map final HashMap<String, String> actualMap = new HashMap<>(); extractFlatMapFromJsonNode(actual, actualMap); // expected data to map final HashMap<String, String> expectedMap = new HashMap<>(); extractFlatMapFromJsonNode(expected, expectedMap); CompareJsonMaps.logger.debug("\n##### remove good entries ###"); Iterator<String> it = actualMap.keySet().iterator(); removeContext(it);//from w ww . j a v a 2s . c o m it = expectedMap.keySet().iterator(); removeContext(it); for (final Entry<String, String> e : expectedMap.entrySet()) { CompareJsonMaps.logger.debug("Trying to remove " + e.getKey() + "..."); if (!actualMap.containsKey(e.getKey())) { CompareJsonMaps.logger.warn("At least this element is missing in actual: " + e.getKey()); return false; } if (e.getKey().endsWith("Order]")) { handleOrderedValues(actualMap, e); } else { handleUnorderedValues(actualMap, e); } } if (!actualMap.isEmpty()) { CompareJsonMaps.logger.warn("Fail - no Equality! These keys/values were NOT expected:"); actualMap.forEach((key, val) -> CompareJsonMaps.logger.warn("KEY=" + key + " VALUE=" + val)); } else CompareJsonMaps.logger.info("Succeeded - resources are equal"); return actualMap.size() == 0; }
From source file:gwap.game.quiz.tools.QuizQuestionBean.java
@SuppressWarnings("unchecked") public JSONObject generateJSONObject() { jsonObject = new JSONObject(); jsonObject.put("Title", QuizGermanStemmer.stemText(artResource.getDefaultTitle())); jsonObject.put("Teaser", QuizGermanStemmer.stemText(getTeaser(artResource))); if (artResource.getLocation() != null) { jsonObject.put("Location", QuizGermanStemmer.stemText(artResource.getLocation())); } else {//from ww w . j a v a2s .c o m jsonObject.put("Location", ""); } if (artResource.getDateCreated() != null) { jsonObject.put("Datierung", artResource.getDateCreated()); } else { jsonObject.put("Datierung", ""); } if (artResource.getInstitution() != null) { jsonObject.put("Institution", QuizGermanStemmer.stemText(artResource.getInstitution())); } else { jsonObject.put("Institution", ""); } HashMap<String, Integer> taggings = cleanUpAndGetTaggins(artResource.getTaggings()); jsonObject.put("NumTags", taggings.size()); int ii = 0; for (Entry<String, Integer> s : taggings.entrySet()) { if (s.getValue() > 1) { jsonObject.put("Tag" + ii, QuizGermanStemmer.stemText(s.getKey())); jsonObject.put("TagNum" + ii, s.getValue()); } ii++; } jsonObject.put("A", QuizGermanStemmer.stem(answerA)); jsonObject.put("B", QuizGermanStemmer.stem(answerB)); jsonObject.put("C", QuizGermanStemmer.stem(answerC)); jsonObject.put("D", QuizGermanStemmer.stem(answerD)); jsonObject.put("CorrectAnswer", QuizGermanStemmer.stem(correctAnswer)); if (answerA.getDeath() != null) { jsonObject.put("DA", answerA.getDeath().getYear() + 1900); } else { jsonObject.put("DA", Integer.parseInt(artResource.getDateCreated()) + 30); } if (answerB.getDeath() != null) { jsonObject.put("DB", answerB.getDeath().getYear() + 1900); } else { jsonObject.put("DB", Integer.parseInt(artResource.getDateCreated()) + 30); } if (answerC.getDeath() != null) { jsonObject.put("DC", answerC.getDeath().getYear() + 1900); } else { jsonObject.put("DC", Integer.parseInt(artResource.getDateCreated()) + 30); } if (answerD.getDeath() != null) { jsonObject.put("DD", answerD.getDeath().getYear() + 1900); } else { jsonObject.put("DD", Integer.parseInt(artResource.getDateCreated()) + 30); } jsonObject.put("URL", artResource.getUrl().split("image/")[1]); return this.jsonObject; }