List of usage examples for java.util Map get
V get(Object key);
From source file:Main.java
public static void main(final String[] args) { final List<String> asu = new ArrayList<String>(); asu.add("2"); asu.add("11"); asu.add("7"); asu.add("10"); asu.add("7"); asu.add("12"); asu.add("2"); asu.add("11"); asu.add("11"); asu.add("7"); asu.add("7"); asu.add("7"); List<String> list = new ArrayList<String>(); Map<String, Integer> counts = new HashMap<String, Integer>(); list.addAll(asu);/*w ww . j a v a 2 s .co m*/ for (String item : list) { Integer count = counts.get(item); if (count == null) { count = 1; } else { count = count + 1; } counts.put(item, count); } Collections.sort(asu, new Comparator<String>() { @Override public int compare(final String left, final String right) { int result = counts.get(left).compareTo(counts.get(right)); if (result == 0) { result = left.compareTo(right); } return result; } }); System.out.println(asu); }
From source file:com.liferay.mobile.sdk.BuilderAntTask.java
public static void main(String[] args) { Map<String, String> arguments = parseArguments(args); String url = arguments.get("url"); String context = arguments.get("context"); String filter = arguments.get("filter"); StringBuilder sb = new StringBuilder(); sb.append(url);/*from w w w .j a va 2s.c o m*/ if (Validator.isNotNull(context)) { sb.append("/"); sb.append(context); } sb.append("/api/jsonws?discover"); if (Validator.isNull(filter)) { sb.append("=/*"); } else { sb.append("=/"); sb.append(filter); sb.append("/*"); } HttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(sb.toString()); DiscoveryResponseHandler handler = new DiscoveryResponseHandler(); try { String builderType = arguments.get("builder"); Builder builder = null; if (builderType.equals("android")) { builder = new AndroidBuilder(); } Discovery discovery = client.execute(get, handler); PortalVersion version = HttpUtil.getPortalVersion(url); if (Validator.isNull(filter)) { builder.buildAll(version, discovery); } else { builder.build(filter, version, discovery); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { JarFile jarfile = new JarFile("filename.jar"); Manifest manifest = jarfile.getManifest(); Map map = manifest.getEntries(); for (Iterator it = map.keySet().iterator(); it.hasNext();) { String entryName = (String) it.next(); Attributes attrs = (Attributes) map.get(entryName); for (Iterator it2 = attrs.keySet().iterator(); it2.hasNext();) { Attributes.Name attrName = (Attributes.Name) it2.next(); String attrValue = attrs.getValue(attrName); }/* w w w .j a v a 2 s. c o m*/ } }
From source file:com.liferay.mobile.sdk.SDKBuilder.java
public static void main(String[] args) throws IOException { SDKBuilder builder = new SDKBuilder(); Map<String, String> arguments = builder.parseArguments(args); String[] platforms = arguments.get("platforms").split(","); String url = arguments.get("url"); String[] contexts = arguments.get("contexts").split(","); String packageName = arguments.get("packageName"); String filter = arguments.get("filter"); int portalVersion = Integer.valueOf(arguments.get("portalVersion")); String destination = arguments.get("destination"); try {//from ww w . jav a 2s . com builder.build(platforms, url, contexts, packageName, filter, portalVersion, destination); } catch (Exception e) { _log.log(Level.SEVERE, e.getMessage(), e); } }
From source file:com.alibaba.jstorm.utils.FileAttribute.java
public static void main(String[] args) { Map<String, FileAttribute> map = new HashMap<String, FileAttribute>(); FileAttribute attribute = new FileAttribute(); attribute.setFileName("test"); attribute.setIsDir("true"); attribute.setModifyTime(new Date().toString()); attribute.setSize("4096"); map.put("test", attribute); System.out.println("Before:" + map); String jsonString = JStormUtils.to_json(map); Map<String, Map> map2 = (Map<String, Map>) JStormUtils.from_json(jsonString); Map jObject = map2.get("test"); FileAttribute attribute2 = FileAttribute.fromJSONObject(jObject); System.out.println("attribute2:" + attribute2); }
From source file:gov.nih.nci.cabio.portal.portlet.canned.CannedObjectConfig.java
/** * Test harness./* www . j a va 2 s . co m*/ */ public static final void main(String[] args) throws Exception { CannedObjectConfig c = new CannedObjectConfig(); Map<String, ClassObject> classes = c.getClasses(); for (String className : classes.keySet()) { ClassObject config = classes.get(className); System.out.println(className + ": " + config.getLabel()); for (LabeledObject attr : config.getAttributesForRole("SUMMARY")) { System.out.println("\t" + attr.getName() + ": " + attr.getLabel()); } } }
From source file:Main.java
public static void main(String[] args) { Map map = System.getenv(); Set keys = map.keySet();// w w w . j av a 2s .c o m Iterator iterator = keys.iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); String value = (String) map.get(key); System.out.println(key + " = " + value); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Map map = new HashMap(); // Create int wrapper object Integer refInt = new Integer(123); // Store int in map map.put("key", refInt); // Get int value from map refInt = (Integer) map.get("key"); // Get the integer value from wrapper object int i = refInt.intValue(); }
From source file:example.client.CamelMongoJmsStockClient.java
@SuppressWarnings("resource") public static void main(final String[] args) throws Exception { systemProps = loadProperties();//www . j a va2 s. c o m AbstractApplicationContext context = new ClassPathXmlApplicationContext("camel-client.xml"); ProducerTemplate camelTemplate = context.getBean("camelTemplate", ProducerTemplate.class); List<Map<String, Object>> stocks = readJsonsFromMongoDB(); for (Map<String, Object> stock : stocks) { stock.remove("_id"); stock.remove("Earnings Date"); camelTemplate.sendBody(String.format("jms:queue:%s", systemProps.getProperty("ticker.queue.name")), ExchangePattern.InOnly, stock); } new Timer().schedule(new TimerTask() { @Override public void run() { Map<String, Object> aRandomStock = stocks.get(RandomUtils.nextInt(0, stocks.size())); aRandomStock.put("Price", ((Double) aRandomStock.get("Price")) + RandomUtils.nextFloat(0.1f, 9.99f)); camelTemplate.sendBody(String.format("jms:queue:%s", systemProps.getProperty("ticker.queue.name")), ExchangePattern.InOnly, aRandomStock); } }, 1000, 2000); }
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 w w w . ja v a 2s .c o m*/ 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)); } }