Example usage for java.util TreeMap TreeMap

List of usage examples for java.util TreeMap TreeMap

Introduction

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

Prototype

public TreeMap() 

Source Link

Document

Constructs a new, empty tree map, using the natural ordering of its keys.

Usage

From source file:com.cloudera.sqoop.hbase.ToStringPutTransformer.java

public ToStringPutTransformer() {
    serializedFieldNames = new TreeMap<String, byte[]>();
}

From source file:com.github.fedorchuck.webstore.web.controllers.SystemInfoController.java

@RequestMapping(value = "", method = GET)
public ModelAndView index() {
    ModelAndView model = new ModelAndView("sysinfo");

    final double mb = 1024 * 1024;
    Runtime runtime = Runtime.getRuntime();
    long usedRam = runtime.totalMemory() - runtime.freeMemory();

    Map<String, Double> mem = new TreeMap<>();
    mem.put("Used memory", usedRam / mb);
    mem.put("Total memory", runtime.totalMemory() / mb);
    mem.put("Free memory", runtime.freeMemory() / mb);

    model.getModel().put("mem", mem);

    //model.addObject("userActions", new UserActions());

    return model;
}

From source file:com.ai.smart.bottom.helper.MacUtils.java

public static JSONObject sort(JSONObject json) {
    Set<String> iteratorKeys = json.keySet();
    SortedMap<String, Object> map = new TreeMap<String, Object>();
    for (String str : iteratorKeys) {
        map.put(str, json.get(str));//from ww w. j av a 2s  .co m
    }
    Set<String> mapkeys = map.keySet();
    JSONObject json2 = new JSONObject();
    for (String s : mapkeys) {
        json2.put(s, map.get(s));
    }
    return json2;
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractWorkflowController.java

@RequestMapping(value = "/{workflowParam}", method = RequestMethod.GET)
public String show(@PathVariable String workflowParam, ModelMap map) {
    logger.debug("Getting details for the workflow : " + workflowParam);
    Workflow workflow = workflowService.locate(workflowParam);
    Map<Activity.Bucket, List<WorkflowActivity>> bucketMap = new TreeMap<Activity.Bucket, List<WorkflowActivity>>();
    if (workflow.getWorkflowActivities() != null && workflow.getWorkflowActivities().size() > 0) {
        for (WorkflowActivity activity : workflow.getWorkflowActivities()) {
            if (!activity.isNullified()) {
                if (bucketMap.containsKey(activity.getBucket())) {
                    bucketMap.get(activity.getBucket()).add(activity);
                } else {
                    List<WorkflowActivity> activities = new ArrayList<WorkflowActivity>();
                    activities.add(activity);
                    bucketMap.put(activity.getBucket(), activities);
                }/*from   ww  w  .  j a va2  s.co m*/
            }
        }
    }
    map.put("workflow", workflow);
    map.put("bucketMap", bucketMap);
    logger.debug("Returning details for the workflow : " + workflowParam);
    return "workflow.details.popup";
}

From source file:org.darwinathome.server.controller.ExceptionResolver.java

public ModelAndView resolveException(HttpServletRequest httpServletRequest,
        HttpServletResponse httpServletResponse, Object object, Exception exception) {
    String stackTrace = getStackTrace(exception);
    try {/*w w  w .  j a v  a  2 s  .  c o  m*/
        Map<String, Object> model = new TreeMap<String, Object>();
        model.put("stackTrace", stackTrace);
        emailSender.sendEmail(targetEmailAddress, "noreply@darwinathome.org", "Exception Occurred", model);
    } catch (Exception e) {
        log.warn("Unable to send email to " + targetEmailAddress, e);
    }
    ModelAndView mav = new ModelAndView("exception");
    mav.addObject("exception", exception);
    mav.addObject("stackTrace", stackTrace);
    return mav;
}

From source file:fr.pasteque.client.models.Catalog.java

public Catalog() {
    this.categories = new ArrayList<Category>();
    this.products = new HashMap<Category, List<Product>>();
    this.database = new HashMap<String, Product>();
    this.barcodeDb = new TreeMap<String, Product>();
}

From source file:com.cyclopsgroup.waterview.ui.view.system.status.SetLocale.java

/**
 * Overwrite or implement method execute()
 *
 * @see com.cyclopsgroup.waterview.Module#execute(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.Context)
 *//*  ww  w.  j  a  v  a2  s . co m*/
public void execute(RuntimeData data, Context context) throws Exception {
    Locale[] locales = Locale.getAvailableLocales();
    TreeMap availableLocales = new TreeMap();
    for (int i = 0; i < locales.length; i++) {
        Locale locale = locales[i];
        if (StringUtils.isEmpty(locale.getCountry())) {
            continue;
        }
        String key = locale.getCountry() + '|' + locale.getLanguage();
        availableLocales.put(key, locale);
    }
    context.put("availableLocales", availableLocales.values());
    context.put("currentLocale", data.getSessionContext().get(RuntimeData.LOCALE_NAME));
}

From source file:io.warp10.continuum.DirectoryUtil.java

private static long computeHash(long k0, long k1, long timestamp, List<String> classSelectors,
        List<Map<String, String>> labelsSelectors) {
    ///*from   w  w w .  jav a 2s .  c o m*/
    // Create a ByteArrayOutputStream into which the content will be dumped
    //

    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    // Add timestamp

    try {
        baos.write(Longs.toByteArray(timestamp));

        if (null != classSelectors) {
            for (String classSelector : classSelectors) {
                baos.write(classSelector.getBytes(Charsets.UTF_8));
            }
        }

        if (null != labelsSelectors) {
            for (Map<String, String> map : labelsSelectors) {
                TreeMap<String, String> tm = new TreeMap<String, String>();
                tm.putAll(map);
                for (Entry<String, String> entry : tm.entrySet()) {
                    baos.write(entry.getKey().getBytes(Charsets.UTF_8));
                    baos.write(entry.getValue().getBytes(Charsets.UTF_8));
                }
            }
        }
    } catch (IOException ioe) {
        return 0L;
    }

    // Compute hash

    byte[] data = baos.toByteArray();

    long hash = SipHashInline.hash24(k0, k1, data, 0, data.length);

    return hash;
}

From source file:com.webcohesion.ofx4j.io.nanoxml.TestNanoXMLOFXReader.java

/**
 * tests using sax to parse an OFX doc./*  w  w  w  .j  a  va 2 s .c  om*/
 */
public void testVersion1() throws Exception {
    NanoXMLOFXReader reader = new NanoXMLOFXReader();
    final Map<String, List<String>> headers = new HashMap<String, List<String>>();
    final Stack<Map<String, List<Object>>> aggregateStack = new Stack<Map<String, List<Object>>>();
    TreeMap<String, List<Object>> root = new TreeMap<String, List<Object>>();
    aggregateStack.push(root);

    reader.setContentHandler(getNewDefaultHandler(headers, aggregateStack));
    reader.parse(TestNanoXMLOFXReader.class.getResourceAsStream("example-response.ofx"));
    assertEquals(9, headers.size());
    assertEquals(1, aggregateStack.size());
    assertSame(root, aggregateStack.pop());

    TreeMap<String, List<Object>> OFX = (TreeMap<String, List<Object>>) root.remove("OFX").get(0);
    assertNotNull(OFX);

    TreeMap<String, List<Object>> SIGNONMSGSRSV1 = (TreeMap<String, List<Object>>) OFX.remove("SIGNONMSGSRSV1")
            .get(0);
    assertNotNull(SIGNONMSGSRSV1);
    TreeMap<String, List<Object>> SONRS = (TreeMap<String, List<Object>>) SIGNONMSGSRSV1.remove("SONRS").get(0);
    assertNotNull(SONRS);
    TreeMap<String, List<Object>> STATUS = (TreeMap<String, List<Object>>) SONRS.remove("STATUS").get(0);
    assertNotNull(STATUS);
    assertEquals("0", STATUS.remove("CODE").get(0).toString().trim());
    assertEquals("INFO", STATUS.remove("SEVERITY").get(0).toString().trim());
    assertTrue(STATUS.isEmpty());
    assertEquals("20071015021529.000[-8:PST]", SONRS.remove("DTSERVER").get(0).toString().trim());
    assertEquals("ENG", SONRS.remove("LANGUAGE").get(0).toString().trim());
    assertEquals("19900101000000", SONRS.remove("DTACCTUP").get(0).toString().trim());
    TreeMap<String, List<Object>> FI = (TreeMap<String, List<Object>>) SONRS.remove("FI").get(0);
    assertEquals("Bank&Cd", FI.remove("ORG").get(0).toString().trim());
    assertEquals("01234", FI.remove("FID").get(0).toString().trim());
    assertTrue(FI.isEmpty());
    assertTrue(SONRS.isEmpty());
    assertTrue(SIGNONMSGSRSV1.isEmpty());

    TreeMap<String, List<Object>> BANKMSGSRSV1 = (TreeMap<String, List<Object>>) OFX.remove("BANKMSGSRSV1")
            .get(0);
    TreeMap<String, List<Object>> STMTTRNRS = (TreeMap<String, List<Object>>) BANKMSGSRSV1.remove("STMTTRNRS")
            .get(0);
    assertEquals("23382938", STMTTRNRS.remove("TRNUID").get(0).toString().trim());
    STATUS = (TreeMap<String, List<Object>>) STMTTRNRS.remove("STATUS").get(0);
    assertNotNull(STATUS);
    assertEquals("0", STATUS.remove("CODE").get(0).toString().trim());
    assertEquals("INFO", STATUS.remove("SEVERITY").get(0).toString().trim());
    assertTrue(STATUS.isEmpty());
    TreeMap<String, List<Object>> STMTRS = (TreeMap<String, List<Object>>) STMTTRNRS.remove("STMTRS").get(0);
    assertEquals("USD", STMTRS.remove("CURDEF").get(0).toString().trim());
    TreeMap<String, List<Object>> BANKACCTFROM = (TreeMap<String, List<Object>>) STMTRS.remove("BANKACCTFROM")
            .get(0);
    assertEquals("SAVINGS", BANKACCTFROM.remove("ACCTTYPE").get(0).toString().trim());
    assertEquals("098-121", BANKACCTFROM.remove("ACCTID").get(0).toString().trim());
    assertEquals("987654321", BANKACCTFROM.remove("BANKID").get(0).toString().trim());
    assertTrue(BANKACCTFROM.isEmpty());
    TreeMap<String, List<Object>> BANKTRANLIST = (TreeMap<String, List<Object>>) STMTRS.remove("BANKTRANLIST")
            .get(0);
    assertEquals("20070101", BANKTRANLIST.remove("DTSTART").get(0).toString().trim());
    assertEquals("20071015", BANKTRANLIST.remove("DTEND").get(0).toString().trim());
    TreeMap<String, List<Object>> STMTTRN = (TreeMap<String, List<Object>>) BANKTRANLIST.remove("STMTTRN")
            .get(0);
    assertEquals("CREDIT", STMTTRN.remove("TRNTYPE").get(0).toString().trim());
    assertEquals("20070329", STMTTRN.remove("DTPOSTED").get(0).toString().trim());
    assertEquals("20070329", STMTTRN.remove("DTUSER").get(0).toString().trim());
    assertEquals("150.00", STMTTRN.remove("TRNAMT").get(0).toString().trim());
    assertEquals("980310001", STMTTRN.remove("FITID").get(0).toString().trim());
    assertEquals("TRANSFER", STMTTRN.remove("NAME").get(0).toString().trim());
    assertEquals("Transfer from checking &<> etc.", STMTTRN.remove("MEMO").get(0).toString().trim());
    assertTrue(STMTTRN.isEmpty());
    assertTrue(BANKTRANLIST.isEmpty());
    TreeMap<String, List<Object>> LEDGERBAL = (TreeMap<String, List<Object>>) STMTRS.remove("LEDGERBAL").get(0);
    assertEquals("5250.00", LEDGERBAL.remove("BALAMT").get(0).toString().trim());
    assertEquals("20071015021529.000[-8:PST]", LEDGERBAL.remove("DTASOF").get(0).toString().trim());
    assertTrue(LEDGERBAL.isEmpty());
    TreeMap<String, List<Object>> AVAILBAL = (TreeMap<String, List<Object>>) STMTRS.remove("AVAILBAL").get(0);
    assertEquals("5250.00", AVAILBAL.remove("BALAMT").get(0).toString().trim());
    assertEquals("20071015021529.000[-8:PST]", AVAILBAL.remove("DTASOF").get(0).toString().trim());
    assertTrue(AVAILBAL.isEmpty());
    assertTrue(LEDGERBAL.isEmpty());
    assertTrue(STMTRS.isEmpty());
    assertTrue(STMTTRNRS.isEmpty());
    assertTrue(BANKMSGSRSV1.isEmpty());

    assertTrue(OFX.isEmpty());
    assertTrue(root.isEmpty());
}

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

public SortedMap<String, String> getOrderedParams() {
    SortedMap<String, String> params = new TreeMap<String, String>();
    params.put("PBX_SITE", site);
    params.put("PBX_RANG", rang);
    params.put("PBX_IDENTIFIANT", identifiant);
    params.put("PBX_TOTAL", total);
    params.put("PBX_DEVISE", devise);
    params.put("PBX_CMD", commande);
    params.put("PBX_PORTEUR", clientEmail);
    params.put("PBX_RETOUR", retourVariables);
    params.put("PBX_HASH", hash);
    params.put("PBX_TIME", time);
    params.put("PBX_REPONDRE_A", callbackUrl);
    params.put("PBX_EFFECTUE", forwardEffectueUrl);
    params.put("PBX_REFUSE", forwardRefuseUrl);
    params.put("PBX_ANNULE", forwardAnnuleUrl);

    // params.put("PBX_HMAC", hmac);

    return params;
}