List of usage examples for java.util HashMap containsKey
public boolean containsKey(Object key)
From source file:gr.cti.android.experimentation.service.ModelService.java
public String assignColor(HashMap<Integer, String> deviceColors, Integer deviceID) { String color = "http://maps.google.com/mapfiles/ms/icons/blue-dot.png"; if (deviceColors.containsKey(deviceID)) { color = deviceColors.get(deviceID); return color; }//w w w. j av a2 s .co m int numOfDev = deviceColors.keySet().size(); if (numOfDev % 6 == 0) color = "http://maps.google.com/mapfiles/ms/icons/blue-dot.png"; else if (numOfDev % 6 == 1) color = "http://maps.google.com/mapfiles/ms/icons/red-dot.png"; else if (numOfDev % 6 == 2) color = "http://maps.google.com/mapfiles/ms/icons/green-dot.png"; else if (numOfDev % 6 == 3) color = "http://maps.google.com/mapfiles/ms/icons/yellow-dot.png"; else if (numOfDev % 6 == 4) color = "http://maps.google.com/mapfiles/ms/icons/purple-dot.png"; else if (numOfDev % 6 == 5) color = "http://maps.google.com/mapfiles/ms/icons/pink-dot.png"; deviceColors.put(deviceID, color); return color; }
From source file:com.esri.geoevent.processor.serviceareacalculator.ServiceAreaCalculator.java
private String removeZFromGeom(String geomString) { geomString = new String(geomString); JsonFactory factory = new JsonFactory(); ObjectMapper mapper = new ObjectMapper(factory); JsonParser parser;/*from w ww .j a v a2 s .c om*/ try { parser = factory.createJsonParser(geomString.getBytes()); TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { }; HashMap<String, Object> o = mapper.readValue(parser, typeRef); if (o.containsKey("z")) { o.remove("z"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); mapper.writeValue(baos, o); geomString = baos.toString(); } } catch (Exception e) { throw new RuntimeException(LOGGER.translate("SERVICE_AREA_ERROR_REMOVING_Z", e.getMessage()), e); } return geomString; }
From source file:de.ingrid.portal.interfaces.impl.IBUSInterfaceImpl.java
private void injectCache(HashMap map) { if (!map.containsKey("cache")) { if (cache) { map.put("cache", "on"); } else {/*from w ww .j a va2s.co m*/ map.put("cache", "off"); } } }
From source file:com.griddynamics.jagger.engine.e1.reporting.WorkloadScalabilityPlotsReporter.java
private Collection<ScenarioPlotDTO> getScenarioPlots(List<WorkloadData> scenarios) { HashMap<String, ScenarioPlotDTO> throughputPlots = new HashMap<String, ScenarioPlotDTO>(); List<WorkloadTaskData> resultData; for (WorkloadData scenario : scenarios) { String scenarioName = scenario.getScenario().getName(); if (!throughputPlots.containsKey(scenarioName)) { resultData = getResultData(scenarioName); XYDataset latencyData = getLatencyData(resultData); XYDataset throughputData = getThroughputData(resultData); String clockForPlot = getClockForPlot(resultData); JFreeChart chartThroughput = ChartHelper.createXYChart(null, throughputData, clockForPlot, "Throughput (TPS)", 6, 3, ChartHelper.ColorTheme.LIGHT); JFreeChart chartLatency = ChartHelper.createXYChart(null, latencyData, clockForPlot, "Latency (sec)", 6, 3, ChartHelper.ColorTheme.LIGHT); ScenarioPlotDTO plotDTO = new ScenarioPlotDTO(); plotDTO.setScenarioName(scenarioName); plotDTO.setThroughputPlot(new JCommonDrawableRenderer(chartThroughput)); plotDTO.setLatencyPlot(new JCommonDrawableRenderer(chartLatency)); throughputPlots.put(scenarioName, plotDTO); resultData.clear();/*from www . j a v a2 s . com*/ } } return throughputPlots.values(); }
From source file:com.cz4031.SAXHandler.java
@Override public void endElement(String uri, String localName, String qName) throws SAXException { String tempValue = stringBuilder.toString(); String tempAccent = StringUtils.stripAccents(tempValue); String value = StringUtils.trimToEmpty(tempAccent); stringBuilder.setLength(0);/*from w w w . j av a2 s.c om*/ if (publication != null) { if (qName.equalsIgnoreCase("author")) { String authorName = value.toLowerCase(); AuthorList instance = AuthorList.getInstance(); HashMap<Author, Set<Integer>> authorList = instance.getAuthorList(); Author author = new Author(); author.setName(authorName); if (authorList.containsKey(author)) { Set<Integer> publicationList = authorList.get(author); publicationList.add(publication.getPubId()); } else { author.setId(++authorID); Set<Integer> publicationList = new HashSet<>(); publicationList.add(publication.getPubId()); authorList.put(author, publicationList); } } else if (qName.equalsIgnoreCase("article") || qName.equalsIgnoreCase("book") || qName.equalsIgnoreCase("incollection") || qName.equalsIgnoreCase("inproceedings")) { CSVWriter csvWriter = CSVWriter.getInstance(); csvWriter.writeToPublication(publication); publication = null; } else if (qName.equalsIgnoreCase("title")) { publication.setTitle(value); } else if (qName.equalsIgnoreCase("year")) { int year = Integer.parseInt(value); publication.setYear(year); } else if (qName.equalsIgnoreCase("journal")) { publication.setJournal(value); } else if (qName.equalsIgnoreCase("volume")) { publication.setVolume(value); } else if (qName.equalsIgnoreCase("number")) { publication.setNumber(value); } else if (qName.equalsIgnoreCase("publisher")) { publication.setPublisher(value); } else if (qName.equalsIgnoreCase("isbn")) { publication.setIsbn(value); } else if (qName.equalsIgnoreCase("booktitle")) { publication.setBooktitle(value); } else if (qName.equalsIgnoreCase("editor")) { publication.setEditor(value); } else if (qName.equalsIgnoreCase("pages")) { String pageStr = value; parsePages(pageStr); } } }
From source file:com.alibaba.jstorm.utils.JStormUtils.java
public static <V> HashMap<V, Integer> multi_set(List<V> list) { HashMap<V, Integer> rtn = new HashMap<V, Integer>(); for (V v : list) { int cnt = 1; if (rtn.containsKey(v)) { cnt += rtn.get(v);//from ww w. j a v a 2s . c o m } rtn.put(v, cnt); } return rtn; }
From source file:com.esri.geoevent.solutions.processor.eventjoiner.EventJoinerProcessor.java
public GeoEvent process(GeoEvent evt) throws Exception { try {/*from ww w. j av a 2 s. c o m*/ if (recordCache == null) recordCache = new HashMap<String, TrackRecord>(); String curDefName = evt.getGeoEventDefinition().getName(); if (!defList.contains(curDefName)) return null; String uid = evt.getField(joinfield).toString(); if (!recordCache.containsKey(uid)) { TrackRecord tr = new TrackRecord(); tr.setId(uid); HashMap<String, GeoEvent> joinEvents = new HashMap<String, GeoEvent>(); joinEvents.put(curDefName, evt); tr.records.add(joinEvents); recordCache.put(uid, tr); } else { TrackRecord tr = recordCache.get(uid); Boolean exitLoop = false; while (!exitLoop) { for (HashMap<String, GeoEvent> rec : tr.records) { if (!rec.containsKey(curDefName)) { rec.put(curDefName, evt); if (rec.size() == defList.size()) { if (createNewDef) { ConstructGeoEventDef(rec); createNewDef = false; } return CreateGeoEvent(rec); } exitLoop = true; } } exitLoop = true; } HashMap<String, GeoEvent> joinEvents = new HashMap<String, GeoEvent>(); joinEvents.put(curDefName, evt); tr.records.add(joinEvents); } return null; } catch (Exception e) { LOG.error(e.getMessage()); throw (e); } }
From source file:at.diamonddogs.net.WebClientDefaultHttpClient.java
private Map<String, List<String>> convertHeaders(Header[] headers) { HashMap<String, List<String>> ret = new HashMap<String, List<String>>(); for (Header h : headers) { String key = h.getName(); String value = h.getValue(); if (ret.containsKey(key)) { ret.get(key).add(value);//w w w . ja va2 s . c o m } else { List<String> values = new ArrayList<String>(10); values.add(value); ret.put(key, values); } } return ret; }
From source file:com.linuxbox.enkive.imap.mailbox.mongo.MongoEnkiveImapMailboxMapper.java
@Override public Mailbox<String> findMailboxByPath(MailboxPath mailboxName) throws MailboxException, MailboxNotFoundException { DBObject mailboxListObject = getMailboxList(); if (mailboxName.getName().equals(MailboxConstants.INBOX)) { MailboxPath inboxPath = new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), MailboxConstants.INBOX); return new EnkiveImapMailbox(inboxPath, 1); } else if (mailboxName.getName().equals("Trash")) { MailboxPath trashPath = new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), "Trash"); return new EnkiveImapMailbox(trashPath, 1); } else if (mailboxListObject != null) { @SuppressWarnings("unchecked") HashMap<String, String> mailboxTable = (HashMap<String, String>) mailboxListObject .get(MongoEnkiveImapConstants.MAILBOXES); String searchMailboxName = mailboxName.getName().replace(".", "/"); if (mailboxTable.containsKey(searchMailboxName)) { mailboxName.setName(searchMailboxName); EnkiveImapMailbox mailbox = new EnkiveImapMailbox(mailboxName, 1); mailbox.setMailboxId(mailboxTable.get(searchMailboxName)); return mailbox; }/*from w w w . ja va2 s . c o m*/ } return null; }
From source file:com.compomics.pride_asa_pipeline.core.logic.enzyme.EnzymePredictor.java
public LinkedHashMap<Enzyme, Integer> getEnzymeCounts(List<String> peptideSequences) { LOGGER.info("Counting enzyme occurences"); bestGuess = enzymeFactory.getEnzyme("Trypsin"); HashMap<Character, Integer> AAbeforeMap = new HashMap<>(); for (String sequence : peptideSequences) { char CharAAbeforeCleavage = sequence.charAt(sequence.length() - 1); int counter = 1; if (AAbeforeMap.containsKey(CharAAbeforeCleavage)) { counter = counter + (AAbeforeMap.get(CharAAbeforeCleavage)); }/* w ww . jav a2 s .c o m*/ AAbeforeMap.put(CharAAbeforeCleavage, counter); } LinkedHashMap<Enzyme, Integer> enzymeHits = new LinkedHashMap<>(); ArrayList<Enzyme> enzymes = enzymeFactory.getEnzymes(); int totalEnzymeCounter = 0; for (Enzyme anEnzyme : enzymes) { int enzymeCounter = 0; for (char AA : anEnzyme.getAminoAcidBefore()) { if (AAbeforeMap.get(AA) != null) { enzymeCounter = enzymeCounter + AAbeforeMap.get(AA); } } if (enzymeCounter != 0) { LOGGER.debug("Checking " + anEnzyme.getName() + " - " + enzymeCounter); enzymeHits.put(anEnzyme, enzymeCounter); } totalEnzymeCounter += enzymeCounter; } //Sort on occurences //Deal with special cases : //default if (enzymeHits.isEmpty()) { enzymeHits.put(enzymeFactory.getEnzyme("Trypsin"), 9999); } return enzymeHits; }