Example usage for java.util HashMap HashMap

List of usage examples for java.util HashMap HashMap

Introduction

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

Prototype

public HashMap() 

Source Link

Document

Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).

Usage

From source file:com.apress.prospringintegration.jdbc.JdbcOutbound.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("/spring/jdbc/jdbc-outbound-context.xml");

    MessageChannel input = context.getBean("input", MessageChannel.class);

    Map<String, Object> rowMessage = new HashMap<String, Object>();

    rowMessage.put("id", 3);
    rowMessage.put("firstname", "Mr");
    rowMessage.put("lastname", "Bill");
    rowMessage.put("status", 0);

    Message<Map<String, Object>> message = MessageBuilder.withPayload(rowMessage).build();
    input.send(message);//from  ww  w .  jav a2s. c o  m

}

From source file:JMeterProcessing.JMeterPropertiesGenerator.java

public static void main(String[] args) throws IOException, JSONException {
    Map<String, Long> idValuesMap = new HashMap<String, Long>();

    processTestrayCaseResult(idValuesMap);
    processTestrayRun(idValuesMap);/*from w ww .  ja va 2 s  .c  o m*/
    processTestrayBuild(idValuesMap);
    processTestrayBuildType(idValuesMap);
    processTestrayTask(idValuesMap);

    generatePropertiesFile(idValuesMap);
}

From source file:com.cjwagner.InfoSecPriv.ExtensionServer.java

public static void main(String[] args) {
    initializeLogStore();/*from  w ww  .  jav  a 2s. co  m*/

    get("/data", (request, response) -> {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.MINUTE, -5);
        Date tMinusDelta = cal.getTime();

        Map<String, LoggerMessage> filtered = new HashMap<String, LoggerMessage>();
        for (Map.Entry<String, LoggerMessage> entry : logStore.entrySet()) {
            String ip = entry.getKey();
            LoggerMessage logmess = entry.getValue();
            LoggerMessage logmessFiltered = new LoggerMessage();
            logmessFiltered.setFirstLogTime(logmess.getFirstLogTime());
            List<LogData> filteredData = new ArrayList<LogData>();
            logmessFiltered.setLogs(filteredData);
            for (LogData data : logmess.getLogs()) {
                if (data.getDate().after(tMinusDelta)) {
                    filteredData.add(data);
                }
            }

            filtered.put(ip, logmessFiltered);
        }

        ObjectMapper objMapper = new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);
        String jsonResponse = objMapper.writeValueAsString(filtered);
        System.out.println("Responded to query for recent data from IP: " + request.ip());
        return jsonResponse;
    });

    post("/LicenseRegistry", (request, response) -> {
        if (storeSize >= MAXSTORESIZE) {
            response.status(507);//insufficient storage
            return "Server storage full!";
        }

        String ip = request.ip().replace(':', '_');
        String json = request.body();

        try {
            LoggerMessage logMess = LoggerMessage.fromJSON(json);
            logMess.setFirstLogTime(new Date());
            LoggerMessage rec = logStore.get(ip);
            if (rec == null) {
                logStore.put(ip, logMess);
                rec = logMess;
            } else {
                rec.getLogs().addAll(logMess.getLogs());
            }
            updateLogFile(ip, rec);
            storeSize += logMess.getLogs().size();
            response.status(200);

            System.out.println("Recieved log data from IP: " + ip);
            return "LicenseKey:<c706cfe7-b748-4d75-98b5-c6b32ab789cb>";
        } catch (JsonParseException jpe) {
            response.status(HTTP_BAD_REQUEST);
            System.out.println("Failed to parse log data from IP: " + ip);
            return jpe.getMessage();
        }
    });
}

From source file:com.ibm.watson.developer_cloud.alchemy_data_news.v1.GetNewsDocumentExample.java

