List of usage examples for java.util.concurrent ConcurrentMap get
V get(Object key);
From source file:com.phearom.um.model.MyMusicProvider.java
/** * Get the list of music tracks from a server and caches the track information * for future reference, keying tracks by musicId and grouping by genre. *///from w ww. ja v a 2 s. co m private void buildListsByGenre() { ConcurrentMap<String, List<MediaMetadataCompat>> newMusicListByGenre = new ConcurrentHashMap<>(); for (MutableMediaMetadata m : mMusicListById.values()) { String genre = m.metadata.getString(MediaMetadataCompat.METADATA_KEY_GENRE); List<MediaMetadataCompat> list = newMusicListByGenre.get(genre); if (list == null) { list = new ArrayList<>(); newMusicListByGenre.put(genre, list); } list.add(m.metadata); } mMusicListByGenre = newMusicListByGenre; }
From source file:com.phearom.um.model.MusicProvider.java
private void buildListsByGenre() { ConcurrentMap<String, List<MediaMetadataCompat>> newMusicListByGenre = new ConcurrentHashMap<>(); for (MutableMediaMetadata m : mMusicListById.values()) { String genre = m.metadata.getString(MediaMetadataCompat.METADATA_KEY_GENRE); List<MediaMetadataCompat> list = newMusicListByGenre.get(genre); if (list == null) { list = new ArrayList<>(); newMusicListByGenre.put(genre, list); }//from w w w. j a v a2s . c o m list.add(m.metadata); } mMusicListByGenre = newMusicListByGenre; }
From source file:org.jasig.portlet.proxy.mvc.portlet.proxy.ProxyPortletController.java
@ActionMapping public void proxyTarget(final @RequestParam("proxy.url") String url, final ActionRequest request, final ActionResponse response) throws IOException { final PortletPreferences preferences = request.getPreferences(); IContentResponse proxyResponse = null; try {/*from ww w . j av a2s . c om*/ // locate the content service to use to retrieve our HTML content final String contentServiceKey = preferences.getValue(CONTENT_SERVICE_KEY, null); final IContentService contentService = applicationContext.getBean(contentServiceKey, IContentService.class); final IContentRequest proxyRequest; try { proxyRequest = contentService.getRequest(request); } catch (RuntimeException e) { log.error("URL {} was not in the proxy list", url); // TODO: how should we handle these errors? return; } // retrieve the HTML content proxyResponse = contentService.getContent(proxyRequest, request); // TODO: this probably can only be an HTTP content type if (proxyResponse instanceof HttpContentResponseImpl) { // Determine the content type of the proxied response. If this is // not an HTML type, we need to construct a resource URL instead final HttpContentResponseImpl httpContentResponse = (HttpContentResponseImpl) proxyResponse; final String responseContentType = httpContentResponse.getHeaders().get("Content-Type"); for (Pattern contentType : knownHtmlContentTypes) { if (responseContentType != null && contentType.matcher(responseContentType).matches()) { final Map<String, String[]> params = request.getParameterMap(); response.setRenderParameters(params); return; } } } // if this is not an HTML content type, use the corresponding resource // URL in the session final PortletSession session = request.getPortletSession(); @SuppressWarnings("unchecked") final ConcurrentMap<String, String> rewrittenUrls = (ConcurrentMap<String, String>) session .getAttribute(URLRewritingFilter.REWRITTEN_URLS_KEY); response.sendRedirect(rewrittenUrls.get(url)); } finally { if (proxyResponse != null) { proxyResponse.close(); } } }
From source file:com.appdevper.mediaplayer.model.MusicProvider.java
private synchronized void buildListsByGenre() { ConcurrentMap<String, List<MediaMetadataCompat>> newMusicListByGenre = new ConcurrentHashMap<>(); for (MutableMediaMetadata m : mMusicListById.values()) { String genre = m.metadata.getString(MediaMetadataCompat.METADATA_KEY_GENRE); List<MediaMetadataCompat> list = newMusicListByGenre.get(genre); if (list == null) { list = new ArrayList<>(); newMusicListByGenre.put(genre, list); }//from ww w . j a v a2 s. c o m list.add(m.metadata); } mMusicListByGenre = newMusicListByGenre; }
From source file:com.classiqo.nativeandroid_32bitz.model.MusicProvider.java
private synchronized void buildListsByGenre() { ConcurrentMap<String, List<MediaMetadataCompat>> newMusicListByGenre = new ConcurrentHashMap<>(); for (MutableMediaMetadata m : mMusicListById.values()) { String genre = m.metadata.getString(MediaMetadataCompat.METADATA_KEY_GENRE); List<MediaMetadataCompat> list = newMusicListByGenre.get(genre); if (list == null) { list = new ArrayList<>(); newMusicListByGenre.put(genre, list); }// w w w .j a v a2 s. c om list.add(m.metadata); } mMusicListByGenre = newMusicListByGenre; }
From source file:com.chinaftw.music.model.MusicProvider.java
private synchronized void buildListsByGenre() { ConcurrentMap<String, List<MediaMetadata>> newMusicListByGenre = new ConcurrentHashMap<>(); for (MutableMediaMetadata m : mMusicListById.values()) { String genre = m.metadata.getString(MediaMetadata.METADATA_KEY_GENRE); List<MediaMetadata> list = newMusicListByGenre.get(genre); if (list == null) { list = new ArrayList<>(); newMusicListByGenre.put(genre, list); }//from www . j a v a2 s. co m list.add(m.metadata); } mMusicListByGenre = newMusicListByGenre; }
From source file:com.example.android.supportv4.media.model.MusicProvider.java
private synchronized void buildListsByGenre() { ConcurrentMap<String, List<MediaMetadataCompat>> newMusicListByGenre = new ConcurrentHashMap<>(); for (MutableMediaMetadata m : mMusicListById.values()) { String genre = m.metadata.getString(MediaMetadataCompat.METADATA_KEY_GENRE); List<MediaMetadataCompat> list = newMusicListByGenre.get(genre); if (list == null) { list = new ArrayList<>(); newMusicListByGenre.put(genre, list); }//from w w w.j a v a2 s. c o m list.add(m.metadata); } mMusicListByGenre = newMusicListByGenre; mMusicGenres = new ArrayList<>(mMusicListByGenre.keySet()); }
From source file:org.onebusaway.transit_data_federation.impl.service_alerts.ServiceAlertsServiceImpl.java
private <T> void getServiceAlertIdsForKey(ConcurrentMap<T, Set<AgencyAndId>> serviceAlertIdsByKey, T key, Collection<AgencyAndId> matches) { Set<AgencyAndId> ids = serviceAlertIdsByKey.get(key); if (ids != null) matches.addAll(ids);//from w w w.j av a 2 s . c o m }
From source file:playground.acmarmol.matsim2030.microcensus2010.MZPopulationUtils.java
public static void analyzeActivityTypesAndLengths(Population population) throws ExecutionException { LoadingCache<String, SummaryStatistics> activityDuration = CacheBuilder.newBuilder() .build(CacheLoader.from(new Supplier<SummaryStatistics>() { @Override//from w w w. j av a2 s . c o m public SummaryStatistics get() { return new SummaryStatistics(); } })); for (Person p : population.getPersons().values()) { if (p.getPlans().size() == 0) continue; Plan plan = p.getPlans().get(0); List<PlanElement> planElements = plan.getPlanElements(); for (PlanElement pe : planElements) { if (!(pe instanceof Activity)) continue; Activity activity = (Activity) pe; double startTime = activity.getStartTime(); double endTime = activity.getEndTime(); SummaryStatistics typeStats = activityDuration.get(activity.getType()); if (endTime != Time.UNDEFINED_TIME) { if (startTime == Time.UNDEFINED_TIME) startTime = 0; typeStats.addValue(endTime - startTime); } } } ConcurrentMap<String, SummaryStatistics> activityDurationMap = activityDuration.asMap(); { int i = 0; final StringBuffer s = new StringBuffer(); for (final String actType : activityDurationMap.keySet()) { final SummaryStatistics stats = activityDurationMap.get(actType); s.append(String.format("<param name=\"activityType_%d\" value=\"%s\" />\n", i, actType)); s.append(String.format("<param name=\"activityPriority_%d\" value=\"1\" />\n", i)); s.append(String.format("<param name=\"activityTypicalDuration_%d\" value=\"%s\" />\n", i, Time.writeTime(stats.getMean()))); s.append("\n"); i++; } log.info("All activities:\n" + s.toString()); } }
From source file:com.alibaba.dubbo.governance.service.impl.ProviderServiceImpl.java
public List<String> findApplicationsByServiceName(String service) { List<String> ret = new ArrayList<String>(); ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY); if (null == providerUrls) return ret; Map<Long, URL> value = providerUrls.get(service); if (value == null) { return ret; }//from www . j a v a 2 s. c om for (Map.Entry<Long, URL> e2 : value.entrySet()) { URL u = e2.getValue(); String app = u.getParameter(Constants.APPLICATION_KEY); if (app != null) ret.add(app); } return ret; }