List of usage examples for java.util SortedMap containsKey
boolean containsKey(Object key);
From source file:org.apache.felix.webconsole.internal.compendium.ConfigManager.java
private void listConfigurations(PrintWriter printWriter, ConfigurationAdmin inputConfigAdmin, String inputPidFilter, String localeInfo) { try {//from w ww . j a va 2 s. c o m // start with ManagedService instances SortedMap currOptionsPlain = getServices(ManagedService.class.getName(), inputPidFilter, localeInfo, true); // add in existing configuration (not duplicating ManagedServices) Configuration[] tempConfigsList = inputConfigAdmin.listConfigurations(inputPidFilter); for (int i = 0; tempConfigsList != null && i < tempConfigsList.length; i++) { // ignore configuration object if an entry already exists in the // map String tempPid = tempConfigsList[i].getPid(); if (currOptionsPlain.containsKey(tempPid)) { continue; } // insert and entry for the pid ObjectClassDefinition classDef = this.getObjectClassDefinition(tempConfigsList[i], localeInfo); String tempName; if (classDef != null) { tempName = classDef.getName() + " ("; tempName += tempPid + ")"; } else { tempName = tempPid; } if (classDef != null) { currOptionsPlain.put(tempPid, tempName); } } printOptionsForm(printWriter, currOptionsPlain, "configSelection_pid", "configure", "Configure"); } catch (Exception ex) { // write a message or ignore } }
From source file:org.mc4j.ems.impl.jmx.connection.DConnection.java
@SuppressWarnings({ "unchecked" }) public synchronized void loadSynchronous(boolean deep) { if (!connectionProvider.isConnected()) connectionProvider.connect();/*from w w w. jav a 2s . co m*/ log.info("Querying MBeanServer for all MBeans..."); MBeanServer mBeanServer = connectionProvider.getMBeanServer(); Set<ObjectName> objectNames = null; try { objectNames = (Set<ObjectName>) mBeanServer.queryNames(new ObjectName("*:*"), null); } catch (MalformedObjectNameException e) { /* Should never happen */ } SortedMap<ObjectName, DMBean> retrievedBeansMap = new TreeMap<ObjectName, DMBean>( new ObjectNameComparator()); if (!loaded) { log.info("Found " + objectNames.size() + " MBeans - starting load..."); } Set<DObjectName> currentKeys = new HashSet<DObjectName>(this.beanMap.keySet()); for (ObjectName objectName : objectNames) { // TODO: We're loading the beans on every run here i think... only load it if its not in the beanMap DMBean bean = mapBean(objectName, deep); retrievedBeansMap.put(objectName, bean); } Set<EmsBean> newBeans = new HashSet<EmsBean>(); Set<EmsBean> removedBeans = new HashSet<EmsBean>(); for (Map.Entry<ObjectName, DMBean> entry : retrievedBeansMap.entrySet()) { if (!currentKeys.contains(entry.getKey())) { newBeans.add(entry.getValue()); } } for (DObjectName name : currentKeys) { if (!retrievedBeansMap.containsKey(name.getObjectName())) { removedBeans.add(beanMap.remove(name)); } } if (loaded && log.isDebugEnabled()) { log.debug("Added " + newBeans.size() + " and removed " + removedBeans.size() + " since previous load."); } loaded = true; fireRegistrationEvent(newBeans, removedBeans); }
From source file:knowledgeMiner.mining.SentenceParserHeuristic.java
/** * Pairs the nouns and adjectives together to produce a number of result * text fragments to be resolved to concepts. * * @param parse/*from w w w . j a va 2s .c om*/ * The parse to process and pair. * @param anchors * The anchor map. * @param existingAnchorTrees * The anchor trees already added to the results (for reuse and * subtree-ing) * @return A collection of possible mappable entities composed of at least * one noun and possible adjectives (with sub-adjectives). */ private Collection<Tree<String>> pairNounAdjs(Parse parse, SortedMap<String, String> anchors, Map<String, Tree<String>> existingAnchorTrees) { Collection<Tree<String>> results = new ArrayList<>(); boolean createNewNounSet = false; ArrayList<String> nounPhrases = new ArrayList<>(); Parse[] children = parse.getChildren(); for (int i = children.length - 1; i >= 0; i--) { String childType = children[i].getType(); String childText = children[i].getCoveredText(); if (childType.startsWith("NN") || childType.equals("NP")) { // Note the noun, adding it to the front of the existing NP. if (createNewNounSet) nounPhrases.clear(); String existingNounPhrase = ""; if (!nounPhrases.isEmpty()) existingNounPhrase = nounPhrases.get(nounPhrases.size() - 1); String np = (childText + " " + existingNounPhrase).trim(); nounPhrases.add(np); // Add to the tree (if not a pure anchor) if (!anchors.containsKey(np)) results.add(new Tree<String>(reAnchorString(np, anchors))); } else if (childType.startsWith("JJ") || childType.equals("ADJP")) { // Only process if we have an NP if (!nounPhrases.isEmpty()) { // For every nounPhrase StringBuilder adjective = new StringBuilder(); for (int j = i; children[j].getType().startsWith("JJ") || children[j].getType().equals("ADJP"); j++) { // Build adjective combinations if (adjective.length() != 0) adjective.append(" "); adjective.append(children[j].getCoveredText()); for (String np : nounPhrases) { // Create the tree (with sub adjective tree) String adjNP = adjective + " " + np; Tree<String> adjP = null; // Check for an existing anchor tree if (existingAnchorTrees.containsKey(adjNP)) adjP = existingAnchorTrees.get(adjNP); else adjP = new Tree<String>(reAnchorString(adjNP, anchors)); if (!anchors.containsKey(adjective.toString())) adjP.addSubValue(reAnchorString(adjective.toString(), anchors)); // Add to the tree results.add(adjP); } } } createNewNounSet = true; } else { createNewNounSet = true; } } return results; }
From source file:org.jasig.schedassist.web.VisibleScheduleTag.java
@Override public int doStartTagInternal() { final ServletContext servletContext = pageContext.getServletContext(); final Date scheduleStart = visibleSchedule.getScheduleStart(); if (null == scheduleStart) { // the visibleSchedule is empty, short circuit try {/*from w w w .j a va 2 s. c o m*/ StringBuilder noappointments = new StringBuilder(); noappointments.append("<span class=\"none-available\">"); noappointments.append(getMessageSource().getMessage("no.available.appointments", null, null)); noappointments.append("</span>"); pageContext.getOut().write(noappointments.toString()); } catch (IOException e) { LOG.error("IOException occurred in doStartTag", e); } // SKIP_BODY means don't print any content from body of tag return SKIP_BODY; } LOG.debug("scheduleStart: " + scheduleStart); SortedMap<Date, List<AvailableBlock>> dailySchedules = new TreeMap<Date, List<AvailableBlock>>(); Date index = DateUtils.truncate(scheduleStart, java.util.Calendar.DATE); Date scheduleEnd = visibleSchedule.getScheduleEnd(); while (index.before(scheduleEnd)) { dailySchedules.put(index, new ArrayList<AvailableBlock>()); index = DateUtils.addDays(index, 1); } final Date lastMapKey = dailySchedules.lastKey(); LOG.debug("visibleSchedule spans " + dailySchedules.keySet().size() + " days"); try { SortedMap<AvailableBlock, AvailableStatus> scheduleBlockMap = visibleSchedule.getBlockMap(); int numberOfEventsToDisplay = 0; for (AvailableBlock block : scheduleBlockMap.keySet()) { Date eventStartDate = block.getStartTime(); LOG.debug("event start date: " + eventStartDate); Date mapKey = DateUtils.truncate(eventStartDate, java.util.Calendar.DATE); if (CommonDateOperations.equalsOrAfter(eventStartDate, scheduleStart) && dailySchedules.containsKey(mapKey)) { dailySchedules.get(mapKey).add(block); numberOfEventsToDisplay++; } } LOG.debug("number of events to display: " + numberOfEventsToDisplay); if (numberOfEventsToDisplay == 0) { // no available times in this range! StringBuilder noappointments = new StringBuilder(); noappointments.append("<span class=\"none-available\">"); noappointments.append(getMessageSource().getMessage("no.available.appointments", null, null)); noappointments.append("</span>"); pageContext.getOut().write(noappointments.toString()); } else { int weekNumber = 1; Date currentWeekStart = DateUtils.truncate(scheduleStart, java.util.Calendar.DATE); Date currentWeekFinish = DateUtils.addDays(currentWeekStart, CommonDateOperations.numberOfDaysUntilSunday(currentWeekStart)); currentWeekFinish = DateUtils.addMinutes(currentWeekFinish, -1); boolean renderAnotherWeek = true; while (renderAnotherWeek) { if (LOG.isDebugEnabled()) { LOG.debug("will render another week using currentWeekStart " + currentWeekStart + " and currentWeekFinish " + currentWeekFinish); } SortedMap<Date, List<AvailableBlock>> subMap = dailySchedules.subMap(currentWeekStart, currentWeekFinish); renderWeek(servletContext, pageContext.getOut(), weekNumber++, subMap, scheduleBlockMap); currentWeekStart = DateUtils.addMinutes(currentWeekFinish, 1); currentWeekFinish = DateUtils.addDays(currentWeekStart, 7); currentWeekFinish = DateUtils.addMinutes(currentWeekFinish, -1); if (LOG.isDebugEnabled()) { LOG.debug("recalculated currentWeekStart " + currentWeekStart + ", currentWeekFinish " + currentWeekFinish); } if (currentWeekStart.after(lastMapKey)) { renderAnotherWeek = false; LOG.debug("will not render another week"); } } } } catch (IOException e) { LOG.error("IOException occurred in doStartTag", e); } // SKIP_BODY means don't print any content from body of tag return SKIP_BODY; }
From source file:com.googlecode.fascinator.common.StorageDataUtil.java
/** * Getlist method to get the values of key from the sourceMap * * @param sourceMap Map container//w w w.j a v a 2 s . c o m * @param baseKey field to search * @return list of value based on baseKey */ public Map<String, Object> getList(JsonSimple json, String baseKey) { SortedMap<String, Object> valueMap = new TreeMap<String, Object>(); Map<String, Object> data; if (baseKey == null) { log.error("NULL baseKey provided!"); return valueMap; } if (!baseKey.endsWith(".")) { baseKey = baseKey + "."; } if (json == null) { log.error("NULL JSON object provided!"); return valueMap; } // Look through the top level nodes for (Object oKey : json.getJsonObject().keySet()) { // If the key matches String key = (String) oKey; if (key.startsWith(baseKey)) { // Find our data String value = json.getString(null, key); String field = baseKey; if (key.length() >= baseKey.length()) { field = key.substring(baseKey.length(), key.length()); } String index = field; if (field.indexOf(".") > 0) { index = field.substring(0, field.indexOf(".")); } if (valueMap.containsKey(index)) { data = (Map<String, Object>) valueMap.get(index); } else { data = new LinkedHashMap<String, Object>(); valueMap.put(index, data); } if (value.length() == 1) { value = String.valueOf(value.charAt(0)); } data.put(field.substring(field.indexOf(".") + 1, field.length()), value); } } // log.info("{}: {}", baseKey, valueMap); return valueMap; }
From source file:org.jasig.schedassist.portlet.VisibleScheduleTag.java
@Override public int doStartTagInternal() { RenderRequest renderRequest = (RenderRequest) pageContext.getRequest().getAttribute(PORTLET_REQUEST); RenderResponse renderResponse = (RenderResponse) pageContext.getRequest().getAttribute(PORTLET_RESPONSE); final Date scheduleStart = visibleSchedule.getScheduleStart(); if (null == scheduleStart) { // the visibleSchedule is empty, short circuit try {/* ww w . j a v a 2 s.c o m*/ StringBuilder noappointments = new StringBuilder(); noappointments.append("<span class=\"none-available\">"); noappointments.append(getMessageSource().getMessage("no.available.appointments", null, null)); noappointments.append("</span>"); pageContext.getOut().write(noappointments.toString()); } catch (IOException e) { LOG.error("IOException occurred in doStartTag", e); } // SKIP_BODY means don't print any content from body of tag return SKIP_BODY; } LOG.debug("scheduleStart: " + scheduleStart); SortedMap<Date, List<AvailableBlock>> dailySchedules = new TreeMap<Date, List<AvailableBlock>>(); Date index = DateUtils.truncate(scheduleStart, java.util.Calendar.DATE); Date scheduleEnd = visibleSchedule.getScheduleEnd(); while (index.before(scheduleEnd)) { dailySchedules.put(index, new ArrayList<AvailableBlock>()); index = DateUtils.addDays(index, 1); } final Date lastMapKey = dailySchedules.lastKey(); LOG.debug("visibleSchedule spans " + dailySchedules.keySet().size() + " days"); try { SortedMap<AvailableBlock, AvailableStatus> scheduleBlockMap = visibleSchedule.getBlockMap(); int numberOfEventsToDisplay = 0; for (AvailableBlock block : scheduleBlockMap.keySet()) { Date eventStartDate = block.getStartTime(); LOG.debug("event start date: " + eventStartDate); Date mapKey = DateUtils.truncate(eventStartDate, java.util.Calendar.DATE); if (CommonDateOperations.equalsOrAfter(eventStartDate, scheduleStart) && dailySchedules.containsKey(mapKey)) { dailySchedules.get(mapKey).add(block); numberOfEventsToDisplay++; } } LOG.debug("number of events to display: " + numberOfEventsToDisplay); if (numberOfEventsToDisplay == 0) { // no available times in this range! StringBuilder noappointments = new StringBuilder(); noappointments.append("<span class=\"none-available\">"); noappointments.append(getMessageSource().getMessage("no.available.appointments", null, null)); noappointments.append("</span>"); pageContext.getOut().write(noappointments.toString()); } else { int weekNumber = 1; Date currentWeekStart = DateUtils.truncate(scheduleStart, java.util.Calendar.DATE); Date currentWeekFinish = DateUtils.addDays(currentWeekStart, CommonDateOperations.numberOfDaysUntilSunday(currentWeekStart)); currentWeekFinish = DateUtils.addMinutes(currentWeekFinish, -1); boolean renderAnotherWeek = true; while (renderAnotherWeek) { if (LOG.isDebugEnabled()) { LOG.debug("will render another week using currentWeekStart " + currentWeekStart + " and currentWeekFinish " + currentWeekFinish); } SortedMap<Date, List<AvailableBlock>> subMap = dailySchedules.subMap(currentWeekStart, currentWeekFinish); renderWeek(pageContext.getOut(), weekNumber++, subMap, scheduleBlockMap, renderRequest, renderResponse); currentWeekStart = DateUtils.addMinutes(currentWeekFinish, 1); currentWeekFinish = DateUtils.addDays(currentWeekStart, 7); currentWeekFinish = DateUtils.addMinutes(currentWeekFinish, -1); if (LOG.isDebugEnabled()) { LOG.debug("recalculated currentWeekStart " + currentWeekStart + ", currentWeekFinish " + currentWeekFinish); } if (currentWeekStart.after(lastMapKey)) { renderAnotherWeek = false; LOG.debug("will not render another week"); } } } } catch (IOException e) { LOG.error("IOException occurred in doStartTag", e); } // SKIP_BODY means don't print any content from body of tag return SKIP_BODY; }
From source file:tajo.master.GlobalPlanner.java
private Collection<List<Fragment>> hashFragments(List<Fragment> frags) { SortedMap<String, List<Fragment>> hashed = new TreeMap<String, List<Fragment>>(); for (Fragment f : frags) { if (hashed.containsKey(f.getPath().getName())) { hashed.get(f.getPath().getName()).add(f); } else {//from w w w .j av a 2 s .c om List<Fragment> list = new ArrayList<Fragment>(); list.add(f); hashed.put(f.getPath().getName(), list); } } return hashed.values(); }
From source file:tajo.master.GlobalPlanner.java
private Map<TupleRange, Set<URI>> rangeFetches(Schema schema, List<URI> uriList) throws UnsupportedEncodingException { SortedMap<TupleRange, Set<URI>> map = Maps.newTreeMap(); TupleRange range;/*from w w w . jav a 2 s . c o m*/ Set<URI> uris; for (URI uri : uriList) { range = TupleUtil.queryToRange(schema, uri.getQuery()); // URI.getQuery() returns a url-decoded query string. if (map.containsKey(range)) { uris = map.get(range); uris.add(uri); } else { uris = Sets.newHashSet(); uris.add(uri); map.put(range, uris); } } return map; }
From source file:org.ambraproject.service.search.SolrSearchService.java
@SuppressWarnings("unchecked") private SearchResultSinglePage readQueryResults(QueryResponse queryResponse, SolrQuery query) { SolrDocumentList documentList = queryResponse.getResults(); if (log.isInfoEnabled()) { StringBuilder filterQueriesForLog = new StringBuilder(); if (query.getFilterQueries() != null && query.getFilterQueries().length > 0) { for (String filterQuery : query.getFilterQueries()) { filterQueriesForLog.append(filterQuery).append(" , "); }/* ww w. ja va 2s .c om*/ if (filterQueriesForLog.length() > 3) { filterQueriesForLog.replace(filterQueriesForLog.length() - 3, filterQueriesForLog.length(), ""); } else { filterQueriesForLog.append("No Filter Queries"); } } log.info("query.getQuery():{ " + query.getQuery() + " }" + ", query.getSortFields():{ " + (query.getSortFields() == null ? null : Arrays.asList(query.getSortFields())) + " }" + ", query.getFilterQueries():{ " + filterQueriesForLog.toString() + " }" + ", found:" + documentList.getNumFound() + ", start:" + documentList.getStart() + ", max_score:" + documentList.getMaxScore() + ", QTime:" + queryResponse.getQTime() + "ms"); // TODO: implement spell-checking in a meaningful manner. This loop exists only to generate log output. // TODO: Add "spellcheckAlternatives" or something like it to the SearchHits class so it can be displayed to the user like Google's "did you mean..." // TODO: Turn off spellchecking for the "author" field. if (queryResponse.getSpellCheckResponse() != null && queryResponse.getSpellCheckResponse().getSuggestionMap() != null && queryResponse.getSpellCheckResponse().getSuggestionMap().keySet().size() > 0) { StringBuilder sb = new StringBuilder("Spellcheck alternative suggestions:"); for (String token : queryResponse.getSpellCheckResponse().getSuggestionMap().keySet()) { sb.append(" { ").append(token).append(" : "); if (queryResponse.getSpellCheckResponse().getSuggestionMap().get(token).getAlternatives() .size() < 1) { sb.append("NO ALTERNATIVES"); } else { for (String alternative : queryResponse.getSpellCheckResponse().getSuggestionMap() .get(token).getAlternatives()) { sb.append(alternative).append(", "); } sb.replace(sb.length() - 2, sb.length(), ""); // Remove last comma and space. } sb.append(" } ,"); } log.info(sb.replace(sb.length() - 2, sb.length(), "").toString()); // Remove last comma and space. } else { log.info("Solr thinks everything in the query is spelled correctly."); } } List<SearchHit> searchResults = new ArrayList<SearchHit>(); for (SolrDocument document : documentList) { String id = SolrServiceUtil.getFieldValue(document, "id", String.class, query.toString()); String message = id == null ? query.toString() : id; Float score = SolrServiceUtil.getFieldValue(document, "score", Float.class, message); String title = SolrServiceUtil.getFieldValue(document, "title_display", String.class, message); Date publicationDate = SolrServiceUtil.getFieldValue(document, "publication_date", Date.class, message); String eissn = SolrServiceUtil.getFieldValue(document, "eissn", String.class, message); String journal = SolrServiceUtil.getFieldValue(document, "journal", String.class, message); String articleType = SolrServiceUtil.getFieldValue(document, "article_type", String.class, message); String strikingImage = SolrServiceUtil.getFieldValue(document, "striking_image", String.class, message); List<String> abstractText = SolrServiceUtil.getFieldMultiValue(document, "abstract", String.class, message); List<String> abstractPrimary = SolrServiceUtil.getFieldMultiValue(document, "abstract_primary_display", String.class, message); List<String> authorList = SolrServiceUtil.getFieldMultiValue(document, "author_display", String.class, message); // TODO create a dedicated field for checking the existence of assets for a given article. List<String> figureTableCaptions = SolrServiceUtil.getFieldMultiValue(document, "figure_table_caption", String.class, message); List<String> subjects = SolrServiceUtil.getFieldMultiValue(document, "subject", String.class, message); List<String> expressionOfconcern = SolrServiceUtil.getFieldMultiValue(document, "expression_of_concern", String.class, message); String retraction = SolrServiceUtil.getFieldValue(document, "retraction", String.class, message); String abstractResult = ""; //Use the primary abstract if it exists if (abstractPrimary.size() > 0) { abstractResult = StringUtils.join(abstractPrimary, ", "); } else { if (abstractText.size() > 0) { abstractResult = StringUtils.join(abstractText, ", "); } } //Flatten the list of subjects to a unique set Set<String> flattenedSubjects = new HashSet<String>(); for (String subject : subjects) { for (String temp : subject.split("/")) { if (temp.trim().length() > 0) { flattenedSubjects.add(temp); } } } SearchHit hit = SearchHit.builder().setHitScore(score).setUri(id).setTitle(title) .setListOfCreators(authorList).setDate(publicationDate).setIssn(eissn).setJournalTitle(journal) .setArticleTypeForDisplay(articleType).setAbstractText(abstractResult) .setStrikingImage(strikingImage).setHasAssets(figureTableCaptions.size() > 0) .setSubjects(flattenedSubjects).setSubjectsPolyhierarchy(subjects) .setExpressionOfConcern(expressionOfconcern).setRetraction(retraction).build(); if (log.isDebugEnabled()) log.debug(hit.toString()); searchResults.add(hit); } //here we assume that number of hits is always going to be withing range of int SearchResultSinglePage results = new SearchResultSinglePage((int) documentList.getNumFound(), -1, searchResults, query.getQuery()); if (queryResponse.getFacetField("subject_facet") != null) { List<Map> subjects = facetCountsToHashMap(queryResponse.getFacetField("subject_facet")); if (subjects != null) { List<Map> subjectResult = new ArrayList<Map>(); SortedMap<String, Long> topSubjects = null; try { topSubjects = getTopSubjects(); } catch (ApplicationException ex) { throw new RuntimeException(ex.getMessage(), ex); } //Remove top level 1 subjects from list, FEND-805 for (Map<String, Object> m : subjects) { if (!topSubjects.containsKey(m.get("name"))) { HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put("name", m.get("name")); hm.put("count", m.get("count")); subjectResult.add(hm); } } results.setSubjectFacet(subjectResult); } else { results.setSubjectFacet(null); } } if (queryResponse.getFacetField("author_facet") != null) { results.setAuthorFacet(facetCountsToHashMap(queryResponse.getFacetField("author_facet"))); } if (queryResponse.getFacetField("editor_facet") != null) { results.setEditorFacet(facetCountsToHashMap(queryResponse.getFacetField("editor_facet"))); } if (queryResponse.getFacetField("article_type_facet") != null) { results.setArticleTypeFacet(facetCountsToHashMap(queryResponse.getFacetField("article_type_facet"))); } if (queryResponse.getFacetField("affiliate_facet") != null) { results.setInstitutionFacet(facetCountsToHashMap(queryResponse.getFacetField("affiliate_facet"))); } if (queryResponse.getFacetField("cross_published_journal_key") != null) { results.setJournalFacet( facetCountsToHashMap(queryResponse.getFacetField("cross_published_journal_key"))); } return results; }
From source file:org.opennaas.extensions.genericnetwork.capability.circuitstatistics.CircuitStatisticsCapability.java
private SortedMap<Long, List<CircuitStatistics>> parseCSV(String csvStatistics) throws IllegalArgumentException, IOException { CSVReader reader = new CSVReader(new StringReader(csvStatistics)); try {/*w ww. j ava2s . co m*/ SortedMap<Long, List<CircuitStatistics>> circuitsStatistics = new TreeMap<Long, List<CircuitStatistics>>(); List<String[]> records = reader.readAll(); log.debug("Storing the new " + records.size() + " received circuits statistics."); for (String[] currentRecord : records) { if (currentRecord.length < 7) throw new IllegalArgumentException( "Invalid record length: it should contain at least 7 fields."); CircuitStatistics currentStatistics = new CircuitStatistics(); if (!StringUtils.isNumeric(currentRecord[0].trim())) throw new IllegalArgumentException("Records should start with timestamp."); Long timestamp = Long.valueOf(currentRecord[0].trim()); currentStatistics.setSlaFlowId(currentRecord[1].trim()); currentStatistics.setThroughput(currentRecord[2].trim()); currentStatistics.setPacketLoss(currentRecord[3].trim()); currentStatistics.setDelay(currentRecord[4].trim()); currentStatistics.setJitter(currentRecord[5].trim()); StringBuilder sb = new StringBuilder(); for (int i = 6; i < currentRecord.length; i++) sb.append(currentRecord[i]).append(","); sb.setLength(sb.length() - 1); // remove last "," currentStatistics.setFlowData(sb.toString().trim()); if (circuitsStatistics.containsKey(timestamp)) circuitsStatistics.get(timestamp).add(currentStatistics); else { List<CircuitStatistics> circuitStatisticsList = new ArrayList<CircuitStatistics>(); circuitStatisticsList.add(currentStatistics); circuitsStatistics.put(timestamp, circuitStatisticsList); } } return circuitsStatistics; } finally { reader.close(); } }