List of usage examples for java.util HashMap get
public V get(Object key)
From source file:net.itransformers.idiscover.discoveryhelpers.xml.SnmpForXslt.java
public static String getName(String ipAddress, String neighbourIPDryRun) throws Exception { HashMap<String, String> deviceNameMap = discoveredIPs.get(ipAddress); if (neighbourIPDryRun.equals("true")) { if (deviceNameMap != null) { return null; } else {//from w w w . ja va2 s . c o m deviceNameMap = new HashMap<String, String>(); discoveredIPs.put(ipAddress, deviceNameMap); return null; } } else { if (deviceNameMap != null) { String deviceName = deviceNameMap.get("snmp"); if ("".equals(deviceName) || deviceName == null) { return null; } else { return deviceName; } } else { return null; } } }
From source file:com.ecyrd.jspwiki.ui.TemplateManager.java
/** * Returns resource requests for a particular type. If there are no resources, * returns an empty array.//www .ja v a 2 s.com * * @param ctx WikiContext * @param type The resource request type * @return a String array for the resource requests */ @SuppressWarnings("unchecked") public static String[] getResourceRequests(WikiContext ctx, String type) { HashMap<String, Vector<String>> hm = (HashMap<String, Vector<String>>) ctx.getVariable(RESOURCE_INCLUDES); if (hm == null) return new String[0]; Vector<String> resources = hm.get(type); if (resources == null) return new String[0]; String[] res = new String[resources.size()]; return resources.toArray(res); }
From source file:com.savor.ads.core.ApiRequestFactory.java
public static HashMap<String, Object> getFormRequestWithoutSign(AppApi.Action action, Object params, Session appSession) throws UnsupportedEncodingException { if (params == null) { return null; }/*from w w w . ja va 2 s . c o m*/ HashMap<String, Object> requestParams; if (params instanceof HashMap) { requestParams = (HashMap<String, Object>) params; } else { return null; } final Iterator<String> keySet = requestParams.keySet().iterator(); // ArrayList<NameValuePair> pm = new ArrayList<>(); JSONObject jsonObject = new JSONObject(); try { while (keySet.hasNext()) { final String key = keySet.next(); // pm.add(new BasicNameValuePair(key, (String) requestParams // .get(key))); jsonObject.put(key, requestParams.get(key)); } } catch (Exception e) { e.printStackTrace(); return null; } return requestParams; // return new UrlEncodedFormEntity(pm, HTTP.UTF_8); }
From source file:com.clustercontrol.repository.util.FacilityTreeCache.java
/** * ?????FacilityInfo??//from w ww. jav a 2 s .c o m * * @param facilityId * @return list */ public static List<FacilityInfo> getParentFacilityInfo(String facilityId) { // ????????????????????????? // (?????????????????????????) HashMap<String, ArrayList<FacilityTreeItem>> facilityTreeItemCache = getFacilityTreeItemCache(); List<FacilityInfo> list = new ArrayList<FacilityInfo>(); List<FacilityTreeItem> treeItems = facilityTreeItemCache.get(facilityId); if (treeItems == null) { return list; } for (FacilityTreeItem treeItem : treeItems) { FacilityTreeItem parentTreeItem = treeItem.getParent(); if (parentTreeItem != null) { list.add(parentTreeItem.getData()); } } return list; }
From source file:com.clustercontrol.repository.util.FacilityTreeCache.java
public static Set<String> getChildFacilityIdSet(String facilityId) { // ????????????????????????? // (?????????????????????????) HashMap<String, ArrayList<FacilityTreeItem>> facilityTreeItemCache = getFacilityTreeItemCache(); HashSet<String> childFacilityIdSet = new HashSet<String>(); List<FacilityTreeItem> treeItems = facilityTreeItemCache.get(facilityId); if (treeItems == null) { return childFacilityIdSet; }/* ww w. j av a 2s. c o m*/ for (FacilityTreeItem treeItem : treeItems) { for (FacilityTreeItem childTreeItem : treeItem.getChildren()) { FacilityInfo childFacilityInfo = childTreeItem.getData(); childFacilityIdSet.add(childFacilityInfo.getFacilityId()); } } return childFacilityIdSet; }
From source file:gov.nih.nci.rembrandt.web.graphing.data.GeneExpressionPlot.java
public static HashMap generateBarChart(String gene, String reporter, HttpSession session, PrintWriter pw, GeneExpressionDataSetType geType) { String log2Filename = null;//from w ww. j a va 2s . c om String rawFilename = null; String medianFilename = null; String bwFilename = ""; String legendHtml = null; HashMap charts = new HashMap(); PlotSize ps = PlotSize.MEDIUM; final String geneName = gene; final String alg = geType.equals(GeneExpressionDataSetType.GeneExpressionDataSet) ? RembrandtConstants.REPORTER_SELECTION_AFFY : RembrandtConstants.REPORTER_SELECTION_UNI; try { InstitutionCriteria institutionCriteria = InsitutionAccessHelper.getInsititutionCriteria(session); final GenePlotDataSet gpds = new GenePlotDataSet(gene, reporter, institutionCriteria, geType, session.getId()); //final GenePlotDataSet gpds = new GenePlotDataSet(gene, institutionCriteria,GeneExpressionDataSetType.GeneExpressionDataSet ); //LOG2 Dataset DefaultStatisticalCategoryDataset dataset = (DefaultStatisticalCategoryDataset) gpds.getLog2Dataset(); //RAW Dataset CategoryDataset meanDataset = (CategoryDataset) gpds.getRawDataset(); //B&W dataset DefaultBoxAndWhiskerCategoryDataset bwdataset = (DefaultBoxAndWhiskerCategoryDataset) gpds .getBwdataset(); //Median dataset CategoryDataset medianDataset = (CategoryDataset) gpds.getMedianDataset(); charts.put("diseaseSampleCountMap", gpds.getDiseaseSampleCountMap()); //IMAGE Size Control if (bwdataset != null && bwdataset.getRowCount() > 5) { ps = PlotSize.LARGE; } else { ps = PlotSize.MEDIUM; } //SMALL/MEDIUM == 650 x 400 //LARGE == 1000 x 400 //put as external Props? int imgW = 650; if (ps == PlotSize.LARGE) { imgW = new BigDecimal(bwdataset.getRowCount()).multiply(new BigDecimal(75)).intValue() > 1000 ? new BigDecimal(bwdataset.getRowCount()).multiply(new BigDecimal(75)).intValue() : 1000; } JFreeChart bwChart = null; //B&W plot CategoryAxis xAxis = new CategoryAxis("Disease Type"); NumberAxis yAxis = new NumberAxis("Log2 Expression Intensity"); yAxis.setAutoRangeIncludesZero(true); BoxAndWhiskerCoinPlotRenderer bwRenderer = null; // BoxAndWhiskerRenderer bwRenderer = new BoxAndWhiskerRenderer(); if (reporter != null) { //single reporter, show the coins bwRenderer = new BoxAndWhiskerCoinPlotRenderer(gpds.getCoinHash()); bwRenderer.setDisplayCoinCloud(true); bwRenderer.setDisplayMean(false); bwRenderer.setDisplayAllOutliers(true); bwRenderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { String tt = ""; NumberFormat formatter = new DecimalFormat(".####"); String key = ""; //String s = formatter.format(-1234.567); // -001235 if (dataset instanceof DefaultBoxAndWhiskerCategoryDataset) { DefaultBoxAndWhiskerCategoryDataset ds = (DefaultBoxAndWhiskerCategoryDataset) dataset; try { String med = formatter.format(ds.getMedianValue(series, item)); tt += "Median: " + med + "<br/>"; tt += "Mean: " + formatter.format(ds.getMeanValue(series, item)) + "<br/>"; tt += "Q1: " + formatter.format(ds.getQ1Value(series, item)) + "<br/>"; tt += "Q3: " + formatter.format(ds.getQ3Value(series, item)) + "<br/>"; tt += "Max: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMaxFaroutOutlier(ds, series, item)) + "<br/>"; tt += "Min: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMinFaroutOutlier(ds, series, item)) + "<br/>"; //tt += "<br/><br/>Please click on the box and whisker to view a plot for this reporter.<br/>"; //tt += "X: " + ds.getValue(series, item).toString()+"<br/>"; //tt += "<br/><a href=\\\'#\\\' id=\\\'"+ds.getRowKeys().get(series)+"\\\' onclick=\\\'alert(this.id);return false;\\\'>"+ds.getRowKeys().get(series)+" plot</a><br/><br/>"; key = ds.getRowKeys().get(series).toString(); } catch (Exception e) { } } return tt; } }); } else { //groups, dont show coins bwRenderer = new BoxAndWhiskerCoinPlotRenderer(); bwRenderer.setDisplayAllOutliers(true); bwRenderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { String tt = ""; NumberFormat formatter = new DecimalFormat(".####"); String key = ""; //String s = formatter.format(-1234.567); // -001235 if (dataset instanceof DefaultBoxAndWhiskerCategoryDataset) { DefaultBoxAndWhiskerCategoryDataset ds = (DefaultBoxAndWhiskerCategoryDataset) dataset; try { String med = formatter.format(ds.getMedianValue(series, item)); tt += "Median: " + med + "<br/>"; tt += "Mean: " + formatter.format(ds.getMeanValue(series, item)) + "<br/>"; tt += "Q1: " + formatter.format(ds.getQ1Value(series, item)) + "<br/>"; tt += "Q3: " + formatter.format(ds.getQ3Value(series, item)) + "<br/>"; tt += "Max: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMaxFaroutOutlier(ds, series, item)) + "<br/>"; tt += "Min: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMinFaroutOutlier(ds, series, item)) + "<br/>"; tt += "<br/><br/>Please click on the box and whisker to view a plot for this reporter.<br/>"; //tt += "X: " + ds.getValue(series, item).toString()+"<br/>"; //tt += "<br/><a href=\\\'#\\\' id=\\\'"+ds.getRowKeys().get(series)+"\\\' onclick=\\\'alert(this.id);return false;\\\'>"+ds.getRowKeys().get(series)+" plot</a><br/><br/>"; key = ds.getRowKeys().get(series).toString(); } catch (Exception e) { } } return "onclick=\"popCoin('" + geneName + "','" + key + "', '" + alg + "');\" | " + tt; } }); } bwRenderer.setFillBox(false); CategoryPlot bwPlot = new CategoryPlot(bwdataset, xAxis, yAxis, bwRenderer); bwChart = new JFreeChart(bwPlot); // JFreeChart bwChart = new JFreeChart( // null /*"Gene Expression Plot (" + gene.toUpperCase() + ")"*/, // new Font("SansSerif", Font.BOLD, 14), // bwPlot, // true // ); bwChart.setBackgroundPaint(java.awt.Color.white); //bwChart.getTitle().setHorizontalAlignment(TextTitle.DEFAULT_HORIZONTAL_ALIGNMENT.LEFT); bwChart.removeLegend(); //END BW plot // create the chart...for LOG2 dataset JFreeChart log2Chart = ChartFactory.createBarChart( null /*"Gene Expression Plot (" + gene.toUpperCase() + ")"*/, // chart // title "Groups", // domain axis label "Log2 Expression Intensity", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); //create the chart .... for RAW dataset JFreeChart meanChart = ChartFactory.createBarChart( null /*"Gene Expression Plot (" + gene.toUpperCase() + ")"*/, // chart // title "Groups", // domain axis label "Mean Expression Intensity", // range axis label meanDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // create the chart .... for Median dataset JFreeChart medianChart = ChartFactory.createBarChart( null /*"Gene Expression Plot (" + gene.toUpperCase() + ")"*/, // chart // title "Groups", // domain axis label "Median Expression Intensity", // range axis label medianDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); log2Chart.setBackgroundPaint(java.awt.Color.white); // lets start some customization to retro fit w/jcharts lookand feel CategoryPlot log2Plot = log2Chart.getCategoryPlot(); CategoryAxis log2Axis = log2Plot.getDomainAxis(); log2Axis.setLowerMargin(0.02); // two percent log2Axis.setCategoryMargin(0.20); // 20 percent log2Axis.setUpperMargin(0.02); // two percent // same for our fake chart - just to get the tooltips meanChart.setBackgroundPaint(java.awt.Color.white); CategoryPlot meanPlot = meanChart.getCategoryPlot(); CategoryAxis meanAxis = meanPlot.getDomainAxis(); meanAxis.setLowerMargin(0.02); // two percent meanAxis.setCategoryMargin(0.20); // 20 percent meanAxis.setUpperMargin(0.02); // two percent // median plot medianChart.setBackgroundPaint(java.awt.Color.white); CategoryPlot medianPlot = medianChart.getCategoryPlot(); CategoryAxis medianAxis = medianPlot.getDomainAxis(); medianAxis.setLowerMargin(0.02); // two percent medianAxis.setCategoryMargin(0.20); // 20 percent medianAxis.setUpperMargin(0.02); // two percent // customise the renderer... StatisticalBarRenderer log2Renderer = new StatisticalBarRenderer(); // BarRenderer renderer = (BarRenderer) plot.getRenderer(); log2Renderer.setItemMargin(0.01); // one percent log2Renderer.setDrawBarOutline(true); log2Renderer.setOutlinePaint(Color.BLACK); log2Renderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { HashMap pv = gpds.getPValuesHashMap(); HashMap std_d = gpds.getStdDevMap(); String currentPV = (String) pv .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); String stdDev = (String) std_d .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : " + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>" + RembrandtConstants.PVALUE + " : " + currentPV + "<br/>Std. Dev.: " + stdDev + "<br/>"; } }); log2Plot.setRenderer(log2Renderer); // customize the renderer BarRenderer meanRenderer = (BarRenderer) meanPlot.getRenderer(); meanRenderer.setItemMargin(0.01); // one percent meanRenderer.setDrawBarOutline(true); meanRenderer.setOutlinePaint(Color.BLACK); meanRenderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { HashMap pv = gpds.getPValuesHashMap(); HashMap std_d = gpds.getStdDevMap(); String currentPV = (String) pv .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); String stdDev = (String) std_d .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : " + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>" + RembrandtConstants.PVALUE + ": " + currentPV + "<br/>"; //"<br/>Std. Dev.: " + stdDev + "<br/>"; } }); meanPlot.setRenderer(meanRenderer); // customize the renderer BarRenderer medianRenderer = (BarRenderer) medianPlot.getRenderer(); medianRenderer.setItemMargin(0.01); // one percent medianRenderer.setDrawBarOutline(true); medianRenderer.setOutlinePaint(Color.BLACK); medianRenderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { HashMap pv = gpds.getPValuesHashMap(); HashMap std_d = gpds.getStdDevMap(); String currentPV = (String) pv .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); String stdDev = (String) std_d .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : " + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>" + RembrandtConstants.PVALUE + ": " + currentPV + "<br/>"; //"<br/>Std. Dev.: " + stdDev + "<br/>"; } }); // LegendTitle lg = chart.getLegend(); medianPlot.setRenderer(medianRenderer); // lets generate a custom legend - assumes theres only one source? LegendItemCollection lic = log2Chart.getLegend().getSources()[0].getLegendItems(); legendHtml = LegendCreator.buildLegend(lic, "Probesets"); log2Chart.removeLegend(); meanChart.removeLegend(); medianChart.removeLegend(); //bwChart.removeLegend(); // <-- do this above // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); // BW if (bwChart != null) { int bwwidth = new BigDecimal(1.5).multiply(new BigDecimal(imgW)).intValue(); bwFilename = ServletUtilities.saveChartAsPNG(bwChart, bwwidth, 400, info, session); CustomOverlibToolTipTagFragmentGenerator ttip = new CustomOverlibToolTipTagFragmentGenerator(); String toolTip = " href='javascript:void(0);' alt='GeneChart JFreechart Plot' "; ttip.setExtra(toolTip); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, bwFilename, info, ttip, new StandardURLTagFragmentGenerator()); info.clear(); // lose the first one info = new ChartRenderingInfo(new StandardEntityCollection()); } //END BW log2Filename = ServletUtilities.saveChartAsPNG(log2Chart, imgW, 400, info, session); CustomOverlibToolTipTagFragmentGenerator ttip = new CustomOverlibToolTipTagFragmentGenerator(); String toolTip = " alt='GeneChart JFreechart Plot' "; ttip.setExtra(toolTip); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, log2Filename, info, ttip, new StandardURLTagFragmentGenerator()); // clear the first one and overwrite info with our second one - no // error bars info.clear(); // lose the first one info = new ChartRenderingInfo(new StandardEntityCollection()); rawFilename = ServletUtilities.saveChartAsPNG(meanChart, imgW, 400, info, session); // Write the image map to the PrintWriter // can use a different writeImageMap to pass tooltip and URL custom ttip = new CustomOverlibToolTipTagFragmentGenerator(); toolTip = " alt='GeneChart JFreechart Plot' "; ttip.setExtra(toolTip); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, rawFilename, info, ttip, new StandardURLTagFragmentGenerator()); info.clear(); // lose the first one info = new ChartRenderingInfo(new StandardEntityCollection()); medianFilename = ServletUtilities.saveChartAsPNG(medianChart, imgW, 400, info, session); // Write the image map to the PrintWriter // can use a different writeImageMap to pass tooltip and URL custom ttip = new CustomOverlibToolTipTagFragmentGenerator(); toolTip = " alt='GeneChart JFreechart Plot' "; ttip.setExtra(toolTip); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, medianFilename, info, ttip, new StandardURLTagFragmentGenerator()); // ChartUtilities.writeImageMap(pw, filename, info, true); pw.flush(); } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); log2Filename = "public_error_500x300.png"; } // return filename; charts.put("errorBars", log2Filename); charts.put("noErrorBars", rawFilename); charts.put("medianBars", medianFilename); charts.put("bwFilename", bwFilename); charts.put("legend", legendHtml); charts.put("size", ps.toString()); return charts; }
From source file:com.actelion.research.orbit.imageAnalysis.utils.ImageUtils.java
/** * Rescales using plate intensities and converts to 8bit. Works for gray- and rgb color images. * * @param bi16/*from www .j a v a 2 s . com*/ * @return */ public static BufferedImage convertTo8bit(int rdfId, BufferedImage bi16, PlateScalingMin plateScalingMin, PlateScalingMax plateScalingMax) throws Exception { RawDataFile rdf = DALConfig.getImageProvider().LoadRawDataFile(rdfId); /* if (plateScalingMin==defaultPlateScalingMin && plateScalingMax==defaultPlateScalingMax) { // /orbitvol1/2014-11/4309324.1002.jpg String url = RawUtils.STR_SERVER+"/rawFile?rawFile="+rdf.getDataPath()+"/"+rdfId+"."+RawUtils.LEVEL_8BITPREVIEW+".jpg"; System.out.println("url: " + url); return ImageIO.read(new URL(url)); } */ RawData rd = DALConfig.getImageProvider().LoadRawData(rdf.getRawDataId()); List<RawMeta> rmList = DALConfig.getImageProvider().LoadRawMetasByRawDataFile(rdfId); List<RawMeta> rmDataList = DALConfig.getImageProvider().LoadRawMetasByRawData(rd.getRawDataId()); rmList.addAll(rmDataList); HashMap<String, RawMeta> rmHash = RawUtilsCommon.getHashFromMetaList(rmList); if (!rmHash.containsKey(RawUtilsCommon.STR_META_CHANNEL)) throw new Exception("Error: Meta data 'Channel' not available for RawDataFile " + rdfId); //int channel = Integer.parseInt(rmHash.get(RawUtils.STR_META_CHANNEL).getValue()) - 1; int channel = Integer.parseInt(rmHash.get(RawUtilsCommon.STR_META_CHANNEL).getValue()); String metaKey = "Percentiles_wvlength_" + channel + "_channel_0"; if (!rmHash.containsKey(metaKey)) throw new Exception("Error: Meta data '" + metaKey + "' not available for RawDataFile " + rdfId); String val = rmHash.get(metaKey).getValue(); int[] minmax = parseMinMax(val, plateScalingMin, plateScalingMax); BufferedImage bi = null; if (bi16.getSampleModel().getNumBands() == 1) { bi16 = ImageUtils.scaleIntensities(bi16, new int[] { minmax[0] }, new int[] { minmax[1] }); bi = new BufferedImage(bi16.getWidth(), bi16.getHeight(), BufferedImage.TYPE_BYTE_GRAY); } else { throw new IllegalArgumentException("Only images with 1 band (gray-color) supported. This image has " + bi16.getSampleModel().getNumBands() + " bands."); } Graphics2D g2d = bi.createGraphics(); g2d.drawImage(bi16, 0, 0, null); g2d.dispose(); return bi; }
From source file:free.yhc.netmbuddy.utils.Utils.java
public static Object[] getSortedKeyOfTimeMap(HashMap<? extends Object, Long> timeMap) { TimeElem[] te = new TimeElem[timeMap.size()]; Object[] vs = timeMap.keySet().toArray(new Object[0]); for (int i = 0; i < vs.length; i++) te[i] = new TimeElem(vs[i], timeMap.get(vs[i])); Arrays.sort(te, sTimeElemComparator); Object[] sorted = new Object[vs.length]; for (int i = 0; i < sorted.length; i++) sorted[i] = te[i].v;/* w w w. j a va 2 s. c o m*/ return sorted; }
From source file:com.linkedin.pinot.util.TestUtils.java
public static void assertJSONArrayApproximation(JSONArray jsonArrayEstimate, JSONArray jsonArrayActual, double precision) { LOGGER.info("====== assertJSONArrayApproximation ======"); try {//from w ww . ja v a 2 s .c o m HashMap<String, Double> mapEstimate = genMapFromJSONArray(jsonArrayEstimate); HashMap<String, Double> mapActual = genMapFromJSONArray(jsonArrayActual); // estimation should not affect number of groups formed Assert.assertEquals(mapEstimate.keySet().size(), mapActual.keySet().size()); LOGGER.info("estimate: " + mapEstimate.keySet()); LOGGER.info("actual: " + mapActual.keySet()); int cnt = 0; for (String key : mapEstimate.keySet()) { // Not strictly enforced, since in quantile, top 100 groups from accurate maybe not be top 100 from estimate // Assert.assertEquals(mapActual.keySet().contains(key), true); if (mapActual.keySet().contains(key)) { assertApproximation(mapEstimate.get(key), mapActual.get(key), precision); cnt += 1; } } LOGGER.info("group overlap rate: " + (cnt + 0.0) / mapEstimate.keySet().size()); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.cburch.logisim.util.LocaleManager.java
private static String replaceAccents(String src, HashMap<Character, String> repl) { // find first non-standard character - so we can avoid the // replacement process if possible int i = 0;/* w w w. j a v a 2 s. co m*/ int n = src.length(); for (; i < n; i++) { char ci = src.charAt(i); if (ci < 32 || ci >= 127) break; } if (i == n) return src; // ok, we'll have to consider replacing accents char[] cs = src.toCharArray(); StringBuilder ret = new StringBuilder(src.substring(0, i)); for (int j = i; j < cs.length; j++) { char cj = cs[j]; if (cj < 32 || cj >= 127) { String out = repl.get(Character.valueOf(cj)); if (out != null) { ret.append(out); } else { ret.append(cj); } } else { ret.append(cj); } } return ret.toString(); }