List of usage examples for java.util HashMap HashMap
public HashMap()
From source file:edu.teilar.jcrop.service.ApplicationTest2.java
public static void main(String[] args) { RestTemplate restTemplate = new RestTemplate(); // model to return Map<String, Object> model = new HashMap<String, Object>(); // set up json mapper MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); ObjectMapper mapper = new ObjectMapper(); converter.setObjectMapper(mapper);//from w w w . j ava2 s . c om List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(converter); restTemplate.setMessageConverters(messageConverters); String uri = "http://localhost:8080/jcrop-service/rest/learningobjects/{kobj}"; KObject kobj = restTemplate.getForObject(uri, KObject.class, "complex1"); System.out.println("Learning Object: " + kobj.getName()); System.out.println("Target Concept: " + kobj.getTargetEducationalObjective().getName()); ArrayList<Node> traverseArrayList = new ArrayList<Node>(); traverseKObject(kobj, traverseArrayList); System.out.println("sss" + traverseArrayList); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step5bGoldLabelStatistics.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { String inputDir = args[0];//from w w w . jav a2s. c o m Collection<File> files = IOHelper.listXmlFiles(new File(inputDir)); int totalPairsWithReasonSameAsGold = 0; DescriptiveStatistics ds = new DescriptiveStatistics(); DescriptiveStatistics statsPerTopic = new DescriptiveStatistics(); Map<String, Integer> goldDataDistribution = new HashMap<>(); int totalGoldReasonTokens = 0; for (File file : files) { List<AnnotatedArgumentPair> argumentPairs = (List<AnnotatedArgumentPair>) XStreamTools.getXStream() .fromXML(file); int pairsPerTopicCounter = 0; for (AnnotatedArgumentPair annotatedArgumentPair : argumentPairs) { String goldLabel = annotatedArgumentPair.getGoldLabel(); int sameInOnePair = 0; if (goldLabel != null) { if (!goldDataDistribution.containsKey(goldLabel)) { goldDataDistribution.put(goldLabel, 0); } goldDataDistribution.put(goldLabel, goldDataDistribution.get(goldLabel) + 1); // get gold reason statistics for (AnnotatedArgumentPair.MTurkAssignment assignment : annotatedArgumentPair.mTurkAssignments) { String label = assignment.getValue(); if (goldLabel.equals(label)) { sameInOnePair++; totalGoldReasonTokens += assignment.getReason().split("\\W+").length; } } pairsPerTopicCounter++; } ds.addValue(sameInOnePair); totalPairsWithReasonSameAsGold += sameInOnePair; } statsPerTopic.addValue(pairsPerTopicCounter); } System.out.println("Total reasons matching gold " + totalPairsWithReasonSameAsGold); System.out.println(ds); int totalPairs = 0; for (Integer pairs : goldDataDistribution.values()) { totalPairs += pairs; } System.out.println(goldDataDistribution); System.out.println(goldDataDistribution.values()); System.out.println("Total pairs: " + totalPairs); System.out.println("Stats per topic: " + statsPerTopic); System.out.println("Total gold reason tokens: " + totalGoldReasonTokens); }
From source file:cz.hobrasoft.pdfmu.jackson.SchemaGenerator.java
public static void main(String[] args) throws JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); // nice formatting SchemaFactoryWrapper visitor = new SchemaFactoryWrapper(); Map<String, Type> types = new HashMap<>(); types.put("RpcResponse", RpcResponse.class); types.put("result/inspect", Inspect.class); types.put("result/version set", VersionSet.class); types.put("result/signature add", SignatureAdd.class); types.put("result/empty", EmptyResult.class); for (Map.Entry<String, Type> e : types.entrySet()) { String name = e.getKey(); String filename = String.format("schema/%s.json", name); Type type = e.getValue(); mapper.acceptJsonFormatVisitor(mapper.constructType(type), visitor); JsonSchema jsonSchema = visitor.finalSchema(); mapper.writeValue(new File(filename), jsonSchema); }/* www . j a v a 2 s.c o m*/ }
From source file:com.espertech.esperio.regression.adapter.SupportJMSSender.java
public static void main(String[] args) throws JMSException { SupportJMSSender sender = new SupportJMSSender(); //sender.sendSerializable("hello"); Map<String, Object> values = new HashMap<String, Object>(); values.put("prop1", "a"); sender.sendMap(values);/*from w ww . j a v a2s. c o m*/ sender.destroy(); System.exit(1); }
From source file:com.tc.simple.apn.quicktests.Test2.java
/** * @param args//from w w w . ja v a 2 s.c o m * @throws IOException */ public static void main(String[] args) { try { System.out.println(KeyManagerFactory.getDefaultAlgorithm()); String token = "8cebc7c08f79fa62f0994eb4298387ff930857ff8d14a50de431559cf476b223"; InputStream in = Test2.class.getResourceAsStream("webshell-dev.p12"); byte[] p12 = IOUtils.toByteArray(in); Map<String, Object> custom = new HashMap<String, Object>(); //custom.put("scriptfunction", "afterPushNotice"); //custom.put("customdata", "hi there"); //custom.put("url","http://google.com"); for (int i = 0; i < 2; i++) { Payload payload = new PayloadFactory().buildPayload(token, "Hi There " + i, 0, null, custom); //String payload="{\"aps\":{\"alert\":\"yabadabadooo" + i + "\"}}"; //String payload = "{\"aps\":{\"alert\":\"Hi There" + i + "\"}}"; send(p12, payload.getToken(), i * 100, payload.getJson()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.jslsolucoes.tagria.doc.generator.DocGenerator.java
public static void main(String[] args) throws IOException { String workspace = args[0];/*from ww w. j av a 2 s. co m*/ Map<String, List<Tag>> groupments = new HashMap<>(); String html = FileUtils.readFileToString( new File(workspace + "/tagria-lib/src/main/resources/META-INF/html.tld"), CHARSET); String ajax = FileUtils.readFileToString( new File(workspace + "/tagria-lib/src/main/resources/META-INF/ajax.tld"), CHARSET); XStream xStream = new XStream(); xStream.processAnnotations(Taglib.class); Taglib taglibForHtml = (Taglib) xStream.fromXML(html); Taglib taglibForAjax = (Taglib) xStream.fromXML(ajax); List<Tag> tags = new ArrayList<Tag>(); tags.addAll(taglibForHtml.getTags()); tags.addAll(taglibForAjax.getTags()); for (Tag tag : tags) { List<Tag> groups = groupments.get(tag.getGroup()); if (groups == null) { groupments.put(tag.getGroup(), new ArrayList<>()); } groupments.get(tag.getGroup()).add(tag); StringBuilder template = new StringBuilder( "<%@include file=\"../app/taglibs.jsp\"%> " + "<html:view title=\"{title}\"> " + " <html:panel> " + " <html:panelHead label=\"" + tag.getName() + "\"></html:panelHead> " + " <html:panelBody> " + " <html:tabPanel> " + " <html:tab label=\"{about}\" active=\"true\"> " + " <html:alert state=\"warning\"> " + " " + tag.getDescription() + " " + " </html:alert> " + " </html:tab> " + " <html:tab label=\"{attributes}\"> "); if (CollectionUtils.isEmpty(tag.getAttributes())) { template.append("<html:alert state=\"info\" label=\"{tag.empty.attributes}\"></html:alert>"); } else { template.append("<html:table><html:tableLine>" + "<html:tableColumn header=\"true\"><fmt:message key=\"tag.attribute\"/></html:tableColumn>" + "<html:tableColumn header=\"true\"><fmt:message key=\"tag.required\"/></html:tableColumn>" + "<html:tableColumn header=\"true\"><fmt:message key=\"tag.type\"/></html:tableColumn>" + "<html:tableColumn header=\"true\"><fmt:message key=\"tag.description\"/></html:tableColumn>" + "</html:tableLine>"); for (Attribute attribute : tag.getAttributes()) { template.append("<html:tableLine>" + "<html:tableColumn>" + attribute.getName() + "</html:tableColumn>" + "<html:tableColumn>" + (attribute.getRequired() == null ? false : true) + "</html:tableColumn>" + "<html:tableColumn>" + attribute.getType() + "</html:tableColumn>" + "<html:tableColumn>" + attribute.getDescription() + "</html:tableColumn>" + "</html:tableLine>"); } template.append("</html:table>"); } template.append(" " + " </html:tab> " + " <html:tab label=\"{demo}\"> " + " " + tag.getExample() + " " + " </html:tab> " + " <html:tab label=\"{source}\"> " + " <html:code> " + " <html:view>" + tag.getExampleEscaped() + "</html:view> " + " </html:code> " + " </html:tab> " + " </html:tabPanel> " + " </html:panelBody> " + " </html:panel> " + " </html:view> "); FileUtils.writeStringToFile(new File( workspace + "/tagria-doc/src/main/webapp/WEB-INF/jsp/component/" + tag.getName() + ".jsp"), template.toString(), CHARSET); } for (List<Tag> values : groupments.values()) { Collections.sort(values, new Comparator<Tag>() { @Override public int compare(Tag o1, Tag o2) { return o1.getName().compareTo(o2.getName()); } }); } StringBuilder menu = new StringBuilder("<html:div cssClass=\"menu\"><html:listGroup>"); for (String key : new TreeSet<String>(groupments.keySet())) { menu.append("<html:listGroupItem><html:collapsable label=\"" + key + "\"><html:listGroup>"); for (Tag tag : groupments.get(key)) { menu.append("<html:listGroupItem><html:link label=\"" + StringUtils.capitalize(tag.getName()) + "\" target=\"conteudo\" url=\"/component/" + tag.getName() + "\"></html:link></html:listGroupItem>"); } menu.append("</html:listGroup></html:collapsable></html:listGroupItem>"); } menu.append("</html:listGroup></html:div>"); File home = new File(workspace + "/tagria-doc/src/main/webapp/WEB-INF/jsp/app/index.jsp"); FileUtils.writeStringToFile(home, FileUtils.readFileToString(home, CHARSET) .replaceAll("<html:div cssClass=\"menu\">[\\s\\S]*?</html:div>", menu.toString()), CHARSET); }
From source file:com.zenoss.zenpacks.zenjmx.ZenJmxMain.java
/** * @param args/* w w w .j av a2 s . co m*/ */ public static void main(String[] args) throws Exception { HashMap<String, Level> loggingLevel = new HashMap<String, Level>(); loggingLevel.put(ERROR, Level.ERROR); loggingLevel.put(WARNING, Level.WARN); loggingLevel.put(INFO, Level.INFO); loggingLevel.put(DEBUG, Level.DEBUG); Configuration config = Configuration.instance(); parseArguments(config, args); if (config.propertyExists(OptionsFactory.LOG_SEVERITY)) { String levelOpt = config.getProperty(OptionsFactory.LOG_SEVERITY); Level level = loggingLevel.get(levelOpt); if (level != null) { _logger.info("setting root logger to " + level); Logger.getRootLogger().setLevel(level); } else { _logger.warn("Ignoring unknown log severity " + levelOpt); } } String port = config.getProperty(OptionsFactory.LISTEN_PORT, OptionsFactory.DEFAULT_LISTENPORT); Server server = new Server(); Connector connector = new SocketConnector(); connector.setPort(Integer.parseInt(port)); server.setConnectors(new Connector[] { connector }); ServletHandler handler = new ServletHandler(); ServletHolder holder = new ServletHolder(new XmlRpcServlet()); handler.addServletWithMapping(holder, "/"); // handler.start(); handler.initialize(); server.setHandler(handler); try { server.start(); } catch (Exception e) { System.exit(10); } server.join(); }
From source file:akori.Impact.java
static public void main(String[] args) throws IOException { String PATH = "E:\\Trabajos\\AKORI\\datosmatrizgino\\"; String PATHIMG = "E:\\NetBeansProjects\\AKORI\\Proccess_1\\ImagesPages\\"; for (int i = 1; i <= 32; ++i) { for (int k = 1; k <= 15; ++k) { System.out.println("Matrix " + i + "-" + k); BufferedImage img = null; try { img = ImageIO.read(new File(PATHIMG + i + ".png")); } catch (IOException ex) { ex.getStackTrace();//from w ww . j av a 2 s . c o m } int ymax = img.getHeight(); int xmax = img.getWidth(); double[][] imagen = new double[ymax][xmax]; BufferedReader in = null; try { in = new BufferedReader(new FileReader(PATH + i + "-" + k + ".txt")); } catch (FileNotFoundException ex) { ex.getStackTrace(); } String linea; ArrayList<String> lista = new ArrayList<String>(); HashMap<String, String> lista1 = new HashMap<String, String>(); try { for (int j = 0; (linea = in.readLine()) != null; ++j) { String[] datos = linea.split(","); int x = (int) Double.parseDouble(datos[1]); int y = (int) Double.parseDouble(datos[2]); if (x >= xmax || y >= ymax || x <= 0 || y <= 0) { continue; } lista.add(x + "," + y); } } catch (Exception ex) { ex.getStackTrace(); } try { in.close(); } catch (IOException ex) { ex.getStackTrace(); } Iterator iter = lista.iterator(); int[][] matrix = new int[lista.size()][2]; for (int j = 0; iter.hasNext(); ++j) { String xy = (String) iter.next(); String[] datos = xy.split(","); matrix[j][0] = Integer.parseInt(datos[0]); matrix[j][1] = Integer.parseInt(datos[1]); } for (int j = 0; j < matrix.length; ++j) { int std = 50; int x = matrix[j][0]; int y = matrix[j][1]; imagen[y][x] += 1; double aux; normalMatrix(imagen, y, x, std); } FileWriter fw = new FileWriter(PATH + "Matrix" + i + "-" + k + ".txt"); BufferedWriter bw = new BufferedWriter(fw); for (int j = 0; j < imagen.length; ++j) { for (int t = 0; t < imagen[j].length; ++t) { if (t + 1 == imagen[j].length) bw.write(imagen[j][t] + ""); else bw.write(imagen[j][t] + ","); } bw.write("\n"); } bw.close(); } } }
From source file:Freq.java
public static void main(String[] args) { Map<String, Integer> m = new HashMap<String, Integer>(); // Initialize frequency table from command line for (String a : args) { Integer freq = m.get(a);//from w ww. ja v a 2 s. c o m m.put(a, (freq == null) ? 1 : freq + 1); } System.out.println(m.size() + " distinct words:"); System.out.println(m); }
From source file:io.parallec.sample.app.http.HttpDiffRequestsSameServerApp.java
public static void main(String[] args) { ParallelClient pc = new ParallelClient(); Map<String, Object> responseContext = new HashMap<String, Object>(); responseContext.put("temp", null); pc.prepareHttpGet("/userdata/sample_weather_$ZIP.txt") .setReplaceVarMapToSingleTargetSingleVar("ZIP", Arrays.asList("95037", "48824"), "www.parallec.io") .setResponseContext(responseContext).execute(new ParallecResponseHandler() { public void onCompleted(ResponseOnSingleTask res, Map<String, Object> responseContext) { String temp = new FilterRegex("(.*)").filter(res.getResponseContent()); System.out.println("\n!!Temperature: " + temp + " TargetHost: " + res.getHost()); responseContext.put("temp", temp); }//from ww w .ja v a 2 s. c om }); int tempGlobal = Integer.parseInt((String) responseContext.get("temp")); Asserts.check(tempGlobal <= 100 && tempGlobal >= 0, " Fail to extract output from sample weather API. Fail different request to same server test"); pc.releaseExternalResources(); }