Example usage for java.util SortedMap get

List of usage examples for java.util SortedMap get

Introduction

In this page you can find the example usage for java.util SortedMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:com.aurel.track.report.dashboard.AverageTimeToCloseItem.java

/**
 * Add the time series to the timeSeriesCollection
 * SortedMap at first and second level (year and period)
 * (Sorted because the accumulated should be calculated in the right order)
 * @param timeSeriesCollection/*from w  w w .jav a2 s  .c  o m*/
 * @param yearToPeriodToOpenedWorkItemCountMap
 * @param selectedTimeInterval
*/
public static SortedMap<Date, Object> transformPeriodsToDates(
        SortedMap/*<Integer, SortedMap<Integer, Object>>*/ yearToPeriodToValuesMap, int selectedTimeInterval) {
    SortedMap<Date, Object> dateToValue = new TreeMap<Date, Object>();
    for (Iterator iterator = yearToPeriodToValuesMap.keySet().iterator(); iterator.hasNext();) {
        Integer year = (Integer) iterator.next();
        SortedMap<Integer, Object> intervalToStatusChangeBeans = (SortedMap<Integer, Object>) yearToPeriodToValuesMap
                .get(year);
        Iterator<Integer> periodIterator = intervalToStatusChangeBeans.keySet().iterator();
        while (periodIterator.hasNext()) {
            Integer period = periodIterator.next();
            Object periodValue = intervalToStatusChangeBeans.get(period);
            if (periodValue != null) {
                dateToValue.put(createDate(period.intValue(), year.intValue(), selectedTimeInterval),
                        periodValue);
            }
        }
    }
    return dateToValue;
}

From source file:org.esupportail.papercut.domain.PayBoxForm.java

