List of usage examples for java.util HashMap HashMap
public HashMap()
From source file:com.zimbra.cs.account.PreAuthKey.java
public static void main(String args[]) throws ServiceException { long now = System.currentTimeMillis(); HashMap<String, String> params = new HashMap<String, String>(); params.put("account", "user1"); params.put("by", "name"); params.put("timestamp", "1176399950434"); params.put("expires", "0"); String key = "9d8ad87fd726ba7d5fecf3d705621024b31cedb142310ec965f9263568fa0f27"; System.out.printf("key=%s preAuth=%s\n", key, computePreAuth(params, key)); }
From source file:com.hillert.botanic.MainApp.java
/** * Main class initializes the Spring Application Context and populates seed * data using {@link SeedDataService}./*w ww . j a v a2 s .c om*/ * * @param args Not used. */ public static void main(String[] args) { Map<String, Object> props = new HashMap<String, Object>(); props.put("redisPort", SocketUtils.findAvailableTcpPort()); SpringApplication app = new SpringApplication(MainApp.class); app.setDefaultProperties(props); ConfigurableApplicationContext context = app.run(args); MapPropertySource propertySource = new MapPropertySource("ports", props); context.getEnvironment().getPropertySources().addFirst(propertySource); SeedDataService seedDataService = context.getBean(SeedDataService.class); seedDataService.populateSeedData(); }
From source file:edu.cmu.lti.oaqa.annographix.apps.SolrSimpleIndexApp.java
public static void main(String[] args) { Options options = new Options(); options.addOption("i", null, true, "Input File"); options.addOption("u", null, true, "Solr URI"); options.addOption("n", null, true, "Batch size"); CommandLineParser parser = new org.apache.commons.cli.GnuParser(); try {// w w w . jav a 2s . c o m CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("i")) { inputFile = cmd.getOptionValue("i"); } else { Usage("Specify Input File"); } if (cmd.hasOption("u")) { solrURI = cmd.getOptionValue("u"); } else { Usage("Specify Solr URI"); } if (cmd.hasOption("n")) { batchQty = Integer.parseInt(cmd.getOptionValue("n")); } SolrServerWrapper solrServer = new SolrServerWrapper(solrURI); BufferedReader inpText = new BufferedReader( new InputStreamReader(CompressUtils.createInputStream(inputFile))); XmlHelper xmlHlp = new XmlHelper(); String docText = XmlHelper.readNextXMLIndexEntry(inpText); for (int docNum = 1; docText != null; ++docNum, docText = XmlHelper.readNextXMLIndexEntry(inpText)) { // 1. Read document text Map<String, String> docFields = null; HashMap<String, Object> objDocFields = new HashMap<String, Object>(); try { docFields = xmlHlp.parseXMLIndexEntry(docText); } catch (SAXException e) { System.err.println("Parsing error, offending DOC:" + NL + docText); throw new Exception("Parsing error."); } for (Map.Entry<String, String> e : docFields.entrySet()) { //System.out.println(e.getKey() + " " + e.getValue()); objDocFields.put(e.getKey(), e.getValue()); } solrServer.indexDocument(objDocFields); if ((docNum - 1) % batchQty == 0) solrServer.indexCommit(); } solrServer.indexCommit(); } catch (ParseException e) { Usage("Cannot parse arguments"); } catch (Exception e) { System.err.println("Terminating due to an exception: " + e); System.exit(1); } }
From source file:licenseUtil.LicenseUtil.java
public static void main(String[] args) throws IOException, IncompleteLicenseObjectException { if (args.length == 0) { logger.error("Missing parameters. Use --help to get a list of the possible options."); } else if (args[0].equals("--addPomToTsv")) { if (args.length < 4) logger.error(// w ww . j a va 2 s .co m "Missing arguments for option --addPomToTsv. Please specify <pomFileName> <licenses.stub.tsv> <currentVersion> or use the option --help for further information."); String pomFN = args[1]; String spreadSheetFN = args[2]; String currentVersion = args[3]; MavenProject project = null; try { project = Utils.readPom(new File(pomFN)); } catch (XmlPullParserException e) { logger.error("Could not parse pom file: \"" + pomFN + "\""); } LicensingList licensingList = new LicensingList(); File f = new File(spreadSheetFN); if (f.exists() && !f.isDirectory()) { licensingList.readFromSpreadsheet(spreadSheetFN); } licensingList.addMavenProject(project, currentVersion); licensingList.writeToSpreadsheet(spreadSheetFN); } else if (args[0].equals("--writeLicense3rdParty")) { if (args.length < 4) logger.error( "Missing arguments for option --writeLicense3rdParty. Please provide <licenses.enhanced.tsv> <processModule> <currentVersion> [and <targetDir>] or use the option --help for further information."); String spreadSheetFN = args[1]; String processModule = args[2]; String currentVersion = args[3]; HashMap<String, String> targetDirs = new HashMap<>(); if (args.length > 4) { File targetDir = new File(args[4]); logger.info("scan pom files in direct subdirectories of \"" + targetDir.getPath() + "\" to obtain target locations for 3rd party license files..."); File[] subdirs = targetDir.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY); for (File subdir : subdirs) { File pomFile = new File(subdir.getPath() + File.separator + POM_FN); if (!pomFile.exists()) continue; MavenProject mavenProject; try { mavenProject = Utils.readPom(pomFile); } catch (Exception e) { logger.warn("Could not read from pom file: \"" + pomFile.getPath() + "\" because of " + e.getMessage()); continue; } targetDirs.put(mavenProject.getModel().getArtifactId(), subdir.getAbsolutePath()); } } LicensingList licensingList = new LicensingList(); licensingList.readFromSpreadsheet(spreadSheetFN); if (processModule.toUpperCase().equals("ALL")) { for (String module : licensingList.getNonFixedHeaders()) { try { writeLicense3rdPartyFile(module, licensingList, currentVersion, targetDirs.get(module)); } catch (NoLicenseTemplateSetException e) { logger.error("Could not write file for module \"" + module + "\". There is no template specified for \"" + e.getLicensingObject() + "\". Please add an existing template filename to the column \"" + LicensingObject.ColumnHeader.LICENSE_TEMPLATE.value() + "\" of \"" + spreadSheetFN + "\"."); } } } else { try { writeLicense3rdPartyFile(processModule, licensingList, currentVersion, targetDirs.get(processModule)); } catch (NoLicenseTemplateSetException e) { logger.error("Could not write file for module \"" + processModule + "\". There is no template specified for \"" + e.getLicensingObject() + "\". Please add an existing template filename to the column \"" + LicensingObject.ColumnHeader.LICENSE_TEMPLATE.value() + "\" of \"" + spreadSheetFN + "\"."); } } } else if (args[0].equals("--buildEffectivePom")) { Utils.writeEffectivePom(new File(args[1]), (new File(EFFECTIVE_POM_FN)).getAbsolutePath()); } else if (args[0].equals("--updateTsvWithProjectsInFolder")) { if (args.length < 4) logger.error( "Missing arguments for option --processProjectsInFolder. Please provide <superDirectory> <licenses.stub.tsv> and <currentVersion> or use the option --help for further information."); File directory = new File(args[1]); String spreadSheetFN = args[2]; String currentVersion = args[3]; LicensingList licensingList = new LicensingList(); File f = new File(spreadSheetFN); if (f.exists() && !f.isDirectory()) { licensingList.readFromSpreadsheet(spreadSheetFN); } licensingList.addAll(processProjectsInFolder(directory, currentVersion, false)); licensingList.writeToSpreadsheet(spreadSheetFN); } else if (args[0].equals("--purgeTsv")) { if (args.length < 3) logger.error( "Missing arguments for option --purgeTsv. Please provide <spreadSheetIN.tsv>, <spreadSheetOUT.tsv> and <currentVersion> or use the option --help for further information."); String spreadSheetIN = args[1]; String spreadSheetOUT = args[2]; String currentVersion = args[3]; LicensingList licensingList = new LicensingList(); licensingList.readFromSpreadsheet(spreadSheetIN); licensingList.purge(currentVersion); licensingList.writeToSpreadsheet(spreadSheetOUT); } else if (args[0].equals("--help")) { InputStream in = LicenseUtil.class.getClassLoader().getResourceAsStream(README_PATH); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; while ((line = reader.readLine()) != null) { System.out.println(line); } } else { logger.error("Unknown parameter: " + args[0] + ". Use --help to get a list of the possible options."); } }
From source file:com.athena.dolly.web.aws.s3.S3Controller.java
public static void main(String[] args) throws Exception { //String [] keys = {"directory/", "directory/browse.png", "peacock.mp4", "temp/logo.png", "temp/subdir/", "temp/subdir/index.png"}; //String [] keys = {"directory/", "directory/browse.png"}; String[] keys = { "temp/logo.png", "temp/subdir/", "temp/subdir/index.png" }; Map<String, S3Dto> map = new HashMap<String, S3Dto>(); for (String key : keys) { //S3Dto dto = test(null, key); //S3Dto dto = test("directory", key); S3Dto dto = test("temp", key); if (dto != null) map.put(dto.getKey(), dto);/*from w w w .j a v a 2 s .com*/ } System.out.println(map); }
From source file:fr.inria.atlanmod.kyanos.benchmarks.MorsaTraverser.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input Kyanos resource directory"); inputOpt.setArgs(1);/*from www.j av a 2s. co m*/ inputOpt.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(inClassOpt); CommandLineParser parser = new PosixParser(); try { CommandLine commandLine = parser.parse(options, args); URI uri = URI.createURI("morsa://" + commandLine.getOptionValue(IN)); Class<?> inClazz = MorsaTraverser.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put("morsa", new MorsaResourceFactoryImpl(new MongoDBMorsaBackendFactory())); Resource resource = resourceSet.createResource(uri); Map<String, Object> loadOpts = new HashMap<String, Object>(); loadOpts.put(IMorsaResource.OPTION_SERVER_URI, "localhost"); loadOpts.put(IMorsaResource.OPTION_MAX_SAVE_CACHE_SIZE, 30000); loadOpts.put(IMorsaResource.OPTION_DEMAND_LOAD, false); // loadOpts.put(IMorsaResource.OPTION_CACHE_POLICY, FIFOEObjectCachePolicy.class.getName()); // loadOpts.put(IMorsaResource.OPTION_MAX_CACHE_SIZE, 30000); // loadOpts.put(IMorsaResource.OPTION_CACHE_FLUSH_FACTOR, 0.3f); // loadOpts.put(IMorsaResource.OPTION_DEMAND_LOAD_STRATEGY, IMorsaResource.OPTION_SINGLE_LOAD_STRATEGY); // loadOpts.put(IMorsaResource.OPTION_DEMAND_LOAD, true); resource.load(loadOpts); LOG.log(Level.INFO, "Start counting"); int count = 0; long begin = System.currentTimeMillis(); for (Iterator<EObject> iterator = resource.getAllContents(); iterator.hasNext(); iterator .next(), count++) ; long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End counting"); LOG.log(Level.INFO, MessageFormat.format("Resource {0} contains {1} elements", uri, count)); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } 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:de.citec.csra.elancsv.parser.SimpleParser.java
public static void main(String[] args) throws IOException, ParseException { Options opts = new Options(); opts.addOption("file", true, "Tab-separated ELAN export file to load."); opts.addOption("tier", true, "Tier to analyze. Optional: Append ::num to interpret annotations numerically."); opts.addOption("format", true, "How to read information from the file name. %V -> participant, %A -> annoatator, %C -> condition, e.g. \"%V - %A\""); opts.addOption("help", false, "Print this help and exit"); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(opts, args); if (cmd.hasOption("help")) { helpExit(opts, "where OPTION includes:"); }// w w w.j ava 2 s . c o m String infile = cmd.getOptionValue("file"); if (infile == null) { helpExit(opts, "Error: no file given."); } String format = cmd.getOptionValue("format"); if (format == null) { helpExit(opts, "Error: no format given."); } String tier = cmd.getOptionValue("tier"); if (tier == null) { helpExit(opts, "Error: no tier given."); } // TODO count values in annotations (e.g. search all robot occurrences) String[] tn = tier.split("::"); boolean numeric = false; if (tn.length == 2 && tn[1].equals("num")) { numeric = true; tier = tn[0]; } format = "^" + format + "$"; format = format.replaceFirst("%V", "(?<V>.*?)"); format = format.replaceFirst("%A", "(?<A>.*?)"); format = format.replaceFirst("%C", "(?<C>.*?)"); Pattern pa = Pattern.compile(format); Map<String, Participant> participants = new HashMap<>(); BufferedReader br = new BufferedReader(new FileReader(infile)); String line; int lineno = 0; while ((line = br.readLine()) != null) { String[] parts = line.split("\t"); lineno++; if (parts.length < 5) { System.err.println("WARNING: line '" + lineno + "' too short '" + line + "'"); continue; } Annotation a = new Annotation(Long.valueOf(parts[ElanFormat.START.field]), Long.valueOf(parts[ElanFormat.STOP.field]), Long.valueOf(parts[ElanFormat.DURATION.field]), parts[ElanFormat.VALUE.field]); String tname = parts[ElanFormat.TIER.field]; String file = parts[ElanFormat.FILE.field].replaceAll(".eaf", ""); Matcher m = pa.matcher(file); String vp = file; String condition = "?"; String annotator = "?"; String participantID = vp; if (m.find()) { vp = m.group("V"); if (format.indexOf("<A>") > 0) { annotator = m.group("A"); } if (format.indexOf("<C>") > 0) { condition = m.group("C"); } } participantID = vp + ";" + annotator; if (!participants.containsKey(participantID)) { participants.put(participantID, new Participant(vp, condition, annotator)); } Participant p = participants.get(participantID); if (!p.tiers.containsKey(tname)) { p.tiers.put(tname, new Tier(tname)); } p.tiers.get(tname).annotations.add(a); } Map<String, Map<String, Number>> values = new HashMap<>(); Set<String> rownames = new HashSet<>(); String allCountKey = "c: all values"; String allDurationKey = "d: all values"; String allMeanKey = "m: all values"; for (Map.Entry<String, Participant> e : participants.entrySet()) { // System.out.println(e); Tier t = e.getValue().tiers.get(tier); String participantID = e.getKey(); if (!values.containsKey(participantID)) { values.put(participantID, new HashMap<String, Number>()); } Map<String, Number> row = values.get(participantID); //participant id if (t != null) { row.put(allCountKey, 0l); row.put(allDurationKey, 0l); row.put(allMeanKey, 0l); for (Annotation a : t.annotations) { long countAll = (long) row.get(allCountKey) + 1; long durationAll = (long) row.get(allDurationKey) + a.duration; long meanAll = durationAll / countAll; row.put(allCountKey, countAll); row.put(allDurationKey, durationAll); row.put(allMeanKey, meanAll); if (!numeric) { String countKey = "c: " + a.value; String durationKey = "d: " + a.value; String meanKey = "m: " + a.value; if (!row.containsKey(countKey)) { row.put(countKey, 0l); } if (!row.containsKey(durationKey)) { row.put(durationKey, 0l); } if (!row.containsKey(meanKey)) { row.put(meanKey, 0d); } long count = (long) row.get(countKey) + 1; long duration = (long) row.get(durationKey) + a.duration; double mean = duration * 1.0 / count; row.put(countKey, count); row.put(durationKey, duration); row.put(meanKey, mean); rownames.add(countKey); rownames.add(durationKey); rownames.add(meanKey); } else { String countKey = "c: " + t.name; String sumKey = "s: " + t.name; String meanKey = "m: " + t.name; if (!row.containsKey(countKey)) { row.put(countKey, 0l); } if (!row.containsKey(sumKey)) { row.put(sumKey, 0d); } if (!row.containsKey(meanKey)) { row.put(meanKey, 0d); } double d = 0; try { d = Double.valueOf(a.value); } catch (NumberFormatException ex) { } long count = (long) row.get(countKey) + 1; double sum = (double) row.get(sumKey) + d; double mean = sum / count; row.put(countKey, count); row.put(sumKey, sum); row.put(meanKey, mean); rownames.add(countKey); rownames.add(sumKey); rownames.add(meanKey); } } } } ArrayList<String> list = new ArrayList(rownames); Collections.sort(list); StringBuilder header = new StringBuilder("ID;Annotator;"); header.append(allCountKey); header.append(";"); header.append(allDurationKey); header.append(";"); header.append(allMeanKey); header.append(";"); for (String l : list) { header.append(l); header.append(";"); } System.out.println(header); for (Map.Entry<String, Map<String, Number>> e : values.entrySet()) { StringBuilder row = new StringBuilder(e.getKey()); row.append(";"); if (e.getValue().containsKey(allCountKey)) { row.append(e.getValue().get(allCountKey)); } else { row.append("0"); } row.append(";"); if (e.getValue().containsKey(allDurationKey)) { row.append(e.getValue().get(allDurationKey)); } else { row.append("0"); } row.append(";"); if (e.getValue().containsKey(allMeanKey)) { row.append(e.getValue().get(allMeanKey)); } else { row.append("0"); } row.append(";"); for (String l : list) { if (e.getValue().containsKey(l)) { row.append(e.getValue().get(l)); } else { row.append("0"); } row.append(";"); } System.out.println(row); } }
From source file:ISMAGS.CommandLineInterface.java
public static void main(String[] args) throws IOException { String folder = null, files = null, motifspec = null, output = null; Options opts = new Options(); opts.addOption("folder", true, "Folder name"); opts.addOption("linkfiles", true, "Link files seperated by spaces (format: linktype[char] directed[d/u] filename)"); opts.addOption("motif", true, "Motif description by two strings (format: linktypes)"); opts.addOption("output", true, "Output file name"); CommandLineParser parser = new PosixParser(); try {// w ww .j av a2 s. c om CommandLine cmd = parser.parse(opts, args); if (cmd.hasOption("folder")) { folder = cmd.getOptionValue("folder"); } if (cmd.hasOption("linkfiles")) { files = cmd.getOptionValue("linkfiles"); } if (cmd.hasOption("motif")) { motifspec = cmd.getOptionValue("motif"); } if (cmd.hasOption("output")) { output = cmd.getOptionValue("output"); } } catch (ParseException e) { Die("Error: Parsing error"); } if (print) { printBanner(folder, files, motifspec, output); } if (folder == null || files == null || motifspec == null || output == null) { Die("Error: not all options are provided"); } else { ArrayList<String> linkfiles = new ArrayList<String>(); ArrayList<String> linkTypes = new ArrayList<String>(); ArrayList<String> sourcenetworks = new ArrayList<String>(); ArrayList<String> destinationnetworks = new ArrayList<String>(); ArrayList<Boolean> directed = new ArrayList<Boolean>(); StringTokenizer st = new StringTokenizer(files, " "); while (st.hasMoreTokens()) { linkTypes.add(st.nextToken()); directed.add(st.nextToken().equals("d")); sourcenetworks.add(st.nextToken()); destinationnetworks.add(st.nextToken()); linkfiles.add(folder + st.nextToken()); } ArrayList<LinkType> allLinkTypes = new ArrayList<LinkType>(); HashMap<Character, LinkType> typeTranslation = new HashMap<Character, LinkType>(); for (int i = 0; i < linkTypes.size(); i++) { String n = linkTypes.get(i); char nn = n.charAt(0); LinkType t = typeTranslation.get(nn); if (t == null) { t = new LinkType(directed.get(i), n, i, nn, sourcenetworks.get(i), destinationnetworks.get(i)); } allLinkTypes.add(t); typeTranslation.put(nn, t); } if (print) { System.out.println("Reading network.."); } Network network = Network.readNetworkFromFiles(linkfiles, allLinkTypes); Motif motif = getMotif(motifspec, typeTranslation); if (print) { System.out.println("Starting the search.."); } MotifFinder mf = new MotifFinder(network); long tijd = System.nanoTime(); Set<MotifInstance> motifs = mf.findMotif(motif, false); tijd = System.nanoTime() - tijd; if (print) { System.out.println("Completed search in " + tijd / 1000000 + " milliseconds"); } if (print) { System.out.println("Found " + motifs.size() + " instances of " + motifspec + " motif"); } if (print) { System.out.println("Writing instances to file: " + output); } printMotifs(motifs, output); if (print) { System.out.println("Done."); } // Set<MotifInstance> motifs=null; // MotifFinder mf=null; // System.out.println("Starting the search.."); // long tstart = System.nanoTime(); // for (int i = 0; i < it; i++) { // // mf = new MotifFinder(network, allLinkTypes, true); // motifs = mf.findMotif(motif); // } // // long tend = System.nanoTime(); // double time_in_ms = (tend - tstart) / 1000000.0; // System.out.println("Found " + mf.totalFound + " motifs, " + time_in_ms + " ms"); //// System.out.println("Evaluated " + mf.totalNrMappedNodes+ " search nodes"); //// System.out.println("Found " + motifs.size() + " motifs, " + time_in_ms + " ms"); // printMotifs(motifs, output); } }
From source file:GetAllConnectedWlanDevices.java
public static void main(String[] args) { //Create a new FritzConnection with username and password FritzConnection fc = new FritzConnection(ip, user, password); try {/*w w w . ja v a 2s .c o m*/ //The connection has to be initiated. This will load the tr64desc.xml respectively igddesc.xml //and all the defined Services and Actions. fc.init(); } catch (ClientProtocolException e2) { //Any HTTP related error. e2.printStackTrace(); } catch (IOException e2) { //Any Network related error. e2.printStackTrace(); } catch (JAXBException e2) { //Any xml violation. e2.printStackTrace(); } for (int i = 1; i <= 3; i++) { //Get the Service. In this case WLANConfiguration:X Service service = fc.getService("WLANConfiguration:" + i); //Get the Action. in this case GetTotalAssociations Action action = service.getAction("GetTotalAssociations"); Response response1 = null; try { //Execute the action without any In-Parameter. response1 = action.execute(); } catch (UnsupportedOperationException | IOException e1) { e1.printStackTrace(); } int deviceCount = -1; try { //Get the value from the field NewTotalAssociations as an integer. Values can have the Types: String, Integer, Boolean, DateTime and UUID deviceCount = response1.getValueAsInteger("NewTotalAssociations"); } catch (ClassCastException | NoSuchFieldException e) { e.printStackTrace(); } System.out.println("WLAN " + i + ":" + deviceCount); for (int j = 0; j < deviceCount; j++) { //Create a map for the arguments of an action. You have to do this, if the action has IN-Parameters. HashMap<String, Object> arguments = new HashMap<String, Object>(); //Set the argument NewAssociatedDeviceIndex to an integer value. arguments.put("NewAssociatedDeviceIndex", j); try { Response response2 = fc.getService("WLANConfiguration:" + i) .getAction("GetGenericAssociatedDeviceInfo").execute(arguments); System.out.println(" " + response2.getData()); } catch (UnsupportedOperationException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:com.amazon.advertising.api.sample.ItemLookupSample.java
public static void main(String[] args) { /*//from w w w .ja v a 2 s . c om * Set up the signed requests helper */ SignedRequestsHelper helper; try { helper = SignedRequestsHelper.getInstance(ENDPOINT, AWS_ACCESS_KEY_ID, AWS_SECRET_KEY); } catch (Exception e) { e.printStackTrace(); return; } String requestUrl = null; String title = null; /* The helper can sign requests in two forms - map form and string form */ /* * Here is an example in map form, where the request parameters are stored in a map. */ System.out.println("Map form example:"); Map<String, String> params = new HashMap<String, String>(); params.put("Service", "AWSECommerceService"); params.put("Version", "2011-08-01"); params.put("Operation", "ItemSearch"); params.put("SearchIndex", "Books"); params.put("Keywords", "Harry"); // params.put("ResponseGroup", "Small"); requestUrl = helper.sign(params); // System.out.println("Signed Request is \"" + requestUrl + "\""); // title = fetchTitle(requestUrl); // System.out.println("Signed Title is \"" + title + "\""); // System.out.println(); /* Here is an example with string form, where the requests parameters have already been concatenated * into a query string. */ // System.out.println("String form example:"); // String queryString = "Service=AWSECommerceService&Version=2009-03-31&Operation=ItemSearch&ResponseGroup=Small&SearchIndex=Books&keywords=harry" // + ITEM_ID; // requestUrl = helper.sign(queryString); NodeList nodelist = fetchASIN(requestUrl); System.out.println(nodelist.getLength()); for (int i = 0; i < nodelist.getLength(); i++) { String asin = nodelist.item(i).getTextContent(); println(asin); getItemInfo(asin, helper); break; } }