List of usage examples for java.util Map put
V put(K key, V value);
From source file:com.qcloud.project.macaovehicle.util.MessageGetter.java
public static void main(String[] args) throws Exception { // StringBuilder stringBuilder = new StringBuilder(); // stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><auditData><url>vehicle</url><success>0</success><vehicle><ric>1000001</ric><reason></reason><state>1</state></vehicle></auditData>"); // System.out.println(stringBuilder.toString()); // String dataPostURL = "http://120.25.12.206:8888/DeclMsg/Ciq"; // MessageGetter.sendXml(stringBuilder.toString(), dataPostURL); Map<String, Object> param = new LinkedHashMap<String, Object>(); param.put("driverIc", "C09000000002a6d32701"); param.put("driverName", ""); param.put("sex", "1"); param.put("birthday", "1991-09-01T00:00:00"); param.put("nationality", ""); param.put("corpName", "??"); param.put("registerNo", "C0900000000347736701"); param.put("drivingValidityDate", "2017-04-17T09:00:00"); param.put("commonFlag", "1"); param.put("residentcardValidityDate", "2014-04-27T09:00:00"); param.put("leftHandFingerprint", "1"); param.put("rightHandFingerprint", "2"); param.put("imageEignvalues", "3"); param.put("certificateNo", "4"); param.put("validityEndDate", "2020-04-17T09:00:00"); param.put("creator", ""); param.put("createDate", "2014-04-17T09:00:00"); param.put("modifier", ""); param.put("modifyDate", "2014-04-17T09:00:00"); param.put("cityCode", ""); param.put("nation", "?"); param.put("tel", "13568877897"); param.put("visaCode", "21212121"); param.put("subscriberCode", "7937"); param.put("visaValidityDate", "2017-04-17T09:00:00"); param.put("icCode", "TDriver000018950"); param.put("toCountry", ""); param.put("fromCountry", ""); param.put("licenseCode", "168819"); param.put("idCard", "440882199110254657"); param.put("secondName", ""); param.put("secondBirthday", "1991-04-17T09:00:00"); param.put("secondCertificateNo", "123456789"); param.put("secondCertificateType", "03"); param.put("visaNo", "123456789"); param.put("stayPeriod", "180"); param.put("residentcardValidityDate", "2017-04-27T09:00:00"); param.put("returnCardNo", "123456789"); param.put("pass", "123456789"); param.put("drivingLicense", "422801197507232815"); param.put("customCode", "12345"); param.put("visaCity", "?"); param.put("certificateType", "01"); param.put("certificateCode", "12345678"); param.put("subscribeDate", "2010-04-17T09:00:00"); param.put("passportNo", "G20961897"); param.put("transactType", "01"); param.put("isAvoidInspect", "N"); param.put("isPriorityInspect", "N"); param.put("remark", ""); String picSourcePath1 = "H://images/?.jpg"; // String picSourcePath1="H://images/1/1.jpg"; String picSourcePath2 = "H://images/1/2.jpeg"; String picSourcePath3 = "H://images/1/3.jpeg"; String picSourcePath4 = "H://images/1/4.jpeg"; String picSourcePath5 = "H://images/1/5.jpeg"; String picSourcePath6 = "H://images/1/6.jpeg"; param.put("driverPhoto", Base64PicUtil.GetImageStr(picSourcePath1)); // param.put("imageA", Base64PicUtil.GetImageStr(picSourcePath2)); // param.put("imageB", Base64PicUtil.GetImageStr(picSourcePath3)); // param.put("imageC", Base64PicUtil.GetImageStr(picSourcePath4)); // param.put("imageD", Base64PicUtil.GetImageStr(picSourcePath5)); String dataStr = MessageGetter.sendMessage(param, "driver", dataPostURL); Map<String, Object> map = XmlParseUtils.XmlToMap(dataStr); System.out.println(dataStr);// w w w . j a va2 s .co m if (map.containsKey("message")) { String message = (String) map.get("message"); if (message.equals("true")) { System.out.println("==================================================="); System.out.println(map); } } System.out.println(dataStr); }
From source file:Main.java
public static void main(String[] args) { Map<String, Integer> wordCounts = new LinkedHashMap<String, Integer>(); String s = "Lorem ipsum dolor sit amet consetetur iam nonumy sadipscing " + "elitr, sed diam nonumy eirmod tempor invidunt ut erat sed " + "labore et dolore magna dolor sit amet aliquyam erat sed diam"; wordCounts.put("sed", 0); wordCounts.put("erat", 0); for (String t : s.split(" ")) { wordCounts.computeIfPresent(t, (k, v) -> v + 1); }//from w w w . ja v a2s . c o m System.out.println(wordCounts); }
From source file:com.aistor.generate.Generate.java
public static void main(String[] args) throws Exception { // ========== ?? ==================== // ??????//from w ww .j a v a 2 s . com // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className} // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4? String packageName = "com.aistor.modules"; String moduleName = "factory"; // ???sys String subModuleName = ""; // ????? String className = "product"; // ??user String classAuthor = "Zaric"; // Zaric String functionName = "?"; // ?? // ??? Boolean isEnable = false; // ========== ?? ==================== if (!isEnable) { logger.error("????isEnable = true"); return; } if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className) || StringUtils.isBlank(functionName)) { logger.error("??????????????"); return; } // ? String separator = File.separator; String classPath = new DefaultResourceLoader().getResource("").getFile().getPath(); String templatePath = classPath.replace( separator + "webapp" + separator + "WEB-INF" + separator + "classes", separator + "java" + separator + "com" + separator + "aistor" + separator + "modules"); String javaPath = classPath.replace(separator + "webapp" + separator + "WEB-INF" + separator + "classes", separator + "java" + separator + (StringUtils.lowerCase(packageName)).replace(".", separator)); String viewPath = classPath.replace(separator + "classes", separator + "views"); // ??? Configuration cfg = new Configuration(); cfg.setDirectoryForTemplateLoading( new File(templatePath.replace("modules", "generate" + separator + "template"))); // ??? Map<String, String> model = Maps.newHashMap(); model.put("packageName", StringUtils.lowerCase(packageName)); model.put("moduleName", StringUtils.lowerCase(moduleName)); model.put("subModuleName", StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : ""); model.put("className", StringUtils.uncapitalize(className)); model.put("ClassName", StringUtils.capitalize(className)); model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); model.put("classVersion", DateUtils.getDate()); model.put("functionName", functionName); model.put("tableName", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "") + "_" + model.get("className")); model.put("urlPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "") + "/" + model.get("className")); model.put("viewPrefix", StringUtils.substringAfterLast(model.get("packageName"), ".") + "/" + model.get("urlPrefix")); model.put("permissionPrefix", model.get("moduleName") + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "") + ":" + model.get("className")); // ? Entity Template template = cfg.getTemplate("entity.ftl"); String content = FreeMarkers.renderTemplate(template, model); String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java"; writeFile(content, filePath); logger.info(filePath); // ? Dao template = cfg.getTemplate("dao.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java"; writeFile(content, filePath); logger.info(filePath); // ? Service template = cfg.getTemplate("service.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java"; writeFile(content, filePath); logger.info(filePath); // ? Controller template = cfg.getTemplate("controller.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java"; writeFile(content, filePath); logger.info(filePath); // ? ViewForm template = cfg.getTemplate("viewForm.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "Form.jsp"; writeFile(content, filePath); logger.info(filePath); // ? ViewList template = cfg.getTemplate("viewList.ftl"); content = FreeMarkers.renderTemplate(template, model); filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator + model.get("className") + "List.jsp"; writeFile(content, filePath); logger.info(filePath); logger.info("????"); }
From source file:fr.inria.atlanmod.kyanos.benchmarks.XmiCreator.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input file"); inputOpt.setArgs(1);// w w w.j a v a 2 s .c o m inputOpt.setRequired(true); Option outputOpt = OptionBuilder.create(OUT); outputOpt.setArgName("OUTPUT"); outputOpt.setDescription("Output file"); outputOpt.setArgs(1); outputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); options.addOption(inputOpt); options.addOption(outputOpt); options.addOption(inClassOpt); CommandLineParser parser = new PosixParser(); try { CommandLine commandLine = parser.parse(options, args); URI sourceUri = URI.createFileURI(commandLine.getOptionValue(IN)); URI targetUri = URI.createFileURI(commandLine.getOptionValue(OUT)); Class<?> inClazz = XmiCreator.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("zxmi", new XMIResourceFactoryImpl()); Resource sourceResource = resourceSet.createResource(sourceUri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if ("zxmi".equals(sourceUri.fileExtension())) { loadOpts.put(XMIResource.OPTION_ZIP, Boolean.TRUE); } Runtime.getRuntime().gc(); long initialUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); LOG.log(Level.INFO, MessageFormat.format("Used memory before loading: {0}", MessageUtil.byteCountToDisplaySize(initialUsedMemory))); LOG.log(Level.INFO, "Loading source resource"); sourceResource.load(loadOpts); LOG.log(Level.INFO, "Source resource loaded"); Runtime.getRuntime().gc(); long finalUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); LOG.log(Level.INFO, MessageFormat.format("Used memory after loading: {0}", MessageUtil.byteCountToDisplaySize(finalUsedMemory))); LOG.log(Level.INFO, MessageFormat.format("Memory use increase: {0}", MessageUtil.byteCountToDisplaySize(finalUsedMemory - initialUsedMemory))); Resource targetResource = resourceSet.createResource(targetUri); Map<String, Object> saveOpts = new HashMap<String, Object>(); targetResource.save(saveOpts); LOG.log(Level.INFO, "Start moving elements"); targetResource.getContents().clear(); targetResource.getContents().addAll(sourceResource.getContents()); LOG.log(Level.INFO, "End moving elements"); LOG.log(Level.INFO, "Start saving"); targetResource.save(saveOpts); LOG.log(Level.INFO, "Saved"); targetResource.unload(); } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }
From source file:com.alibaba.dubbo.examples.redis.RedisConsumer.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { String config = RedisConsumer.class.getPackage().getName().replace('.', '/') + "/redis-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start();//from ww w . j av a2 s .c o m Map<String, Object> cache = (Map<String, Object>) context.getBean("cache"); cache.remove("hello"); Object value = cache.get("hello"); System.out.println(value); if (value != null) { throw new IllegalStateException(value + " != null"); } cache.put("hello", "world"); value = cache.get("hello"); System.out.println(value); if (!"world".equals(value)) { throw new IllegalStateException(value + " != world"); } }
From source file:LogTest.java
public static void main(String[] args) throws IOException { String inputfile = args[0];//from www. j a v a2 s. c o m String outputfile = args[1]; Map<String, Integer> map = new TreeMap<String, Integer>(); Scanner scanner = new Scanner(new File(inputfile)); while (scanner.hasNext()) { String word = scanner.next(); Integer count = map.get(word); count = (count == null ? 1 : count + 1); map.put(word, count); } scanner.close(); List<String> keys = new ArrayList<String>(map.keySet()); Collections.sort(keys); PrintWriter out = new PrintWriter(new FileWriter(outputfile)); for (String key : keys) out.println(key + " : " + map.get(key)); out.close(); }
From source file:com.joliciel.jochre.yiddish.JochreYiddish.java
public static void main(String[] args) throws Exception { Map<String, String> argMap = new HashMap<String, String>(); for (String arg : args) { int equalsPos = arg.indexOf('='); String argName = arg.substring(0, equalsPos); String argValue = arg.substring(equalsPos + 1); argMap.put(argName, argValue); }/*from ww w.ja va2 s .c om*/ JochreYiddish jochre = new JochreYiddish(); jochre.execute(argMap); }
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 w w .j a v a 2s . c o m }
From source file:com.alibaba.dubbo.examples.memcached.MemcachedConsumer.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { String config = MemcachedConsumer.class.getPackage().getName().replace('.', '/') + "/memcached-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start();//w w w. ja v a 2s .c om Map<String, Object> cache = (Map<String, Object>) context.getBean("cache"); cache.remove("hello"); Object value = cache.get("hello"); System.out.println(value); if (value != null) { throw new IllegalStateException(value + " != null"); } cache.put("hello", "world"); value = cache.get("hello"); System.out.println(value); if (!"world".equals(value)) { throw new IllegalStateException(value + " != world"); } System.in.read(); }
From source file:net.itransformers.idiscover.discoverylisteners.TopologyDeviceLogger.java
public static void main(String[] args) throws FileNotFoundException, JAXBException { String path = "tmp1"; File dir = new File(path); String[] files = dir.list(new FilenameFilter() { public boolean accept(File dir, String name) { return (name.startsWith("device") && name.endsWith(".xml")); }/*from w w w . j a v a 2 s . c o m*/ }); TopologyDeviceLogger logger = new TopologyDeviceLogger(path); String host = "10.33.0.5"; String snmpROComm = "public"; Map<String, String> resourceParams = new HashMap<String, String>(); resourceParams.put("community", snmpROComm); resourceParams.put("version", "1"); Resource resource = new Resource(host, null, resourceParams); for (String fileName : files) { FileInputStream is = new FileInputStream(path + File.separator + fileName); DiscoveredDeviceData discoveredDeviceData = null; try { discoveredDeviceData = JaxbMarshalar.unmarshal(DiscoveredDeviceData.class, is); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } String deviceName = fileName.substring("device-".length(), fileName.length() - ".xml".length()); logger.handleDevice(deviceName, null, discoveredDeviceData, resource); } }