List of usage examples for java.util TreeMap remove
public V remove(Object key)
From source file:com.webcohesion.ofx4j.io.nanoxml.TestNanoXMLOFXReader.java
/** * tests whitespace before and after/*from w w w . java2 s .com*/ */ public void testWhitespaceBeforeAndAfter() throws Exception { NanoXMLOFXReader reader = new NanoXMLOFXReader(); final Map<String, List<String>> headers = new HashMap<String, List<String>>(); final Stack<Map<String, List<Object>>> aggregateStack = new Stack<Map<String, List<Object>>>(); TreeMap<String, List<Object>> root = new TreeMap<String, List<Object>>(); aggregateStack.push(root); reader.setContentHandler(getNewDefaultHandler(headers, aggregateStack)); reader.parse(TestNanoXMLOFXReader.class.getResourceAsStream("whitespace-example.ofx")); assertEquals(9, headers.size()); assertEquals(1, aggregateStack.size()); assertSame(root, aggregateStack.pop()); TreeMap<String, List<Object>> OFX = (TreeMap<String, List<Object>>) root.remove("OFX").get(0); assertNotNull(OFX); assertEquals("E", OFX.remove("S").get(0)); assertTrue(OFX.isEmpty()); assertTrue(root.isEmpty()); }
From source file:com.webcohesion.ofx4j.io.nanoxml.TestNanoXMLOFXReader.java
/** * tests using sax to parse an OFX doc./*from w w w. j a va2 s.c o m*/ */ public void testSimpleVersion1() throws Exception { NanoXMLOFXReader reader = new NanoXMLOFXReader(); final Map<String, List<String>> headers = new HashMap<String, List<String>>(); final Stack<Map<String, List<Object>>> aggregateStack = new Stack<Map<String, List<Object>>>(); TreeMap<String, List<Object>> root = new TreeMap<String, List<Object>>(); aggregateStack.push(root); reader.setContentHandler(getNewDefaultHandler(headers, aggregateStack)); reader.parse(TestNanoXMLOFXReader.class.getResourceAsStream("simple.ofx")); assertEquals(9, headers.size()); assertEquals(1, aggregateStack.size()); assertSame(root, aggregateStack.pop()); TreeMap<String, List<Object>> OFX = (TreeMap<String, List<Object>>) root.remove("OFX").get(0); assertNotNull(OFX); TreeMap<String, List<Object>> SIGNONMSGSRSV1 = (TreeMap<String, List<Object>>) OFX.remove("SIGNONMSGSRSV1") .get(0); assertNotNull(SIGNONMSGSRSV1); TreeMap<String, List<Object>> SONRS = (TreeMap<String, List<Object>>) SIGNONMSGSRSV1.remove("SONRS").get(0); assertNotNull(SONRS); TreeMap<String, List<Object>> STATUS = (TreeMap<String, List<Object>>) SONRS.remove("STATUS").get(0); assertNotNull(STATUS); assertEquals("0", STATUS.remove("CODE").get(0).toString().trim()); assertEquals("INFO", STATUS.remove("SEVERITY").get(0).toString().trim()); assertTrue(STATUS.isEmpty()); assertEquals("20071015021529.000[-8:PST]", SONRS.remove("DTSERVER").get(0).toString().trim()); assertEquals("ENG", SONRS.remove("LANGUAGE").get(0).toString().trim()); assertEquals("19900101000000", SONRS.remove("DTACCTUP").get(0).toString().trim()); assertTrue(SONRS.isEmpty()); assertTrue(SIGNONMSGSRSV1.isEmpty()); assertTrue(OFX.isEmpty()); assertTrue(root.isEmpty()); }
From source file:com.webcohesion.ofx4j.io.nanoxml.TestNanoXMLOFXReader.java
/** * tests for closing tags in v1// w w w .j a va 2 s.c om */ public void testClosingTagsVersion1() throws Exception { NanoXMLOFXReader reader = new NanoXMLOFXReader(); final Map<String, List<String>> headers = new HashMap<String, List<String>>(); final Stack<Map<String, List<Object>>> aggregateStack = new Stack<Map<String, List<Object>>>(); TreeMap<String, List<Object>> root = new TreeMap<String, List<Object>>(); aggregateStack.push(root); reader.setContentHandler(getNewDefaultHandler(headers, aggregateStack)); reader.parse(TestNanoXMLOFXReader.class.getResourceAsStream("closing-tags.ofx")); assertEquals(9, headers.size()); assertEquals(1, aggregateStack.size()); assertSame(root, aggregateStack.pop()); TreeMap<String, List<Object>> OFX = (TreeMap<String, List<Object>>) root.remove("OFX").get(0); assertNotNull(OFX); TreeMap<String, List<Object>> SIGNONMSGSRSV1 = (TreeMap<String, List<Object>>) OFX.remove("SIGNONMSGSRSV1") .get(0); assertNotNull(SIGNONMSGSRSV1); TreeMap<String, List<Object>> SONRS = (TreeMap<String, List<Object>>) SIGNONMSGSRSV1.remove("SONRS").get(0); assertNotNull(SONRS); TreeMap<String, List<Object>> STATUS = (TreeMap<String, List<Object>>) SONRS.remove("STATUS").get(0); assertNotNull(STATUS); TreeMap<String, List<Object>> FI = (TreeMap<String, List<Object>>) SONRS.remove("FI").get(0); assertNotNull(FI); assertEquals("0", STATUS.remove("CODE").get(0).toString().trim()); assertEquals("INFO", STATUS.remove("SEVERITY").get(0).toString().trim()); assertTrue(STATUS.isEmpty()); assertEquals("20100717152132", SONRS.remove("DTSERVER").get(0).toString().trim()); assertEquals("ENG", SONRS.remove("LANGUAGE").get(0).toString().trim()); assertEquals("ameritrade.com", FI.remove("ORG").get(0).toString().trim()); assertTrue(SONRS.isEmpty()); assertTrue(SIGNONMSGSRSV1.isEmpty()); assertTrue(OFX.isEmpty()); assertTrue(root.isEmpty()); }
From source file:com.sshtools.common.vomanagementtool.common.VOHelper.java
public static boolean removeVOFromFavourites(String voName) { boolean isRemoved = false; TreeMap allFavVOs = getVOGroup(FAVOURITES); Iterator<Map.Entry<String, TreeMap>> entries = allFavVOs.entrySet().iterator(); while (entries.hasNext()) { Map.Entry<String, TreeMap> entry = entries.next(); String vonameinMap = entry.getKey(); if (voName.equals(vonameinMap)) { //Check also if it is a self-VO, if yes, need to remove folders too TreeMap allEGIVOs = getVOGroup(EGI); TreeMap allOTHERSVO = getVOGroup(OTHERS); if (!allEGIVOs.containsKey(voName) && !allOTHERSVO.containsKey(voName)) { try { delete(new File(vomsdir + File.separator + voName)); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Cannot remove dirctory '" + vomsdir + File.separator + voName + "'.", "Error: Remove VO from " + FAVOURITES, JOptionPane.ERROR_MESSAGE); }//from w ww . jav a 2s .c o m } allFavVOs.remove(vonameinMap); isRemoved = true; break; } } if (isRemoved) { String newContent = createStringFromTreeMap(allFavVOs); try { writeToFile(favouritesFile, newContent); } catch (IOException e) { isRemoved = false; JOptionPane.showMessageDialog(null, "Failed to remove VO from Favourites. Cannot write to file '" + favouritesFile + "'", "Error: Remove VO", JOptionPane.ERROR_MESSAGE); } } return isRemoved; }
From source file:com.webcohesion.ofx4j.io.nanoxml.TestNanoXMLOFXReader.java
/** * tests using sax to parse an OFX doc.// ww w .j a v a2s . c o m */ public void testVersion1() throws Exception { NanoXMLOFXReader reader = new NanoXMLOFXReader(); final Map<String, List<String>> headers = new HashMap<String, List<String>>(); final Stack<Map<String, List<Object>>> aggregateStack = new Stack<Map<String, List<Object>>>(); TreeMap<String, List<Object>> root = new TreeMap<String, List<Object>>(); aggregateStack.push(root); reader.setContentHandler(getNewDefaultHandler(headers, aggregateStack)); reader.parse(TestNanoXMLOFXReader.class.getResourceAsStream("example-response.ofx")); assertEquals(9, headers.size()); assertEquals(1, aggregateStack.size()); assertSame(root, aggregateStack.pop()); TreeMap<String, List<Object>> OFX = (TreeMap<String, List<Object>>) root.remove("OFX").get(0); assertNotNull(OFX); TreeMap<String, List<Object>> SIGNONMSGSRSV1 = (TreeMap<String, List<Object>>) OFX.remove("SIGNONMSGSRSV1") .get(0); assertNotNull(SIGNONMSGSRSV1); TreeMap<String, List<Object>> SONRS = (TreeMap<String, List<Object>>) SIGNONMSGSRSV1.remove("SONRS").get(0); assertNotNull(SONRS); TreeMap<String, List<Object>> STATUS = (TreeMap<String, List<Object>>) SONRS.remove("STATUS").get(0); assertNotNull(STATUS); assertEquals("0", STATUS.remove("CODE").get(0).toString().trim()); assertEquals("INFO", STATUS.remove("SEVERITY").get(0).toString().trim()); assertTrue(STATUS.isEmpty()); assertEquals("20071015021529.000[-8:PST]", SONRS.remove("DTSERVER").get(0).toString().trim()); assertEquals("ENG", SONRS.remove("LANGUAGE").get(0).toString().trim()); assertEquals("19900101000000", SONRS.remove("DTACCTUP").get(0).toString().trim()); TreeMap<String, List<Object>> FI = (TreeMap<String, List<Object>>) SONRS.remove("FI").get(0); assertEquals("Bank&Cd", FI.remove("ORG").get(0).toString().trim()); assertEquals("01234", FI.remove("FID").get(0).toString().trim()); assertTrue(FI.isEmpty()); assertTrue(SONRS.isEmpty()); assertTrue(SIGNONMSGSRSV1.isEmpty()); TreeMap<String, List<Object>> BANKMSGSRSV1 = (TreeMap<String, List<Object>>) OFX.remove("BANKMSGSRSV1") .get(0); TreeMap<String, List<Object>> STMTTRNRS = (TreeMap<String, List<Object>>) BANKMSGSRSV1.remove("STMTTRNRS") .get(0); assertEquals("23382938", STMTTRNRS.remove("TRNUID").get(0).toString().trim()); STATUS = (TreeMap<String, List<Object>>) STMTTRNRS.remove("STATUS").get(0); assertNotNull(STATUS); assertEquals("0", STATUS.remove("CODE").get(0).toString().trim()); assertEquals("INFO", STATUS.remove("SEVERITY").get(0).toString().trim()); assertTrue(STATUS.isEmpty()); TreeMap<String, List<Object>> STMTRS = (TreeMap<String, List<Object>>) STMTTRNRS.remove("STMTRS").get(0); assertEquals("USD", STMTRS.remove("CURDEF").get(0).toString().trim()); TreeMap<String, List<Object>> BANKACCTFROM = (TreeMap<String, List<Object>>) STMTRS.remove("BANKACCTFROM") .get(0); assertEquals("SAVINGS", BANKACCTFROM.remove("ACCTTYPE").get(0).toString().trim()); assertEquals("098-121", BANKACCTFROM.remove("ACCTID").get(0).toString().trim()); assertEquals("987654321", BANKACCTFROM.remove("BANKID").get(0).toString().trim()); assertTrue(BANKACCTFROM.isEmpty()); TreeMap<String, List<Object>> BANKTRANLIST = (TreeMap<String, List<Object>>) STMTRS.remove("BANKTRANLIST") .get(0); assertEquals("20070101", BANKTRANLIST.remove("DTSTART").get(0).toString().trim()); assertEquals("20071015", BANKTRANLIST.remove("DTEND").get(0).toString().trim()); TreeMap<String, List<Object>> STMTTRN = (TreeMap<String, List<Object>>) BANKTRANLIST.remove("STMTTRN") .get(0); assertEquals("CREDIT", STMTTRN.remove("TRNTYPE").get(0).toString().trim()); assertEquals("20070329", STMTTRN.remove("DTPOSTED").get(0).toString().trim()); assertEquals("20070329", STMTTRN.remove("DTUSER").get(0).toString().trim()); assertEquals("150.00", STMTTRN.remove("TRNAMT").get(0).toString().trim()); assertEquals("980310001", STMTTRN.remove("FITID").get(0).toString().trim()); assertEquals("TRANSFER", STMTTRN.remove("NAME").get(0).toString().trim()); assertEquals("Transfer from checking &<> etc.", STMTTRN.remove("MEMO").get(0).toString().trim()); assertTrue(STMTTRN.isEmpty()); assertTrue(BANKTRANLIST.isEmpty()); TreeMap<String, List<Object>> LEDGERBAL = (TreeMap<String, List<Object>>) STMTRS.remove("LEDGERBAL").get(0); assertEquals("5250.00", LEDGERBAL.remove("BALAMT").get(0).toString().trim()); assertEquals("20071015021529.000[-8:PST]", LEDGERBAL.remove("DTASOF").get(0).toString().trim()); assertTrue(LEDGERBAL.isEmpty()); TreeMap<String, List<Object>> AVAILBAL = (TreeMap<String, List<Object>>) STMTRS.remove("AVAILBAL").get(0); assertEquals("5250.00", AVAILBAL.remove("BALAMT").get(0).toString().trim()); assertEquals("20071015021529.000[-8:PST]", AVAILBAL.remove("DTASOF").get(0).toString().trim()); assertTrue(AVAILBAL.isEmpty()); assertTrue(LEDGERBAL.isEmpty()); assertTrue(STMTRS.isEmpty()); assertTrue(STMTTRNRS.isEmpty()); assertTrue(BANKMSGSRSV1.isEmpty()); assertTrue(OFX.isEmpty()); assertTrue(root.isEmpty()); }
From source file:FastTreeMap.java
/** * Remove any mapping for this key, and return any previously * mapped value./* ww w . j av a 2s .c o m*/ * * @param key the key whose mapping is to be removed * @return the value removed, or null */ public Object remove(Object key) { if (fast) { synchronized (this) { TreeMap temp = (TreeMap) map.clone(); Object result = temp.remove(key); map = temp; return (result); } } else { synchronized (map) { return (map.remove(key)); } } }
From source file:nl.rivm.cib.episim.model.disease.infection.MSEIRSTest.java
public static Observable<Entry<Double, long[]>> stochasticSellke(final SIRConfig config, final double maxDt) { return Observable.create(sub -> { final double beta = config.reproduction() / config.recovery(); final long[] y = config.population(); final double[] T = config.t(); final double dt = Double.isFinite(maxDt) && maxDt > 0 ? maxDt : T[1]; final Long seed = config.seed(); final RandomGenerator rng = new MersenneTwister(seed == null ? System.currentTimeMillis() : seed); final ExponentialDistribution resistanceDist = new ExponentialDistribution(rng, 1), recoverDist = new ExponentialDistribution(rng, config.recovery()); // pending infections (mapping resistance -> amount) final TreeMap<Double, Integer> tInfect = IntStream.range(0, (int) y[0]) .mapToObj(i -> resistanceDist.sample()) .collect(Collectors.toMap(r -> r, r -> 1, Integer::sum, TreeMap::new)); // pending recoveries (mapping time -> amount) final TreeMap<Double, Integer> tRecover = new TreeMap<>(); double cumPres = 0; // Re-initialize infectives as susceptibles with zero resistance tInfect.put(cumPres, (int) y[1]); y[0] += y[1]; // I -> S y[1] -= y[1]; // I -> 0 for (double t = T[0]; t < T[1];) { publishCopy(sub, t, y);//from w w w . j ava 2 s . c o m final long localPopSize = y[0] + y[1] + y[2]; final Double ri = tInfect.isEmpty() ? null : tInfect.firstKey(), ti = ri == null ? null : // now + remaining resistance per relative pressure t + (ri - cumPres) / (beta * Math.max(y[1], 1) / localPopSize), tr = tRecover.isEmpty() ? null : tRecover.firstKey(); // time of next infection is earliest if (ti != null && (tr == null || ti < tr)) { final int ni = tInfect.remove(ri); cumPres = ri; // publish intermediate values for (double t1 = Math.min(ti, t + dt), tMax = Math.min(T[1], ti); t1 < tMax; t1 += dt) publishCopy(sub, t1, y); // infect t = ti; y[0] -= ni; // from S y[1] += ni; // to I // schedule S_t recoveries at t+Exp(1/gamma) for (int i = 0; i < ni; i++) tRecover.compute(t + recoverDist.sample(), (k, v) -> v == null ? 1 : v + 1); } // time of next recovery is earliest else if (tr != null) { final int nr = tRecover.remove(tr); if (ri != null) // advance cumulative pressure by dt * relative pressure cumPres += (tr - t) * beta * y[1] / localPopSize; // publish intermediate values for (double t1 = Math.min(tr, t + dt), tMax = Math.min(T[1], tr); t1 < tMax; t1 += dt) publishCopy(sub, t1, y); // recover t = tr; y[1] -= nr; // from I y[2] += nr; // to R } // no events remaining else { // publish intermediate values for (double t1 = t + dt; t1 < T[1]; t1 += dt) publishCopy(sub, t1, y); // time ends break; } } sub.onComplete(); }); }
From source file:com.serphacker.serposcope.db.google.GoogleSerpRescanDB.java
public void rescanNonBulk(Integer specificRunId, Collection<GoogleTarget> targets, Collection<GoogleSearch> searches, boolean updateSummary) { LOG.debug("SERP rescan (non-bulk) : starting"); long _start = System.currentTimeMillis(); Run specPrevRun = null;//from w w w .j ava 2 s. com Map<Integer, GoogleTargetSummary> specPrevRunSummaryByTarget = new HashMap<>(); if (specificRunId != null) { specPrevRun = runDB.findPrevious(specificRunId); if (specPrevRun != null) { specPrevRunSummaryByTarget = targetSummaryDB.list(specPrevRun.getId()).stream() .collect(Collectors.toMap(GoogleTargetSummary::getTargetId, Function.identity())); } } for (GoogleTarget target : targets) { Map<Integer, GoogleTargetSummary> summaryByRunId = new HashMap<>(); GoogleTargetSummary specificPreviousSummary = specPrevRunSummaryByTarget.get(target.getId()); if (specificPreviousSummary != null) { summaryByRunId.put(specPrevRun.getId(), specificPreviousSummary); } for (GoogleSearch search : searches) { final MutableInt previousRunId = new MutableInt(0); final MutableInt previousRank = new MutableInt(GoogleRank.UNRANKED); GoogleBest searchBest = new GoogleBest(target.getGroupId(), target.getId(), search.getId(), GoogleRank.UNRANKED, null, null); if (specPrevRun != null) { previousRunId.setValue(specPrevRun.getId()); previousRank.setValue( rankDB.get(specPrevRun.getId(), target.getGroupId(), target.getId(), search.getId())); GoogleBest specificBest = rankDB.getBest(target.getGroupId(), target.getId(), search.getId()); if (specificBest != null) { searchBest = specificBest; } } final GoogleBest best = searchBest; serpDB.stream(specificRunId, specificRunId, search.getId(), (GoogleSerp res) -> { int rank = GoogleRank.UNRANKED; String rankedUrl = null; for (int i = 0; i < res.getEntries().size(); i++) { if (target.match(res.getEntries().get(i).getUrl())) { rankedUrl = res.getEntries().get(i).getUrl(); rank = i + 1; break; } } // only update last run GoogleRank gRank = new GoogleRank(res.getRunId(), target.getGroupId(), target.getId(), search.getId(), rank, previousRank.shortValue(), rankedUrl); rankDB.insert(gRank); if (updateSummary) { GoogleTargetSummary summary = summaryByRunId.get(res.getRunId()); if (summary == null) { summaryByRunId.put(res.getRunId(), summary = new GoogleTargetSummary(target.getGroupId(), target.getId(), res.getRunId(), 0)); } summary.addRankCandidat(gRank); } if (rank != GoogleRank.UNRANKED && rank <= best.getRank()) { best.setRank((short) rank); best.setUrl(rankedUrl); best.setRunDay(res.getRunDay()); } previousRunId.setValue(res.getRunId()); previousRank.setValue(rank); }); if (best.getRank() != GoogleRank.UNRANKED) { rankDB.insertBest(best); } } // fill previous summary score if (updateSummary) { TreeMap<Integer, GoogleTargetSummary> summaries = new TreeMap<>(summaryByRunId); GoogleTargetSummary previousSummary = null; for (Map.Entry<Integer, GoogleTargetSummary> entry : summaries.entrySet()) { if (previousSummary != null) { entry.getValue().setPreviousScoreBP(previousSummary.getScoreBP()); } previousSummary = entry.getValue(); } if (specPrevRun != null) { summaries.remove(specPrevRun.getId()); } if (!summaries.isEmpty()) { targetSummaryDB.insert(summaries.values()); } } } LOG.debug("SERP rescan : done, duration = {}", DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - _start)); }
From source file:cc.slda.DisplayTopic.java
@SuppressWarnings("unchecked") public int run(String[] args) throws Exception { Options options = new Options(); options.addOption(Settings.HELP_OPTION, false, "print the help message"); options.addOption(OptionBuilder.withArgName(Settings.PATH_INDICATOR).hasArg() .withDescription("input beta file").create(Settings.INPUT_OPTION)); options.addOption(OptionBuilder.withArgName(Settings.PATH_INDICATOR).hasArg() .withDescription("term index file").create(ParseCorpus.INDEX)); options.addOption(OptionBuilder.withArgName(Settings.INTEGER_INDICATOR).hasArg() .withDescription("display top terms only (default - 10)").create(TOP_DISPLAY_OPTION)); String betaString = null;//from w ww .j a v a2 s .c o m String indexString = null; int topDisplay = TOP_DISPLAY; CommandLineParser parser = new GnuParser(); HelpFormatter formatter = new HelpFormatter(); try { CommandLine line = parser.parse(options, args); if (line.hasOption(Settings.HELP_OPTION)) { formatter.printHelp(ParseCorpus.class.getName(), options); System.exit(0); } if (line.hasOption(Settings.INPUT_OPTION)) { betaString = line.getOptionValue(Settings.INPUT_OPTION); } else { throw new ParseException("Parsing failed due to " + Settings.INPUT_OPTION + " not initialized..."); } if (line.hasOption(ParseCorpus.INDEX)) { indexString = line.getOptionValue(ParseCorpus.INDEX); } else { throw new ParseException("Parsing failed due to " + ParseCorpus.INDEX + " not initialized..."); } if (line.hasOption(TOP_DISPLAY_OPTION)) { topDisplay = Integer.parseInt(line.getOptionValue(TOP_DISPLAY_OPTION)); } } catch (ParseException pe) { System.err.println(pe.getMessage()); formatter.printHelp(ParseCorpus.class.getName(), options); System.exit(0); } catch (NumberFormatException nfe) { System.err.println(nfe.getMessage()); System.exit(0); } JobConf conf = new JobConf(DisplayTopic.class); FileSystem fs = FileSystem.get(conf); Path indexPath = new Path(indexString); Preconditions.checkArgument(fs.exists(indexPath) && fs.isFile(indexPath), "Invalid index path..."); Path betaPath = new Path(betaString); Preconditions.checkArgument(fs.exists(betaPath) && fs.isFile(betaPath), "Invalid beta path..."); SequenceFile.Reader sequenceFileReader = null; try { IntWritable intWritable = new IntWritable(); Text text = new Text(); Map<Integer, String> termIndex = new HashMap<Integer, String>(); sequenceFileReader = new SequenceFile.Reader(fs, indexPath, conf); while (sequenceFileReader.next(intWritable, text)) { termIndex.put(intWritable.get(), text.toString()); } PairOfIntFloat pairOfIntFloat = new PairOfIntFloat(); // HMapIFW hmap = new HMapIFW(); HMapIDW hmap = new HMapIDW(); TreeMap<Double, Integer> treeMap = new TreeMap<Double, Integer>(); sequenceFileReader = new SequenceFile.Reader(fs, betaPath, conf); while (sequenceFileReader.next(pairOfIntFloat, hmap)) { treeMap.clear(); System.out.println("=============================="); System.out.println( "Top ranked " + topDisplay + " terms for Topic " + pairOfIntFloat.getLeftElement()); System.out.println("=============================="); Iterator<Integer> itr1 = hmap.keySet().iterator(); int temp1 = 0; while (itr1.hasNext()) { temp1 = itr1.next(); treeMap.put(-hmap.get(temp1), temp1); if (treeMap.size() > topDisplay) { treeMap.remove(treeMap.lastKey()); } } Iterator<Double> itr2 = treeMap.keySet().iterator(); double temp2 = 0; while (itr2.hasNext()) { temp2 = itr2.next(); if (termIndex.containsKey(treeMap.get(temp2))) { System.out.println(termIndex.get(treeMap.get(temp2)) + "\t\t" + -temp2); } else { System.out.println("How embarrassing! Term index not found..."); } } } } finally { IOUtils.closeStream(sequenceFileReader); } return 0; }
From source file:com.eucalyptus.ws.handlers.WalrusAuthenticationHandler.java
private String getCanonicalizedAmzHeaders(MappingHttpRequest httpRequest) { String result = ""; Set<String> headerNames = httpRequest.getHeaderNames(); TreeMap amzHeaders = new TreeMap<String, String>(); for (String headerName : headerNames) { String headerNameString = headerName.toLowerCase().trim(); if (headerNameString.startsWith("x-amz-")) { String value = httpRequest.getHeader(headerName).trim(); String[] parts = value.split("\n"); value = ""; for (String part : parts) { part = part.trim();/*from w w w . j av a 2 s.c om*/ value += part + " "; } value = value.trim(); if (amzHeaders.containsKey(headerNameString)) { String oldValue = (String) amzHeaders.remove(headerNameString); oldValue += "," + value; amzHeaders.put(headerNameString, oldValue); } else { amzHeaders.put(headerNameString, value); } } } Iterator<String> iterator = amzHeaders.keySet().iterator(); while (iterator.hasNext()) { String key = iterator.next(); String value = (String) amzHeaders.get(key); result += key + ":" + value + "\n"; } return result; }