List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:net.spfbl.data.NoReply.java
private static synchronized TreeSet<String> getAll() throws ProcessException { TreeSet<String> blockSet = new TreeSet<String>(); blockSet.addAll(SET); return blockSet; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.person.SearchPersonMatchingAnyParameter.java
public static CollectionPager<Person> run(String name, String email, String username, String documentIdNumber, IDDocumentType idDocumentType, String roleType, String degreeTypeString, String degreeId, String departmentId, Boolean activePersons, Integer studentNumber, Boolean externalPersons) { SearchParameters searchParameters = new SearchPersonMatchingAnyParameter.SearchParameters(name, email, username, documentIdNumber, idDocumentType == null ? null : idDocumentType.name(), roleType, degreeTypeString, degreeId, departmentId, activePersons, studentNumber, externalPersons, (String) null);/* w w w.ja va2s . c o m*/ if (searchParameters.emptyParameters()) { return new CollectionPager<Person>(new HashSet<Person>(), 25); } final Collection<Person> persons = new HashSet<Person>(); if (searchParameters.getUsername() != null && searchParameters.getUsername().length() > 0) { final Person person = Person.readPersonByUsername(searchParameters.getUsername()); if (person != null) { persons.add(person); } } else { if (searchParameters.getDocumentIdNumber() != null && searchParameters.getDocumentIdNumber().length() > 0) { persons.addAll(Person.findPersonByDocumentID(searchParameters.getDocumentIdNumber())); } if (searchParameters.getStudentNumber() != null) { final Student student = Student.readStudentByNumber(searchParameters.getStudentNumber()); if (student != null) { persons.add(student.getPerson()); } } if (searchParameters.getEmail() != null && searchParameters.getEmail().length() > 0) { final Person person = Person.readPersonByEmailAddress(searchParameters.getEmail()); if (person != null) { persons.add(person); } } if (searchParameters.getMechanoGraphicalNumber() != null) { final Employee employee = Employee.readByNumber(searchParameters.getMechanoGraphicalNumber()); final Student student = Student.readStudentByNumber(searchParameters.getMechanoGraphicalNumber()); if (employee != null) { persons.add(employee.getPerson()); } if (student != null) { persons.add(student.getPerson()); } } if (searchParameters.getName() != null) { if (searchParameters.getExternalPersons() == null || !searchParameters.getExternalPersons()) { persons.addAll(Person.findInternalPerson(searchParameters.getName())); final Role roleBd = searchParameters.getRole(); if (roleBd != null) { for (final Iterator<Person> peopleIterator = persons.iterator(); peopleIterator .hasNext();) { final Person person = peopleIterator.next(); if (!person.hasPersonRoles(roleBd)) { peopleIterator.remove(); } } } final Department department = searchParameters.getDepartment(); if (department != null) { for (final Iterator<Person> peopleIterator = persons.iterator(); peopleIterator .hasNext();) { final Person person = peopleIterator.next(); final Teacher teacher = person.getTeacher(); if (teacher == null || teacher.getCurrentWorkingDepartment() != department) { peopleIterator.remove(); } } } } if (searchParameters.getExternalPersons() == null || searchParameters.getExternalPersons()) { persons.addAll(Person.findExternalPerson(searchParameters.getName())); } } } SearchPersonPredicate predicate = new SearchPersonMatchingAnyParameterPredicate(searchParameters); TreeSet<Person> result = new TreeSet<Person>(Person.COMPARATOR_BY_NAME_AND_ID); result.addAll(CollectionUtils.select(persons, predicate)); return new CollectionPager<Person>(result, 25); }
From source file:com.cyberway.issue.net.PublicSuffixes.java
/** * Converts SURT-ordered list of public prefixes into a Java regex which * matches the public-portion "plus one" segment, giving the domain on which * cookies can be set or other policy grouping should occur. Also adds to * regex a fallback matcher that for any new/unknown TLDs assumes the * second-level domain is assignable. (Eg: 'zzz,example,'). * /*w ww.j a v a 2 s . com*/ * @param list * @return */ private static String surtPrefixRegexFromSurtList(List<String> list) { StringBuilder regex = new StringBuilder(); regex.append("(?ix)^\n"); TreeSet<String> prefixes = new TreeSet<String>(Collections.reverseOrder()); prefixes.addAll(list); prefixes.add("*,"); // for new/unknown TLDs buildRegex("", regex, prefixes); regex.append("\n([\\-\\w]+,)"); String rstring = regex.toString(); // convert glob-stars to word-char-runs rstring = rstring.replaceAll("\\*", "[\\\\-\\\\w]+"); return rstring; }
From source file:net.spfbl.core.Defer.java
private static synchronized TreeSet<String> keySet() { TreeSet<String> keySet = new TreeSet<String>(); keySet.addAll(MAP.keySet()); return keySet; }
From source file:org.jenkins.ci.plugins.PersistentBuildQueue.java
/** * Get all the entries in the persistent build queue, sorted. * /*from w w w. j ava 2s .c o m*/ * @return the sorted entries */ @SuppressWarnings("unchecked") private static SortedSet<String> getPersistentBuildQueueEntries() { final TreeSet<String> set = new TreeSet<String>(); InputStream inputStream = null; try { inputStream = new FileInputStream(getPersistentBuildQueueFile()); set.addAll(IOUtils.readLines(inputStream)); } catch (final IOException e) { LOG.log(Level.WARNING, e.getMessage(), e); } finally { IOUtils.closeQuietly(inputStream); } return set; }
From source file:com.hp.alm.ali.idea.cfg.AliConfigurable.java
private static boolean containsInsensitive(Collection<String> c, String val) { TreeSet<String> ts = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); ts.addAll(c); return ts.contains(val); }
From source file:onl.netfishers.netshot.Database.java
/** * List classes in a given package./*from w ww .j a va 2 s . c o m*/ * * @param packageName the package name * @return the list * @throws ClassNotFoundException the class not found exception * @throws IOException Signals that an I/O exception has occurred. */ public static List<Class<?>> listClassesInPackage(String packageName) throws ClassNotFoundException, IOException { String path = packageName.replace('.', '/'); Enumeration<URL> resources = ClassLoader.getSystemResources(path); List<String> dirs = new ArrayList<String>(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); dirs.add(URLDecoder.decode(resource.getFile(), "UTF-8")); } TreeSet<String> classes = new TreeSet<String>(); for (String directory : dirs) { classes.addAll(findClasses(directory, packageName)); } ArrayList<Class<?>> classList = new ArrayList<Class<?>>(); for (String clazz : classes) { classList.add(Class.forName(clazz)); } return classList; }
From source file:org.apache.marmotta.platform.ldp.patch.RdfPatchUtil.java
/** * Create an RDF-Patch that applies the changes from {@code c1} to {@code c2}. * @param c1 the 'from' RepositoryConnection * @param c2 the 'to' RepositoryConnection * @param optimize optimize the patch, i.e. remove duplicate or idempotent operations. * @param contexts restrict analysis to these contexts (leave empty to use <em>all</em> contexts) * @return List of PatchLines//from w w w . jav a2 s .c o m */ public static List<PatchLine> diff(RepositoryConnection c1, RepositoryConnection c2, boolean optimize, Resource... contexts) throws RepositoryException { Set<Statement> additions = new HashSet<>(), removals = new HashSet<>(); final RepositoryResult<Statement> st1 = c1.getStatements(null, null, null, false, contexts); try { while (st1.hasNext()) { final Statement st = st1.next(); if (!c2.hasStatement(st, false, contexts)) { removals.add(st); } } } finally { st1.close(); } final RepositoryResult<Statement> st2 = c2.getStatements(null, null, null, false, contexts); try { while (st2.hasNext()) { final Statement st = st2.next(); if (!c1.hasStatement(st, false, contexts)) { additions.add(st); } } } finally { st2.close(); } if (optimize) { final TreeSet<Statement> delList = new TreeSet<>(new StatementComparator()); delList.addAll(removals); final TreeSet<Statement> addList = new TreeSet<>(new StatementComparator()); addList.addAll(additions); additions = addList; removals = delList; } Resource pS = null; URI pP = null; Value pO = null; ArrayList<PatchLine> patch = new ArrayList<>(removals.size() + additions.size()); for (Statement s : removals) { final WildcardStatement ws = new WildcardStatement(s.getSubject().equals(pS) ? null : s.getSubject(), s.getPredicate().equals(pP) ? null : s.getPredicate(), s.getObject().equals(pO) ? null : s.getObject()); patch.add(new PatchLine(PatchLine.Operator.DELETE, ws)); pS = s.getSubject(); pP = s.getPredicate(); pO = s.getObject(); } for (Statement s : additions) { final WildcardStatement ws = new WildcardStatement(s.getSubject().equals(pS) ? null : s.getSubject(), s.getPredicate().equals(pP) ? null : s.getPredicate(), s.getObject().equals(pO) ? null : s.getObject()); patch.add(new PatchLine(PatchLine.Operator.ADD, ws)); pS = s.getSubject(); pP = s.getPredicate(); pO = s.getObject(); } return patch; }
From source file:org.hippoecm.frontend.editor.workflow.model.ReferringDocumentsProvider.java
private static SortedSet<Node> getSortedReferrers(final Collection<Node> nodes) throws RepositoryException { final TreeSet<Node> sorted = new TreeSet<>((o1, o2) -> { try {/*from w w w. j a va2 s .co m*/ return o1.getPath().compareTo(o2.getPath()); } catch (RepositoryException e) { throw new RepositoryRuntimeException(e); } }); sorted.addAll(nodes); return sorted; }
From source file:net.spfbl.data.Ignore.java
public static TreeSet<String> getAll() throws ProcessException { TreeSet<String> ignoreSet = SET.getAll(); ignoreSet.addAll(CIDR.getAll()); return ignoreSet; }