List of usage examples for java.util TreeSet add
public boolean add(E e)
From source file:edu.fullerton.ldvservlet.SrcList.java
private int addChanSource(PageItemList tables, List<Integer> chanList, ChannelTable chanTbl, int tblNum, ArrayList<ChanSourceData> csdList, TimeInterval timeRange) throws LdvTableException, WebUtilException { TreeSet<ChanInfo> channels = new TreeSet<>(); for (Integer chanId : chanList) { ChanInfo ci = chanTbl.getChanInfo(chanId); for (ChanInfo ci2 : channels) { boolean closeEnough = ci.getChanName().contentEquals(ci2.getChanName()); closeEnough &= ci.getcType().contentEquals(ci2.getcType()); closeEnough &= ci.getServer().contentEquals(ci2.getServer()); if (closeEnough) { ci = null;/* w w w . j a va2 s.co m*/ break; } } if (ci != null) { channels.add(ci); } } for (ChanInfo ci : channels) { ChanSourceData csd = new ChanSourceData(); csd.pullData(ci); csd.mergeIntervals(timeRange); csd.calcGraphData(); csdList.add(csd); PageItem table = makeTable(csd, tblNum); tblNum++; tables.add(table); String errors = csd.getErrors(); if (!errors.isEmpty()) { String ermsg = errors.replaceAll("\n", "<br>\n"); tables.addBlankLines(1); tables.add(new PageItemString(ermsg, false)); } } return tblNum; }
From source file:com.ecyrd.jspwiki.ReferenceManager.java
/** * Updates the referred pages of a new or edited WikiPage. If a refersTo * entry for this page already exists, it is removed and a new one is built * from scratch. Also calls updateReferredBy() for each referenced page. * <p>//from w ww . ja va 2 s . c o m * This method does not synchronize the database to disk. * * @param page Name of the page to update. * @param references A Collection of Strings, each one pointing to a page this page references. */ private void internalUpdateReferences(String page, Collection references) { page = getFinalPageName(page); // // Create a new entry in m_refersTo. // Collection oldRefTo = m_refersTo.get(page); m_refersTo.remove(page); TreeSet<String> cleanedRefs = new TreeSet<String>(); for (Iterator i = references.iterator(); i.hasNext();) { String ref = (String) i.next(); ref = getFinalPageName(ref); cleanedRefs.add(ref); } m_refersTo.put(page, cleanedRefs); // // We know the page exists, since it's making references somewhere. // If an entry for it didn't exist previously in m_referredBy, make // sure one is added now. // if (!m_referredBy.containsKey(page)) { m_referredBy.put(page, new TreeSet<String>()); } // // Get all pages that used to be referred to by 'page' and // remove that reference. (We don't want to try to figure out // which particular references were removed...) // cleanReferredBy(page, oldRefTo, cleanedRefs); // // Notify all referred pages of their referinesshoodicity. // Iterator<String> it = cleanedRefs.iterator(); while (it.hasNext()) { String referredPageName = it.next(); updateReferredBy(getFinalPageName(referredPageName), page); } }
From source file:com.ecyrd.jspwiki.ui.TemplateManager.java
/** * Lists the skins available under this template. Returns an * empty Set, if there are no extra skins available. Note that * this method does not check whether there is anything actually * in the directories, it just lists them. This may change * in the future.//from w w w. jav a2s .co m * * @param pageContext the JSP PageContext * @param template The template to search * @return Set of Strings with the skin names. * @since 2.3.26 */ @SuppressWarnings("unchecked") public Set listSkins(PageContext pageContext, String template) { String place = makeFullJSPName(template, SKIN_DIRECTORY); ServletContext sContext = pageContext.getServletContext(); Set<String> skinSet = sContext.getResourcePaths(place); TreeSet<String> resultSet = new TreeSet<String>(); if (log.isDebugEnabled()) log.debug("Listings skins from " + place); if (skinSet != null) { String[] skins = {}; skins = skinSet.toArray(skins); for (int i = 0; i < skins.length; i++) { String[] s = StringUtils.split(skins[i], "/"); if (s.length > 2 && skins[i].endsWith("/")) { String skinName = s[s.length - 1]; resultSet.add(skinName); if (log.isDebugEnabled()) log.debug("...adding skin '" + skinName + "'"); } } } return resultSet; }
From source file:io.wcm.handler.mediasource.dam.impl.CropRenditionHandler.java
/** * Searches for the biggest web enabled rendition and, if exists, adds a {@link VirtualCropRenditionMetadata} to the * list//from ww w . jav a 2s. c o m * @param candidates * @return {@link Set} of {@link RenditionMetadata} */ @Override protected Set<RenditionMetadata> postProcessCandidates(Set<RenditionMetadata> candidates) { TreeSet<RenditionMetadata> processedCandidates = new TreeSet<>(candidates); Iterator<RenditionMetadata> descendingIterator = processedCandidates.descendingIterator(); VirtualCropRenditionMetadata cropRendition = null; while (descendingIterator.hasNext()) { RenditionMetadata rendition = descendingIterator.next(); if (DEFAULT_WEB_RENDITION_PATTERN.matcher(rendition.getRendition().getName()).matches()) { RenditionMetadata sourceRendition = new RenditionMetadata(rendition.getRendition()); boolean isImage = FileExtension.isImage(assetFileExtension); if (isImage && sourceRendition.getWidth() >= cropDimension.getRight() && sourceRendition.getHeight() >= cropDimension.getBottom()) { // found biggest virtual rendition for cropped image cropRendition = new VirtualCropRenditionMetadata(sourceRendition.getRendition(), cropDimension.getWidth(), cropDimension.getHeight(), cropDimension); break; } } } if (cropRendition != null) { processedCandidates.add(cropRendition); } return processedCandidates; }
From source file:edu.ku.brc.specify.ui.db.PickListTableAdapter.java
/** * Fills non-Item type PickLists from a Table. * @param type the type to be filled//from w ww .j a va 2 s .co m */ protected void fill(final PickListDBAdapterIFace.Type type) { if (type != PickListDBAdapterIFace.Type.Item) { DBTableInfo tableInfo = DBTableIdMgr.getInstance() .getInfoById(DBTableIdMgr.getInstance().getIdByShortName(pickList.getTableName())); if (tableInfo != null) { DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); try { boolean isBasicType = false; boolean isFromField = type == PickListDBAdapterIFace.Type.TableField; if (isFromField) { DBFieldInfo fi = tableInfo.getFieldByColumnName(pickList.getFieldName()); isBasicType = fi != null ? UIHelper.isPrimitiveObjectType(fi.getDataClass()) : false; } String sqlStr = buildHQL(tableInfo, type == PickListDBAdapterIFace.Type.TableField ? pickList.getFieldName() : null); //log.debug(sqlStr); if (StringUtils.isNotEmpty(sqlStr)) { List<?> dataList = session.getDataList(sqlStr); if (dataList != null && !dataList.isEmpty()) { if (type == PickListDBAdapterIFace.Type.TableField) { TreeSet<String> values = isBasicType ? new TreeSet<String>(String.CASE_INSENSITIVE_ORDER) : null; String formatterStr = isBasicType ? null : pickList.getFormatter(); boolean hasFormatter = StringUtils.isNotEmpty(formatterStr); for (Object dataObj : dataList) { if (dataObj instanceof Object[]) { dataObj = ((Object[]) dataObj)[0]; } if (dataObj != null) { String valStr = hasFormatter ? String.format(formatterStr, dataObj) : dataObj.toString(); if (isBasicType) { values.add(valStr); } else { items.add(pickList.addItem(valStr, valStr)); } } } if (isBasicType) { for (String v : values) { items.add(pickList.addItem(v, v)); } } } else { for (Object dataObj : dataList) { if (dataObj instanceof Object[]) { dataObj = ((Object[]) dataObj)[0]; } String title; if (pickList.getFormatter() != null) { title = DataObjFieldFormatMgr.getInstance().format(dataObj, pickList.getFormatter()); } else { title = ((FormDataObjIFace) dataObj).getIdentityTitle(); } items.add(pickList.addItem(title, dataObj)); } } } else { // No Data Error } } else { log.error("Query String is empty for tableId[" + tableInfo.getTableId() + "]"); } } catch (Exception ex) { ex.printStackTrace(); log.error(ex); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PickListTableAdapter.class, ex); } finally { if (session != null) { session.close(); } } } else { throw new RuntimeException( "Error looking up PickLIst's Table Name [" + pickList.getTableName() + "]"); } } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.webSiteManager.CustomUnitSiteManagementDA.java
private SortedSet<Person> collectFunctionPersons(Unit unit, TreeSet<Person> persons) { YearMonthDay today = new YearMonthDay(); AccountabilityTypeEnum[] types = new AccountabilityTypeEnum[] { AccountabilityTypeEnum.WORKING_CONTRACT, AccountabilityTypeEnum.RESEARCH_CONTRACT }; List<Contract> contacts = unit.getContracts(today, null, types); for (Contract contract : contacts) { persons.add(contract.getPerson()); }/*from w w w . ja v a 2 s . c om*/ for (Function function : unit.getFunctionsSet()) { for (PersonFunction pf : function.getPersonFunctions()) { if (pf.isActive(today)) { persons.add(pf.getPerson()); } } } for (Unit sub : unit.getSubUnits()) { collectFunctionPersons(sub, persons); } return persons; }
From source file:au.edu.uq.cmm.paul.grabber.Analyser.java
private SortedSet<DatasetMetadata> buildInFolderMetadata() { TreeSet<DatasetMetadata> inFolder = new TreeSet<DatasetMetadata>(ORDER_BY_BASE_PATH_AND_TIME); String folderName = getFacility().getFolderName(); if (folderName == null) { return inFolder; }/*w ww . j a va 2 s. c om*/ File localDir = uncNameMapper.mapUncPathname(folderName); if (localDir == null) { return inFolder; } fsm.getStatus(getFacility()).setLocalDirectory(localDir); analyseTree(localDir, Long.MIN_VALUE, Long.MAX_VALUE); for (Runnable runnable : queue) { WorkEntry entry = (WorkEntry) runnable; SessionDetails session = fsm.getSessionDetails(getFacility(), entry.getTimestamp().getTime(), entry.getBaseFile()); entry.pretendToGrabFiles(); inFolder.add(entry.assembleDatasetMetadata(null, session, new File(""))); } return inFolder; }
From source file:br.bireme.ngrams.NGrams.java
private static Set<String> results2pipeFull(final Parameters parameters, final Set<Result> results) { assert parameters != null; assert results != null; final TreeSet<String> ret = new TreeSet<>(); final StringBuilder builder = new StringBuilder(); final Collection<br.bireme.ngrams.Field> flds = parameters.sfields.values(); for (Result result : results) { final String[] param = result.param; final Document doc = result.doc; builder.setLength(0);/* w ww.j av a 2 s .c o m*/ builder.append(result.score).append("|").append(result.similarity); for (int idx = 0; idx < flds.size(); idx++) { String fld = param[idx]; fld = (fld == null) ? "" : fld.trim().replace('|', '!'); builder.append("|").append(fld); builder.append("|").append(Tools.limitSize(Tools.normalize(fld, OCC_SEPARATOR), MAX_NG_TEXT_SIZE)); } for (br.bireme.ngrams.Field field : flds) { final String fldN = doc.get(field.name); final String fld = doc.get(field.name + NGrams.NOT_NORMALIZED_FLD); builder.append("|").append((fld == null) ? "" : fld.replace('|', '!')); builder.append("|").append((fldN == null) ? "" : fldN.replace('|', '!')); } ret.add(builder.toString()); } return ret.descendingSet(); }
From source file:grails.plugin.cache.web.filter.PageFragmentCachingFilter.java
/** * Set the headers in the response object, excluding the Gzip header * @param pageInfo/*from w ww . j a v a2s . com*/ * @param response */ protected void setHeaders(final PageInfo pageInfo, final HttpServletResponse response) { Collection<Header<? extends Serializable>> headers = pageInfo.getHeaders(); // Track which headers have been set so all headers of the same name // after the first are added TreeSet<String> setHeaders = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); for (Header<? extends Serializable> header : headers) { String name = header.getName(); switch (header.getType()) { case STRING: if (setHeaders.contains(name)) { response.addHeader(name, (String) header.getValue()); } else { setHeaders.add(name); response.setHeader(name, (String) header.getValue()); } break; case DATE: if (setHeaders.contains(name)) { response.addDateHeader(name, (Long) header.getValue()); } else { setHeaders.add(name); response.setDateHeader(name, (Long) header.getValue()); } break; case INT: if (setHeaders.contains(name)) { response.addIntHeader(name, (Integer) header.getValue()); } else { setHeaders.add(name); response.setIntHeader(name, (Integer) header.getValue()); } break; default: throw new IllegalArgumentException("No mapping for Header: " + header); } } }
From source file:com.ecyrd.jspwiki.ReferenceManager.java
/** * Does a full reference update. Does not sync; assumes that you do it afterwards. *//*from w ww. j a va 2 s . c o m*/ @SuppressWarnings("unchecked") private void updatePageReferences(WikiPage page) throws ProviderException { String content = m_engine.getPageManager().getPageText(page.getName(), WikiPageProvider.LATEST_VERSION); TreeSet<String> res = new TreeSet<String>(); Collection<String> links = m_engine.scanWikiLinks(page, content); res.addAll(links); Collection attachments = m_engine.getAttachmentManager().listAttachments(page); for (Iterator atti = attachments.iterator(); atti.hasNext();) { res.add(((Attachment) (atti.next())).getName()); } internalUpdateReferences(page.getName(), res); }