Example usage for java.util Map put

List of usage examples for java.util Map put

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

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

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

    MessageChannel input = context.getBean("input", MessageChannel.class);
    PollableChannel output = context.getBean("output", PollableChannel.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 .j  a  v  a 2  s  .c om*/

    Message<?> reply = output.receive();

    System.out.println("Reply message: " + reply);

    Map<String, Object> rowMap = (Map<String, Object>) reply.getPayload();

    for (String column : rowMap.keySet()) {
        System.out.println("column: " + column + " value: " + rowMap.get(column));
    }
}

From source file:org.seedstack.spring.batch.fixtures.FlatFileBatchDemo.java

public static void main(String[] argv) throws Exception {
    String jobFile = argv[0];/*from   ww w .ja  va2 s .  co  m*/

    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            new String[] { "simple-job-launcher-context.xml", jobFile });

    Job job = applicationContext.getBean(Job.class);

    Map<String, JobParameter> jobParametersMap = new HashMap<>();

    jobParametersMap.put("file", new JobParameter(argv[1]));

    JobParameters jobParameters = new JobParameters(jobParametersMap);

    JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);

    JobExecution jobExecution = jobLauncher.run(job, jobParameters);

    printStatistics(jobExecution);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Map map = new HashMap<String, String>();
    map.put("cluster", "10.200.111.111");
    map.put("cluster1", "10.200.121.111");

    Product xml = new Product();
    List<Top> top1 = new ArrayList<Top>();
    Set<String> keys = map.keySet();
    for (String key : keys) {
        Top top = new Top();
        top.setMode(key);// ww w.  j  av a 2 s  .  c  om
        top.setAddress((String) map.get(key));
        top1.add(top);
    }
    xml.setTop(top1);
    File file = new File("C:\\kar\\file.xml");
    JAXBContext jaxbContext = JAXBContext.newInstance(Product.class);
    Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

    // output pretty printed
    jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

    jaxbMarshaller.marshal(xml, file);
    jaxbMarshaller.marshal(xml, System.out);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    XMLInputFactory xif = XMLInputFactory.newFactory();
    XMLStreamReader xsr = xif.createXMLStreamReader(new FileReader("data.xml"));
    xsr.nextTag(); // advance to Employees tag
    xsr.nextTag(); // advance to first Employer element
    Map<String, String> map = new HashMap<String, String>();
    while (xsr.getLocalName().equals("Employee")) {
        map.put(xsr.getAttributeValue("", "id"), xsr.getElementText());
        xsr.nextTag(); // advance to next Employer element
    }//w  w  w  .j  a v a2s .co m
}

From source file:br.com.recursive.biblioteca.servicos.EmailService.java

public static void main(String[] args) throws EmailException {

    //        Pessoa p = new Pessoa();
    //        p.setNome("sdsfsdf");
    //        //from   w  ww . j a v  a2s . co m
    //        Contato c = new Contato();
    //        c.setEmail("oelisiany@gmail.com");
    //        
    //        p.setContato(c);
    //        p.setUsuario(new Usuario());
    //        
    //        EmailService es = new EmailService();
    //        es.sendHtmlEmail(p);

    Map<String, Object> map1 = new HashMap<String, Object>();
    map1.put("cpf", "312313123");
    map1.put("id", 1);

    for (String chave : map1.keySet()) {
        System.out.println(chave);
    }
}

From source file:com.apress.prospringintegration.messageflow.workflow.WorkflowMainClient.java

public static void main(String[] ars) throws Exception {
    ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(
            "workflow-gateway.xml");
    classPathXmlApplicationContext.start();

    ProcessEngine processEngine = classPathXmlApplicationContext.getBean(ProcessEngine.class);

    deployProcessDefinitions(processEngine, "processes/hello.bpmn20.xml", "processes/gateway.bpmn20.xml");

    Map<String, Object> processVariables = new HashMap<String, Object>();
    processVariables.put("customerId", 2);

    ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("sigateway",
            processVariables);//from   ww  w  .j  a  va  2  s  .  c om

    log.debug("the process instance has been started: PI ID # " + pi.getId());

    Thread.sleep(1000 * 20);
    log.debug("waited 20s");
}

From source file:Main.java

public static void main(String[] s) {
    // create sorted map
    SortedMap<String, String> map = new TreeMap<String, String>();

    // populate the set
    map.put("1", "New");
    map.put("2", "to");
    map.put("3", "java2s.com");

    System.out.println("Initial sorted map value: " + map);

    // create unmodifiable sorted map
    Map<String, String> unmodsortmap = Collections.unmodifiableSortedMap(map);

    // try to modify the sorted map
    unmodsortmap.put("4", "Modify");
}

From source file:example.stores.StarbucksClient.java

public static void main(String[] args) {

    Traverson traverson = new Traverson(URI.create("http://localhost:8080"), MediaTypes.HAL_JSON);

    Map<String, Object> parameters = new HashMap<>();
    parameters.put("location", "40.740337,-73.995146");
    parameters.put("distance", "0.5miles");

    PagedResources<Resource<Store>> resources = traverson. //
            follow("stores", "search", "by-location").//
            withTemplateParameters(parameters).//
            toObject(TYPE_REFERENCE);//from w  ww  . j a  v a  2  s .  c o m

    PageMetadata metadata = resources.getMetadata();

    System.out.println(
            String.format("Got %s of %s stores: ", resources.getContent().size(), metadata.getTotalElements()));

    for (Resource<Store> resource : resources) {

        Store store = resource.getContent();

        System.out.println(String.format("- %s - %s", store.name, store.address));
    }
}

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);/*from w w w.ja  va  2s  . co 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:io.parallec.sample.app.http.HttpDiffRequestsSameServerApp.java

public static void main(String[] args) {

    ParallelClient pc = new ParallelClient();

    Map<String, Object> responseContext = new HashMap<String, Object>();
    responseContext.put("temp", null);

    pc.prepareHttpGet("/userdata/sample_weather_$ZIP.txt")
            .setReplaceVarMapToSingleTargetSingleVar("ZIP", Arrays.asList("95037", "48824"), "www.parallec.io")
            .setResponseContext(responseContext).execute(new ParallecResponseHandler() {
                public void onCompleted(ResponseOnSingleTask res, Map<String, Object> responseContext) {
                    String temp = new FilterRegex("(.*)").filter(res.getResponseContent());
                    System.out.println("\n!!Temperature: " + temp + " TargetHost: " + res.getHost());
                    responseContext.put("temp", temp);
                }//w  ww .j  a v  a  2s  . c o m
            });

    int tempGlobal = Integer.parseInt((String) responseContext.get("temp"));
    Asserts.check(tempGlobal <= 100 && tempGlobal >= 0,
            " Fail to extract output from sample weather API. Fail different request to same server test");

    pc.releaseExternalResources();

}