public static void main(String[] args) {
    AlchemyDataNews service = new AlchemyDataNews();
    service.setApiKey("<api_key>");

    Map<String, Object> params = new HashMap<String, Object>();

    String[] fields = new String[] { "enriched.url.title", "enriched.url.url", "enriched.url.author",
            "enriched.url.publicationDate", "enriched.url.enrichedTitle.entities",
            "enriched.url.enrichedTitle.docSentiment" };
    params.put(AlchemyDataNews.RETURN, StringUtils.join(fields, ","));
    params.put(AlchemyDataNews.START, "1440720000");
    params.put(AlchemyDataNews.END, "1441407600");
    params.put(AlchemyDataNews.COUNT, 7);

    //Query on adjacent nested fields: 
    params.put("q.enriched.url.enrichedTitle.entities.entity", "|text=IBM,type=company|");
    params.put("q.enriched.url.enrichedTitle.docSentiment.type", "positive");
    params.put("q.enriched.url.enrichedTitle.taxonomy.taxonomy_.label", "technology and computing");

    DocumentsResult result = service.getNewsDocuments(params).execute();

    System.out.println(result);/*from w  w  w  . j  ava  2s.com*/
}

From source file:cooccurrence.emf.java

public static void main(String args[]) {
    String path = "";
    String writePath = "";
    BufferedReader br = null;/*www.  j ava 2s .  com*/
    ArrayList<String> files = new ArrayList<>();
    listFilesForFolder(new File(path), files);
    for (String filePath : files) {
        System.out.println(filePath);
        String fileName = new File(filePath).getName();

        //data structure to store the PPMI matrix in the file
        HashMap<String, HashMap<String, Double>> cooccur = new HashMap<>();
        readFileContents(filePath, cooccur); //reading the file and storing the content in the hashmap
        //Because Matrices are identified by row and col id, the following 
        //lists maps id to corresponding string. Note that matrix is symmetric. 
        ArrayList<String> rowStrings = new ArrayList<>(cooccur.keySet());
        ArrayList<String> colStrings = new ArrayList<>(cooccur.keySet());

        //creating matrix with given dimensions and initializing it to 0
        RealMatrix matrixR = MatrixUtils.createRealMatrix(rowStrings.size(), colStrings.size());
        //populating the matrices based on the co-occur hashmap
        populateMatrixR(matrixR, cooccur, rowStrings, colStrings);

    }
}

From source file:com.ibm.ecod.watson.AlchemyDataNewsTest.java

public static void main(String[] args) {
    AlchemyDataNews service = new AlchemyDataNews();
    service.setApiKey("5fc91e98eacfa5ebf83440e8c6a61d0f60fa380b");

    Map<String, Object> params = new HashMap<String, Object>();

    String[] fields = new String[] { "enriched.url.title", "enriched.url.url", "enriched.url.author",
            "enriched.url.publicationDate", "enriched.url.enrichedTitle.entities",
            "enriched.url.enrichedTitle.docSentiment" };
    params.put(AlchemyDataNews.RETURN, StringUtils.join(fields, ","));
    params.put(AlchemyDataNews.START, "now-60d");
    params.put(AlchemyDataNews.END, "now");
    //params.put(AlchemyDataNews.COUNT, 7);
    //Query on adjacent nested fields: 
    params.put("q.enriched.url.enrichedTitle.entities.entity", "|text=IBM,type=company|");
    params.put("q.enriched.url.enrichedTitle.docSentiment.type", "positive");
    params.put("q.enriched.url.enrichedTitle.taxonomy.taxonomy_.label", "technology and computing");

    DocumentsResult result = service.getNewsDocuments(params);

    System.out.println(result);//from w w  w  . ja  v a2  s  .co m
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("test.pdf");
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("my.pdf"));
    stamper.insertPage(1, PageSize.A4);/*  ww  w. ja  va  2  s. c  om*/
    PdfContentByte cb = stamper.getOverContent(1);
    PdfImportedPage p = stamper.getImportedPage(reader, 2);
    cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 36f, 450);
    p = stamper.getImportedPage(reader, 3);
    cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 300f, 450);
    p = stamper.getImportedPage(reader, 4);
    cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 36f, 100);
    stamper.addAnnotation(PdfAnnotation.createText(stamper.getWriter(), new Rectangle(300f, 350f, 500f, 450f),
            "inserted page", "This page contains a copy of the next three pages.", true, null), 1);
    List list = SimpleBookmark.getBookmark(reader);
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("Title", "title content");
    map.put("Action", "GoTo");
    map.put("Page", "1 FitH 806");
    list.add(0, map);
    stamper.setOutlines(list);
    stamper.close();
}

