List of usage examples for java.util Map get
V get(Object key);
From source file:com.example.license.LicenseUtil.java
public static void main(String[] args) { String key = "A1B2C3D4E5F6"; LicenseData licenseData = new LicenseData(); licenseData.setUserNum(50000000);/*www.ja v a2 s . c om*/ 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.ebay.spine.Launcher.java
public static void main(String[] args) throws Exception { // not using the default parsing for the hub. Creating a simple one from the default. GridHubConfiguration config = new GridHubConfiguration(); // adding the VNC capable servlet. List<String> servlets = new ArrayList<String>(); servlets.add("web.ConsoleVNC"); config.setServlets(servlets);/*from w ww .j ava2s . co m*/ // capabilities are dynamic for VMs. config.setThrowOnCapabilityNotPresent(false); // forcing the host from command line param as the hub gets confused by all the VMWare network interfaces. for (int i = 0; i < args.length; i++) { if (args[i].startsWith("hubhost=")) { config.setHost(args[i].replace("hubhost=", "")); } } Hub h = new Hub(config); h.start(); // and the nodes. // load the node templates. Map<String, JSONObject> templatesByNameMap = getTemplates("eugrid.json"); // get the template to use for each VM Map<String, String> vmsMapping = getVMtoTemplateMapping("nodes.properties"); // register each node using its template. for (String id : vmsMapping.keySet()) { String templateName = vmsMapping.get(id); JSONObject request = templatesByNameMap.get(templateName); request.getJSONObject("configuration").put("vm", id); BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", "http://" + hub + "/grid/register/"); r.setEntity(new StringEntity(request.toString())); DefaultHttpClient client = new DefaultHttpClient(); URL hubURL = new URL("http://" + hub); HttpHost host = new HttpHost(hubURL.getHost(), hubURL.getPort()); HttpResponse response = client.execute(host, r); } }
From source file:net.itransformers.bgpPeeringMap.BgpPeeringMap.java
public static void main(String[] args) throws Exception { Map<String, String> params = CmdLineParser.parseCmdLine(args); logger.info("input params" + params.toString()); final String settingsFile = params.get("-s"); if (settingsFile == null) { printUsage("bgpPeeringMap.properties"); return;/* w w w. j a va2 s . c om*/ } discover(); }
From source file:net.landora.justintv.JustinTVAPI.java
public static void main(String[] args) throws Exception { List<JustinArchive> archives = readArchives("tsmtournaments", 64); Map<String, List<JustinArchive>> groups = new HashMap<String, List<JustinArchive>>(); for (int i = 0; i < archives.size(); i++) { JustinArchive archive = archives.get(i); List<JustinArchive> group = groups.get(archive.getBroadcastId()); if (group == null) { group = new ArrayList<JustinArchive>(archive.getBroadcastPart()); groups.put(archive.getBroadcastId(), group); }/*w w w .j a va 2 s . c om*/ group.add(archive); } BroadcastSorter sorter = new BroadcastSorter(); for (List<JustinArchive> group : groups.values()) { Collections.sort(group, sorter); JustinArchive base = group.get(group.size() - 1); StringBuffer cmd = new StringBuffer(); cmd.append("mkvmerge -o \""); cmd.append(base.getBroadcastId()); cmd.append(" - "); cmd.append(base.getTitle()); cmd.append("\" "); for (int i = 0; i < group.size(); i++) { JustinArchive archive = group.get(i); if (i > 0) cmd.append("+ "); cmd.append(archive.getId()); cmd.append(".mkv "); } System.out.println(cmd); } }
From source file:Main.java
public static void main(String[] argv) { Map map = new HashMap(); map.put("Adobe", "Mountain View, CA"); map.put("IBM", "White Plains, NY"); map.put("Learning Tree", "Los Angeles, CA"); Iterator k = map.keySet().iterator(); while (k.hasNext()) { String key = (String) k.next(); System.out.println("Key " + key + "; Value " + (String) map.get(key)); }/*from ww w .j a va 2 s .co m*/ }
From source file:Main.java
public static void main(String[] args) { Map<String, int[]> map = new TreeMap<String, int[]>(); int[] array = new int[3]; array[0] = 0;// www . ja va2s . c o m array[1] = 1; array[2] = 2; map.put("array", array); Iterator<String> iter = map.keySet().iterator(); while (iter.hasNext()) { String arrayName = iter.next(); array = map.get(arrayName); System.out.print(arrayName + ":"); for (int i = 0; i < array.length; i++) { System.out.print(array[i]); } } }
From source file:org.alex73.osm.validators.vioski.Export.java
public static void main(String[] args) throws Exception { RehijonyLoad.load(Env.readProperty("dav") + "/Rehijony.xml"); osm = new Belarus(); String dav = Env.readProperty("dav") + "/Nazvy_nasielenych_punktau.csv"; List<Miesta> daviednik = new CSV('\t').readCSV(dav, Miesta.class); Map<String, List<Mdav>> rajony = new TreeMap<>(); for (Miesta m : daviednik) { String r = m.rajon.startsWith("<") ? m.rajon : m.rajon + " "; List<Mdav> list = rajony.get(r); if (list == null) { list = new ArrayList<>(); rajony.put(r, list);/*from ww w . ja v a 2 s .c o m*/ } Mdav mm = new Mdav(); mm.osmID = m.osmID; mm.ss = m.sielsaviet; mm.why = m.osmComment; mm.nameBe = m.nazvaNoStress; mm.nameRu = m.ras; mm.varyjantBe = m.varyjantyBel; mm.varyjantRu = m.rasUsedAsOld; list.add(mm); } placeTag = osm.getTagsPack().getTagCode("place"); osm.byTag("place", o -> o.isNode() && !o.getTag(placeTag).equals("island") && !o.getTag(placeTag).equals("islet"), o -> processNode((IOsmNode) o)); String outDir = Env.readProperty("out.dir"); File foutDir = new File(outDir + "/vioski"); foutDir.mkdirs(); Map<String, String> padzielo = new TreeMap<>(); for (Voblasc v : RehijonyLoad.kraina.getVoblasc()) { for (Rajon r : v.getRajon()) { padzielo.put(r.getNameBe(), osm.getObject(r.getOsmID()).getTag("name", osm)); } } ObjectMapper om = new ObjectMapper(); String o = "var data={};\n"; o += "data.dav=" + om.writeValueAsString(rajony) + "\n"; o += "data.map=" + om.writeValueAsString(map) + "\n"; o += "data.padziel=" + om.writeValueAsString(padzielo) + "\n"; FileUtils.writeStringToFile(new File(outDir + "/vioski/data.js"), o); FileUtils.copyFileToDirectory(new File("vioski/control.js"), foutDir); FileUtils.copyFileToDirectory(new File("vioski/vioski.html"), foutDir); }
From source file:com.google.infrastructuredmap.MapAndMarkdownExtractorMain.java
public static void main(String[] args) throws IOException, ParseException { Options options = new Options(); options.addOption(ARG_KML, true, "path to KML input"); options.addOption(ARG_MARKDOWN, true, "path to Markdown input"); options.addOption(ARG_JSON_OUTPUT, true, "path to write json output"); options.addOption(ARG_JSONP, true, "JSONP template to wrap output JSON data"); CommandLineParser parser = new DefaultParser(); CommandLine cli = parser.parse(options, args); // Extract map features from the input KML. MapData data = null;/*from w ww . j a v a2 s. com*/ try (InputStream in = openStream(cli.getOptionValue(ARG_KML))) { Kml kml = Kml.unmarshal(in); data = MapDataExtractor.extractMapData(kml); } // Extract project features from the input Markdown. Map<String, List<ProjectReference>> references = MarkdownReferenceExtractor .extractReferences(Paths.get(cli.getOptionValue(ARG_MARKDOWN))); for (MapFeature feature : data.features) { List<ProjectReference> referencesForId = references.get(feature.id); if (referencesForId == null) { throw new IllegalStateException("Unknown project reference: " + feature.id); } feature.projects = referencesForId; } // Write the resulting data to the output path. Gson gson = new Gson(); try (FileWriter out = new FileWriter(cli.getOptionValue(ARG_JSON_OUTPUT))) { String json = gson.toJson(data); if (cli.hasOption(ARG_JSONP)) { json = String.format(cli.getOptionValue(ARG_JSONP), json); } out.write(json); } }
From source file:flink.benchmark.AdvertisingTopologyNative.java
public static void main(final String[] args) throws Exception { ParameterTool parameterTool = ParameterTool.fromArgs(args); Map conf = Utils.findAndReadConfigFile(parameterTool.getRequired("confPath"), true); int kafkaPartitions = ((Number) conf.get("kafka.partitions")).intValue(); int hosts = ((Number) conf.get("process.hosts")).intValue(); int cores = ((Number) conf.get("process.cores")).intValue(); ParameterTool flinkBenchmarkParams = ParameterTool.fromMap(getFlinkConfs(conf)); LOG.info("conf: {}", conf); LOG.info("Parameters used: {}", flinkBenchmarkParams.toMap()); StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.getConfig().setGlobalJobParameters(flinkBenchmarkParams); // Set the buffer timeout (default 100) // Lowering the timeout will lead to lower latencies, but will eventually reduce throughput. env.setBufferTimeout(flinkBenchmarkParams.getLong("flink.buffer-timeout", 100)); if (flinkBenchmarkParams.has("flink.checkpoint-interval")) { // enable checkpointing for fault tolerance env.enableCheckpointing(flinkBenchmarkParams.getLong("flink.checkpoint-interval", 1000)); }/*from w w w . ja v a 2 s . com*/ // set default parallelism for all operators (recommended value: number of available worker CPU cores in the cluster (hosts * cores)) env.setParallelism(hosts * cores); DataStream<String> messageStream = env .addSource(new FlinkKafkaConsumer082<String>(flinkBenchmarkParams.getRequired("topic"), new SimpleStringSchema(), flinkBenchmarkParams.getProperties())) .setParallelism(Math.min(hosts * cores, kafkaPartitions)); messageStream.rebalance() // Parse the String as JSON .flatMap(new DeserializeBolt()) //Filter the records if event type is "view" .filter(new EventFilterBolt()) // project the event .<Tuple2<String, String>>project(2, 5) // perform join with redis data .flatMap(new RedisJoinBolt()) // process campaign .keyBy(0).flatMap(new CampaignProcessor()); env.execute(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object keyObject = ""; Object valueObject = ""; Map weakMap = new WeakHashMap(); weakMap.put(keyObject, valueObject); WeakReference weakValue = new WeakReference(valueObject); weakMap.put(keyObject, weakValue);/*from w ww . java2s . c o m*/ Iterator it = weakMap.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); weakValue = (WeakReference) weakMap.get(key); if (weakValue == null) { System.out.println("Value has been garbage-collected"); } else { System.out.println("Get value"); valueObject = weakValue.get(); } } }