public String getParamsAsString() {
    String paramsAsString = "";
    SortedMap<String, String> params = getOrderedParams();
    for (String key : params.keySet()) {
        paramsAsString = paramsAsString + key + "=" + params.get(key) + "&";
    }/*from  w w  w.ja va 2s  . c om*/
    paramsAsString = paramsAsString.subSequence(0, paramsAsString.length() - 1).toString();
    try {
        // paramsAsString = URLEncoder.encode(paramsAsString, "utf8");
        System.out.println(paramsAsString);
        return paramsAsString;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.motrice.jmx.BasicAppManagement.java

/**
 * Get the names and log levels of all loggers.
 *///from   w  w  w.j a v a2 s .  co m
@ManagedAttribute(description = "Application loggers and log levels", currencyTimeLimit = 10)
public List<String> getLoggers() {
    List<String> nameList = new ArrayList<String>();
    SortedMap<String, Logger> map = doGetLoggers();
    for (String key : map.keySet()) {
        Logger log = map.get(key);
        if (log != null && log.getLevel() != null) {
            nameList.add(key + " = " + log.getLevel());
        }
    }

    return nameList;
}

From source file:com.sun.faces.generate.RenderKitSpecificationGenerator.java

public static void generateRenderKitSummary() throws Exception {
    StringBuffer sb = null;/*from ww w . j a  v a  2  s .  c  o  m*/

    // generate the renderkit-summary.html
    sb = new StringBuffer(2048);
    appendResourceToStringBuffer("com/sun/faces/generate/facesdoc/renderkit-summary.top", sb);
    sb.append("<H2>" + renderKitId + " RenderKit</H2>\n");
    sb.append("<BR>\n\n");

    RenderKitBean renderKit = null;
    if (null == (renderKit = fcb.getRenderKit(renderKitId))) {
        RenderKitBean[] kits = null;
        if (null == (kits = fcb.getRenderKits())) {
            throw new IllegalStateException("no RenderKits");
        }
        if (null == (renderKit = kits[0])) {
            throw new IllegalStateException("no RenderKits");
        }
    }

    DescriptionBean descBean = renderKit.getDescription("");
    String description = (null == descBean) ? "" : descBean.getDescription();
    sb.append("<P>" + description + "</P>\n");
    sb.append("<P />");
    sb.append("<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">");
    sb.append("<TR BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">\n");
    sb.append("<TD COLSPAN=\"3\"><FONT SIZE=\"+2\">\n");
    sb.append("<B>Renderer Summary</B></FONT></TD>\n");
    sb.append("\n");
    sb.append("<TR>\n");
    sb.append("<TH>component-family</TH>\n");
    sb.append("<TH>renderer-type</TH>\n");
    sb.append("<TH>description</TH>\n");
    sb.append("</TR>\n");

    SortedMap renderersByComponentFamily = getComponentFamilyRendererMap(renderKitId);
    Iterator rendererIter = null, keyIter = renderersByComponentFamily.keySet().iterator();
    String curType = null, curFamily = null;
    List renderers = null;
    RendererBean renderer = null;

    while (keyIter.hasNext()) {
        curFamily = (String) keyIter.next();
        renderers = (List) renderersByComponentFamily.get(curFamily);
        rendererIter = renderers.iterator();
        sb.append("  <TR>\n");
        sb.append("    <TD rowspan=\"" + renderers.size() + "\">" + curFamily + "</TD>\n");
        while (rendererIter.hasNext()) {
            renderer = (RendererBean) rendererIter.next();
            curType = renderer.getRendererType();
            sb.append("    <TD><A HREF=\"" + curFamily + curType + ".html\" TARGET=\"rendererFrame\">" + curType
                    + "</A></TD>\n");
            descBean = renderer.getDescription("");
            description = (null == descBean) ? "" : descBean.getDescription();
            sb.append("    <TD>" + getFirstSentance(description) + "</TD>");
            if (rendererIter.hasNext()) {
                sb.append("  </TR>\n");
                sb.append("  <TR>\n");
            }
        }
        sb.append("  </TR>\n");
    }

    sb.append("</TABLE>\n\n");

    appendResourceToStringBuffer("com/sun/faces/generate/facesdoc/renderkit-summary.bottom", sb);
    writeStringToFile(sb.toString(), new File(renderKitDirectory, "renderkit-summary.html"));
}

From source file:com.bdaum.juploadr.uploadapi.smugrest.upload.SmugmugUpload.java

@Override
public boolean execute() throws ProtocolException, CommunicationException {
    HttpClient client = HttpClientFactory.getHttpClient(session.getAccount());
    this.monitor.uploadStarted(new UploadEvent(image, 0, true, false));
    SortedMap<String, String> params = getParams();
    String name = params.get(X_SMUG_FILE_NAME);
    PutMethod put = new PutMethod(URL + name);
    for (Map.Entry<String, String> entry : params.entrySet())
        put.addRequestHeader(entry.getKey(), entry.getValue());
    File file = new File(image.getImagePath());
    Asset asset = image.getAsset();//from   w  w  w . j  a v a 2 s  .  c o m
    FileRequestEntity entity = new FileRequestEntity(file, asset.getMimeType());
    put.setRequestEntity(entity);
    try {
        int status = client.executeMethod(put);
        if (status == HttpStatus.SC_OK) {
            // deal with the response
            try {
                String response = put.getResponseBodyAsString();
                put.releaseConnection();
                boolean success = parseResponse(response);
                if (success) {
                    image.setState(UploadImage.STATE_UPLOADED);
                    ImageUploadResponse resp = new ImageUploadResponse(handler.getPhotoID(), handler.getKey(),
                            handler.getUrl());
                    this.monitor.uploadFinished(new UploadCompleteEvent(resp, image));
                } else {
                    throw new UploadFailedException(Messages.getString("juploadr.ui.error.status")); //$NON-NLS-1$
                }

            } catch (IOException e) {
                // TODO: Is it safe to assume the upload failed here?
                this.fail(Messages.getString("juploadr.ui.error.response.unreadable") //$NON-NLS-1$
                        + e.getMessage(), e);
            }
        } else {
            this.fail(Messages.getString("juploadr.ui.error.bad.http.response", status), null); //$NON-NLS-1$
        }
    } catch (ConnectException ce) {
        this.fail(Messages.getString("juploadr.ui.error.unable.to.connect"), ce); //$NON-NLS-1$
    } catch (NoRouteToHostException route) {
        this.fail(Messages.getString("juploadr.ui.error.no.internet"), route); //$NON-NLS-1$
    } catch (UnknownHostException uhe) {
        this.fail(Messages.getString("juploadr.ui.error.unknown.host"), uhe); //$NON-NLS-1$

    } catch (HttpException e) {
        this.fail(Messages.getString("juploadr.ui.error.http.exception") + e, e); //$NON-NLS-1$
    } catch (IOException e) {
        this.fail(Messages.getString("juploadr.ui.error.simple.ioexception") + e.getMessage() + "" //$NON-NLS-1$ //$NON-NLS-2$
                + e, e);
    }
    return true;
}

From source file:com.sun.faces.generate.RenderKitSpecificationGenerator.java

public static void generateAllRenderersFrame() throws Exception {
    StringBuffer sb = null;/*from w  ww  .  j a va  2 s.  co  m*/

    // generate the allrenderers-frame.html
    sb = new StringBuffer(2048);
    appendResourceToStringBuffer("com/sun/faces/generate/facesdoc/allrenderers-frame.top", sb);
    sb.append("<FONT size=\"+1\" CLASS=\"FrameHeadingFont\">\n");
    sb.append("<B>" + renderKitId + " RenderKit</B></FONT>\n");
    sb.append("<BR>\n\n");
    sb.append("<DL CLASS=\"FrameItemFont\">\n\n");

    SortedMap renderersByComponentFamily = getComponentFamilyRendererMap(renderKitId);
    Iterator rendererIter = null, keyIter = renderersByComponentFamily.keySet().iterator();
    String curType = null, curFamily = null;
    List renderers = null;
    RendererBean renderer = null;

    while (keyIter.hasNext()) {
        curFamily = (String) keyIter.next();
        sb.append("  <DT>" + curFamily + "</DT>\n");
        renderers = (List) renderersByComponentFamily.get(curFamily);
        rendererIter = renderers.iterator();
        while (rendererIter.hasNext()) {
            renderer = (RendererBean) rendererIter.next();
            curType = renderer.getRendererType();
            sb.append("  <DD><A HREF=\"" + renderKitId + "/" + curFamily + curType
                    + ".html\" TARGET=\"rendererFrame\">" + curType + "</A><DD>\n");
        }
    }

    sb.append("</dl>\n");

    appendResourceToStringBuffer("com/sun/faces/generate/facesdoc/allrenderers-frame.bottom", sb);
    writeStringToFile(sb.toString(), new File(directory, "allrenderers-frame.html"));
}

From source file:com.github.lukaszbudnik.dqueue.QueueClientPerformanceTest.java

@After
public void after() throws Exception {
    session.execute("drop keyspace " + cassandraKeyspace);

    SortedMap<String, Timer> timers = metricRegistry.getTimers();

    timers.keySet().stream().forEach(k -> {
        Timer t = timers.get(k);
        System.out.println(k);//ww  w  .  ja va 2s  .  c  o  m
        System.out.println("\ttimes called ==> " + t.getCount());
        System.out.println("\tmedian ==> " + t.getSnapshot().getMedian() / 1000 / 1000);
        System.out.println("\t75th percentile ==> " + t.getSnapshot().get75thPercentile() / 1000 / 1000);
        System.out.println("\t99th percentile ==> " + t.getSnapshot().get99thPercentile() / 1000 / 1000);
    });

    queueClient.close();
}

From source file:org.tsm.concharto.service.IntegrationTestTagAggregateService.java

@Test
public void tagIndex() throws ParseException {
    createEvents(10, TAG_A, "2001");
    createEvents(10, TAG_A, "1920-2000");
    createEvents(2, TAG_A, "900 AD");
    createEvents(2, TAG_A, "20000 BC");
    createEvents(5, TAG_B, "2001");
    createEvents(5, TAG_B, "901");
    createEvents(5, TAG_C, "1999");
    createEvents(5, TAG_D, "1920 - 2001");

    tagAggregateService.refresh();//from   www  .  j  av a 2  s . c  o m
    SortedMap<TimeRange, List<TagCloudEntry>> tagIndex = tagAggregateService
            .getTagIndex(CatalogUtil.CATALOG_WWW);

    assertEquals(2, tagIndex.get(TimeRangeFormat.parse(lastDecade)).size());
    assertEquals(3, tagIndex.get(TimeRangeFormat.parse("1900 - 2000")).size());
    assertEquals(1, tagIndex.get(TimeRangeFormat.parse("800 - 900")).size());
    assertEquals(1, tagIndex.get(TimeRangeFormat.parse("1000000 BC - 1 AD")).size());
}

From source file:org.tsm.concharto.service.IntegrationTestTagAggregateService.java

@Test
public void multipleCatalogs() throws ParseException {
    //create 2 tags for two catalogs, one overlap
    createEvents(10, TAG_A, "2001", CATALOG_BOATING);
    createEvents(5, TAG_B, "2001", CATALOG_BOATING);
    createEvents(5, TAG_C, "2001", CATALOG_BOATING);
    createEvents(10, TAG_A, "2001", CatalogUtil.CATALOG_WWW);
    createEvents(10, TAG_D, "2001", CatalogUtil.CATALOG_WWW);

    tagAggregateService.refresh();//  w  ww.  j  a  v  a 2s .  co m

    //verify getRecent
    List<TagCloudEntry> tagCloud = tagAggregateService.getRecent(CatalogUtil.CATALOG_WWW);
    assertEquals(2, tagCloud.size());
    tagCloud = tagAggregateService.getRecent(CatalogUtil.CATALOG_WWW);
    assertEquals(2, tagCloud.size());

    //verify getTagIndex
    SortedMap<TimeRange, List<TagCloudEntry>> tagIndex = tagAggregateService
            .getTagIndex(CatalogUtil.CATALOG_WWW);
    assertEquals(2, tagIndex.get(TimeRangeFormat.parse(lastDecade)).size());
    tagIndex = tagAggregateService.getTagIndex(CATALOG_BOATING);
    assertEquals(3, tagIndex.get(TimeRangeFormat.parse(lastDecade)).size());

}

From source file:com.aqnote.app.wifianalyzer.vendor.model.VendorServiceTest.java

@Test
public void testFindAll() throws Exception {
    // setup//from w  ww . ja va 2  s .c  om
    List<VendorData> vendorDatas = withVendorDatas();
    when(database.findAll()).thenReturn(vendorDatas);
    // execute
    SortedMap<String, List<String>> actual = fixture.findAll();
    // validate
    verify(database).findAll();

    assertEquals(3, actual.size());
    assertEquals(1, actual.get(VendorNameUtils.cleanVendorName(vendorDatas.get(0).getName())).size());
    assertEquals(3, actual.get(VendorNameUtils.cleanVendorName(vendorDatas.get(1).getName())).size());
    assertEquals(1, actual.get(VendorNameUtils.cleanVendorName(vendorDatas.get(4).getName())).size());

    List<String> macs = actual.get(VendorNameUtils.cleanVendorName(vendorDatas.get(1).getName()));
    assertEquals(vendorDatas.get(3).getMac(), macs.get(0));
    assertEquals(vendorDatas.get(1).getMac(), macs.get(1));
    assertEquals(vendorDatas.get(2).getMac(), macs.get(2));
}