List of usage examples for java.util Map put
V put(K key, V value);
From source file:com.apress.prospringintegration.claimcheck.ClaimCheckExample.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "/spring/claimcheck-context.xml"); MessageChannel input = context.getBean("checkinChannel", MessageChannel.class); PollableChannel output = context.getBean("checkoutChannel", 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);//from ww w .j a v a2 s. c o m Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.transform.SerializerTransformer.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:serializer-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"); System.out.println("toString(): " + customerMap.toString()); Message<Map<String, String>> message = MessageBuilder.withPayload(customerMap).build(); input.send(message);//from www .ja v a2 s . c o m Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.transform.ToStringTransformer.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:string-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"); System.out.println("toString(): " + customerMap.toString()); Message<Map<String, String>> message = MessageBuilder.withPayload(customerMap).build(); input.send(message);//from www. j a va 2 s .c o m Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Map objMap = new IdentityHashMap(); Object o1 = new Integer(123); Object o2 = new Integer(123); objMap.put(o1, "first"); objMap.put(o2, "second"); Object v1 = objMap.get(o1); // first Object v2 = objMap.get(o2); // second }
From source file:Main.java
public static void main(String[] s) { //object hash table Hashtable<String, String> table = new Hashtable<String, String>(); // populate the table table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "from java2s.com"); System.out.println("Initial collection: " + table); // create unmodifiable map Map<String, String> m = Collections.unmodifiableMap(table); // try to modify the collection m.put("key3", "value3"); }
From source file:Main.java
public static void main(String[] args) { String str = "this is a test"; char[] char_array = str.toCharArray(); Map<Character, Integer> charCounter = new TreeMap<Character, Integer>(); for (char i : char_array) { charCounter.put(i, charCounter.get(i) == null ? 1 : charCounter.get(i) + 1); }/* ww w. j a v a2s . c om*/ for (Character key : charCounter.keySet()) { System.out.println("occurrence of '" + key + "' is " + charCounter.get(key)); } }
From source file:MainClass.java
public static void main(String args[]) { String[] names = { "A", "J", "B", "E", "P" }; String[] ids = { "1", "2", "9", "8", "7" }; Map<String, String> IDMap = new HashMap<String, String>(); for (int i = 0; i < names.length; i++) IDMap.put(ids[i], names[i]); System.out.println(IDMap.size() + " Students entered: "); System.out.println(IDMap);/*w w w .ja va 2s . c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { Map<String, Integer> map = new HashMap<String, Integer>(); map = new TreeMap(); map.put("a", new Integer(1)); map.put("b", new Integer(2)); map.put("c", new Integer(3)); int size = map.size(); // 2 Object oldValue = map.put("a", new Integer(9)); // 1 oldValue = map.remove("c"); // 3 Iterator it = map.keySet().iterator(); while (it.hasNext()) { Object key = it.next();/* w ww. j a v a2s . c o m*/ } it = map.values().iterator(); while (it.hasNext()) { Object value = it.next(); } }
From source file:com.textocat.textokit.segmentation.GenerateBasicAggregateDescriptor.java
/** * @param args//from w ww. j a va2 s .c o m * @throws ResourceInitializationException */ public static void main(String[] args) throws UIMAException, IOException, SAXException { Map<String, MetaDataObject> aeDescriptions = Maps.newLinkedHashMap(); aeDescriptions.put("tokenizer", TokenizerAPI.getAEImport()); aeDescriptions.put("sentenceSplitter", SentenceSplitterAPI.getAEImport()); String outputPath = "desc/basic-aggregate.xml"; AnalysisEngineDescription desc = PipelineDescriptorUtils.createAggregateDescription(aeDescriptions); FileOutputStream out = FileUtils.openOutputStream(new File(outputPath)); try { desc.toXML(out); } finally { IOUtils.closeQuietly(out); } }
From source file:Main.java
public static void main(final String[] args) { Map<String, String> items; items = new HashMap<String, String>(); items.put("A", "1"); items.put("B", "2"); items.put("C", "3"); display(new RandomIterator<String>(items.keySet().iterator())); display(new RandomIterator<String>(items.keySet().iterator())); }