From source file:CollectionAll.java

public static void main(String[] args) {
    List list1 = new LinkedList();
    list1.add("list");
    list1.add("dup");
    list1.add("x");
    list1.add("dup");
    traverse(list1);// ww w  . ja v a 2 s . c o  m
    List list2 = new ArrayList();
    list2.add("list");
    list2.add("dup");
    list2.add("x");
    list2.add("dup");
    traverse(list2);
    Set set1 = new HashSet();
    set1.add("set");
    set1.add("dup");
    set1.add("x");
    set1.add("dup");
    traverse(set1);
    SortedSet set2 = new TreeSet();
    set2.add("set");
    set2.add("dup");
    set2.add("x");
    set2.add("dup");
    traverse(set2);
    LinkedHashSet set3 = new LinkedHashSet();
    set3.add("set");
    set3.add("dup");
    set3.add("x");
    set3.add("dup");
    traverse(set3);
    Map m1 = new HashMap();
    m1.put("map", "Java2s");
    m1.put("dup", "Kava2s");
    m1.put("x", "Mava2s");
    m1.put("dup", "Lava2s");
    traverse(m1.keySet());
    traverse(m1.values());
    SortedMap m2 = new TreeMap();
    m2.put("map", "Java2s");
    m2.put("dup", "Kava2s");
    m2.put("x", "Mava2s");
    m2.put("dup", "Lava2s");
    traverse(m2.keySet());
    traverse(m2.values());
    LinkedHashMap /* from String to String */ m3 = new LinkedHashMap();
    m3.put("map", "Java2s");
    m3.put("dup", "Kava2s");
    m3.put("x", "Mava2s");
    m3.put("dup", "Lava2s");
    traverse(m3.keySet());
    traverse(m3.values());
}

From source file:com.des.paperbase.ManageData.java

public static void main(String[] args) throws ParseException, IOException {
    ManageData p = new ManageData("DB");

    //p.Create("value");
    Map<String, Object> value = new HashMap<String, Object>();
    //value.put("lastname", "9999");
    value.put("age", "56");
    Map<String, Object> update = new HashMap<String, Object>();
    update.put("lastname", "333");
    update.put("age", "56");
    p.merge("value", value, update, "AND");
    List<Map<String, Object>> output = p.select("value", null, "OR");
    System.out.println(output.size());
    for (int i = 0; i < output.size(); i++) {
        System.out.println(output.get(i));
    }//from  w  ww.j a v a 2  s  .c  o m

}

From source file:com.apress.prospringintegration.transform.Transformer.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:transformer.xml");

    MessageChannel input = context.getBean("input", MessageChannel.class);
    PollableChannel output = context.getBean("output", PollableChannel.class);

    Map<String, String> customerMap = new HashMap<String, String>();
    customerMap.put("firstName", "John");
    customerMap.put("lastName", "Smith");
    customerMap.put("address", "100 State Street");
    customerMap.put("city", "Los Angeles");
    customerMap.put("state", "CA");
    customerMap.put("zip", "90064");

    Message<Map<String, String>> message = MessageBuilder.withPayload(customerMap).build();
    input.send(message);/*  w w  w .  jav a  2 s.c om*/

    Message<?> reply = output.receive();
    System.out.println("received: " + reply.getPayload());
}