List of usage examples for java.util Map put
V put(K key, V value);
From source file:biz.netcentric.cq.tools.actool.configreader.YamlMacroProcessorImpl.java
public static void main(String[] args) throws Exception { Map<Object, Object> userMap = new HashMap<Object, Object>(); userMap.put("x", new Integer(123)); userMap.put("y", new Integer(456)); userMap.put("TEST", "a long test value"); String expr = "x= ---- ${upperCase(splitByWholeSeparator(TEST,'long')[1])}"; String val = new YamlMacroElEvaluator().evaluateEl(expr, String.class, userMap); System.out.println("the value for " + expr + " =>> " + val); }
From source file:it.polito.tellmefirst.web.rest.TMFServer.java
/** * TMF starting point. From rest directory, launch this command: * mvn exec:java -Dexec.mainClass="it.polito.temefirst.web.rest.TMFServer" -Dexec.args="<path_to_TMF_installation>/conf/server.properties" * or use the run.sh file in bin directory */// w ww .j a v a 2 s . co m public static void main(String[] args) throws TMFConfigurationException, TMFIndexesWarmUpException, URISyntaxException, InterruptedException, IOException { LOG.debug("[main] - BEGIN"); URI serverURI = new URI("http://localhost:2222/rest/"); String configFileName = args[0]; new TMFVariables(configFileName); // XXX I put the code of IndexUtil.init() here, because, for now, I need a reference of SimpleSearchers for the Enhancer // build italian searcher Directory contextIndexDirIT = LuceneManager.pickDirectory(new File(TMFVariables.CORPUS_INDEX_IT)); LOG.info("Corpus index used for italian: " + contextIndexDirIT); LuceneManager contextLuceneManagerIT = new LuceneManager(contextIndexDirIT); contextLuceneManagerIT .setLuceneDefaultAnalyzer(new ItalianAnalyzer(Version.LUCENE_36, TMFVariables.STOPWORDS_IT)); ITALIAN_CORPUS_INDEX_SEARCHER = new SimpleSearcher(contextLuceneManagerIT); // build english searcher Directory contextIndexDirEN = LuceneManager.pickDirectory(new File(TMFVariables.CORPUS_INDEX_EN)); LOG.info("Corpus index used for english: " + contextIndexDirEN); LuceneManager contextLuceneManagerEN = new LuceneManager(contextIndexDirEN); contextLuceneManagerEN .setLuceneDefaultAnalyzer(new EnglishAnalyzer(Version.LUCENE_36, TMFVariables.STOPWORDS_EN)); ENGLISH_CORPUS_INDEX_SEARCHER = new SimpleSearcher(contextLuceneManagerEN); // build kb italian searcher String kbDirIT = TMFVariables.KB_IT; String residualKbDirIT = TMFVariables.RESIDUAL_KB_IT; ITALIAN_KB_INDEX_SEARCHER = new KBIndexSearcher(kbDirIT, residualKbDirIT); // build kb english searcher String kbDirEN = TMFVariables.KB_EN; String residualKbDirEN = TMFVariables.RESIDUAL_KB_EN; ENGLISH_KB_INDEX_SEARCHER = new KBIndexSearcher(kbDirEN, residualKbDirEN); enhancer = new Enhancer(ITALIAN_CORPUS_INDEX_SEARCHER, ENGLISH_CORPUS_INDEX_SEARCHER, ITALIAN_KB_INDEX_SEARCHER, ENGLISH_KB_INDEX_SEARCHER); italianClassifier = new Classifier("it", ITALIAN_CORPUS_INDEX_SEARCHER); englishClassifier = new Classifier("en", ENGLISH_CORPUS_INDEX_SEARCHER); //The following is adapted from DBpedia Spotlight (https://github.com/dbpedia-spotlight/dbpedia-spotlight) final Map<String, String> initParams = new HashMap<String, String>(); initParams.put("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core." + "PackagesResourceConfig"); initParams.put("com.sun.jersey.config.property.packages", "it.polito.tellmefirst.web.rest.services"); initParams.put("com.sun.jersey.config.property.WadlGeneratorConfig", "it.polito.tellmefirst.web.rest.wadl." + "ExternalUriWadlGeneratorConfig"); SelectorThread threadSelector = GrizzlyWebContainerFactory.create(serverURI, initParams); threadSelector.start(); System.err.println("Server started in " + System.getProperty("user.dir") + " listening on " + serverURI); Thread warmUp = new Thread() { public void run() { } }; warmUp.start(); while (running) { Thread.sleep(100); } threadSelector.stopEndpoint(); System.exit(0); LOG.debug("[main] - END"); }
From source file:JavaFileGenerator.java
public static void main(String[] args) throws Exception { Map map = new HashMap(); map.put("falseArg", Boolean.FALSE); map.put("trueArg", Boolean.TRUE); map.put("stringValue", "someString"); new JavaFileGenerator(args[0], map).generate(new PrintWriter(args[1])); }
From source file:example.Main.java
public static void main(String[] args) throws Exception { Class[] classes = new Class[3]; classes[0] = A.class; classes[1] = B.class; classes[2] = C.class; JAXBContext jc = JAXBContext.newInstance(classes); JAXBIntrospector ji = jc.createJAXBIntrospector(); Map<QName, Class> classByQName = new HashMap<QName, Class>(classes.length); for (Class clazz : classes) { QName qName = ji.getElementName(clazz.newInstance()); if (null != qName) { classByQName.put(qName, clazz); }/* ww w.j av a 2s . c o m*/ } QName qName = new QName("http://www.example.com", "EH"); System.out.println(classByQName.get(qName)); }
From source file:net.sf.excelutils.tags.IfTag.java
public static void main(String[] args) { Interpreter in = new Interpreter(); try {//w ww . j a v a 2s. c o m in.set("a", "5a"); in.set("b", "5a"); List errors = new ArrayList(); errors.add("abc"); Map context = new HashMap(); context.put("errors", errors); in.set("context", context); in.eval("bar=\"5a\"==\"5a\""); System.out.println(in.get("bar")); System.out.println("ab${addd}dd${cccc}aa".replaceAll("\\$\\{|\\}", "")); System.out.println(in.eval("(context.get(\"errors\").size() == 2)")); System.out.println(in.eval("abc == null")); } catch (EvalError e) { e.printStackTrace(); } }
From source file:com.example.license.LicenseUtil.java
public static void main(String[] args) { String key = "A1B2C3D4E5F6"; LicenseData licenseData = new LicenseData(); licenseData.setUserNum(50000000);/*from w w w.java2 s . c o m*/ licenseData.setSpaceSum(1000000000); licenseData.setEndTime(new Date()); try { String source = convertToString(licenseData); log.info("license data " + source); String secret = generateSecret(key, licenseData); log.info(" " + secret); String encryptData = DESUtil.encrypt(source, secret); log.info("license data?: " + encryptData); Map<String, String> ml = new HashMap<String, String>(); ml.put("data", encryptData); ml.put("secret", secret); String license = convertToString(ml); log.info("license : " + license); String seed = "1"; String encrypt_license = RSAUtil.encrypt(license, seed); log.info("encrypt_license : " + encrypt_license); String decrypt_license = RSAUtil.decrypt(encrypt_license, seed); log.info("decrypt_license : " + decrypt_license); @SuppressWarnings("unchecked") Map<String, String> decrypt_eicense_obj = convertToObjcet(decrypt_license, Map.class); String encrypt_data = decrypt_eicense_obj.get("data"); log.info("encrypt_data : " + encrypt_data); String secret_ = decrypt_eicense_obj.get("secret"); // LicenseData ld // =generateLicense(decrypt_license,LicenseData.class); // secret_+=ld.getEndTime().getTime(); log.info(" : " + secret_); String decryptData = DESUtil.decrypt(encrypt_data, secret_); System.out.println("?: " + decryptData); Sigar sigar = new Sigar(); try { Cpu cpu = sigar.getCpu(); log.info(cpu.toString()); } catch (SigarException e) { e.printStackTrace(); } OperatingSystem os = OperatingSystem.getInstance(); log.info(os.toString()); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.manydesigns.portofino.utils.JsonMapper.java
/** * /* w ww . j a v a2 s . c o m*/ */ public static void main(String[] args) { // List<String> months = Lists.newArrayList(); for (int t_i = 1; t_i <= 12; t_i++) { months.add(t_i + ""); } String json = JsonMapper.getInstance().toJson(months); System.out.println(json); List<Map<String, Object>> list = Lists.newArrayList(); Map<String, Object> map = Maps.newHashMap(); map.put("id", 1); map.put("pId", -1); map.put("name", ""); list.add(map); map = Maps.newHashMap(); map.put("id", 2); map.put("pId", 1); map.put("name", ""); map.put("open", true); list.add(map); json = JsonMapper.getInstance().toJson(list); System.out.println(json); }
From source file:com.oneops.search.msg.processor.CIMessageProcessor.java
public static void main(String[] args) { Map<String, String> map = new HashMap<>(); map.put("test", "Nov 5 21:08:38 2019 GMT"); map.put("test1", "Nov 5 21:08:38 2019 GMT"); convertIllegalDateFormat(map, "test"); convertIllegalDateFormat(map, "test1"); System.out.println(map);//from w w w. j a v a 2 s. co m System.out.println(ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(map.get("test"))); System.out.println(ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(map.get("test1"))); }
From source file:com.example.geomesa.authorizations.GeoServerAuthorizationsTutorial.java
/** * Main entry point. Executes queries against an existing GDELT dataset. * * @param args/* w w w . j a v a2s .c o m*/ * * @throws Exception */ public static void main(String[] args) throws Exception { // read command line options - this contains the path to geoserver and the data store to query CommandLineParser parser = new BasicParser(); Options options = SetupUtil.getWfsOptions(); CommandLine cmd = parser.parse(options, args); String geoserverHost = cmd.getOptionValue(SetupUtil.GEOSERVER_URL); if (!geoserverHost.endsWith("/")) { geoserverHost += "/"; } // create the URL to GeoServer. Note that we need to point to the 'GetCapabilities' request, // and that we are using WFS version 1.0.0 String geoserverUrl = geoserverHost + "wfs?request=GetCapabilities&version=1.0.0"; // create the geotools configuration for a WFS data store Map<String, String> configuration = new HashMap<String, String>(); configuration.put(WFSDataStoreFactory.URL.key, geoserverUrl); configuration.put(WFSDataStoreFactory.WFS_STRATEGY.key, "geoserver"); configuration.put(WFSDataStoreFactory.TIMEOUT.key, cmd.getOptionValue(SetupUtil.TIMEOUT, "99999")); System.out.println("Executing query against '" + geoserverHost + "' with client keystore '" + System.getProperty("javax.net.ssl.keyStore") + "'"); // verify we have gotten the correct datastore WFSDataStore wfsDataStore = (WFSDataStore) DataStoreFinder.getDataStore(configuration); assert wfsDataStore != null; // the geoserver data store to query String geoserverDataStore = cmd.getOptionValue(SetupUtil.FEATURE_STORE); executeQuery(geoserverDataStore, wfsDataStore); }
From source file:com.hisuntech.ArchOnlineSchoolAuth.test.aop.MyTest.java
public static void main(String[] args) throws HttpException, IOException { Map<String, String> sParaTemp = new HashMap<String, String>(); //RqPnCoPT3K9%252Fvwbh3InQ8DTlBqQF2KlM0p08vXXXXXXXXXXMK3zQ4hsFX%252F3tstP sParaTemp.put("WIDout_trade_no", "16051800000164"); //sParaTemp.put("WIDsubject", "16051800000164"); sParaTemp.put("WIDtotal_fee", "0.1"); sParaTemp.put("payType", "10"); // sParaTemp.put("seller_id", "2088021521071865"); // sParaTemp.put("service", "alipay.wap.create.direct.pay.by.user"); // sParaTemp.put("subject", "?-16051800000164"); // sParaTemp.put("total_fee", "0.01"); // sParaTemp.put("trade_no", "2016051821001004490280869093"); // sParaTemp.put("trade_status", "TRADE_SUCCESS"); // sParaTemp.put("sign_type", "RSA"); String url = "http://192.168.1.126:8080/ArchOnlineSchoolBack/getAlipayAdr/getAdr"; //String url = "http://101.200.75.226:8083/ArchOnlineSchoolBack/getAlipayAdr/getAdr"; HttpProtocolHandler httpProtocolHandler = HttpProtocolHandler.getInstance(); HttpRequest request = new HttpRequest(HttpResultType.BYTES); //?//from ww w. j a va2 s . c o m request.setCharset(AlipayConfigTX.input_charset); request.setParameters(generatNameValuePair(sParaTemp)); request.setUrl(url); HttpResponse response = httpProtocolHandler.execute(request, "", ""); if (response == null) { System.out.println("return null;"); } String strResult = response.getStringResult(); System.out.println("return strResult;" + strResult); }