List of usage examples for java.util TreeSet TreeSet
public TreeSet(SortedSet<E> s)
From source file:edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceModelMaker.java
private Set<String> getModelNames() { try {//w w w . j av a 2s .c o m @SuppressWarnings("unchecked") Set<String> names = new TreeSet<>(Collator.getInstance()); names.addAll(service.getGraphURIs()); return names; } catch (RDFServiceException e) { throw new RuntimeException(e); } }
From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.evaluation.phrasematch.LineReader.java
@Override public Set<String> getSetOfStrings(JCas jcas) throws AnalysisEngineProcessException { return new TreeSet<String>(getListOfStrings(jcas)); }
From source file:net.sourceforge.fenixedu.domain.DistrictSubdivision.java
static public Collection<DistrictSubdivision> findByName(String name, int size) { String normalizedName = StringNormalizer.normalize(name); Collection<DistrictSubdivision> result = new TreeSet<DistrictSubdivision>(COMPARATOR_BY_NAME); for (DistrictSubdivision districtSubdivision : Bennu.getInstance().getDistrictSubdivisionsSet()) { if (StringNormalizer.normalize(districtSubdivision.getName()).contains(normalizedName)) { result.add(districtSubdivision); if (result.size() >= size) { break; }//from ww w . ja v a 2 s . c o m } } return result; }
From source file:org.openmrs.module.kenyaemr.fragment.controller.AdminUtilFragmentController.java
public List<SimpleObject> accountSearch(@RequestParam(value = "q", required = false) String query, @RequestParam(value = "which", required = false) String which, UiUtils ui) { Map<Person, User> userAccounts = new HashMap<Person, User>(); Map<Person, Provider> providerAccounts = new HashMap<Person, Provider>(); if ("both".equals(which) || "users".equals(which)) { List<User> users = Context.getUserService().getUsers(query, null, true); for (User u : users) { if (!"daemon".equals(u.getUsername())) { userAccounts.put(u.getPerson(), u); }/*from w ww . jav a2 s.c o m*/ } } if ("both".equals(which) || "providers".equals(which)) { List<Provider> providers = Context.getProviderService().getProviders(query, null, null, null); for (Provider p : providers) { if (p.getPerson() != null) { providerAccounts.put(p.getPerson(), p); } } } Set<Person> persons = new TreeSet<Person>(new PersonByNameComparator()); persons.addAll(userAccounts.keySet()); persons.addAll(providerAccounts.keySet()); List<SimpleObject> ret = new ArrayList<SimpleObject>(); for (Person p : persons) { SimpleObject account = SimpleObject.fromObject(p, ui, "personId", "personName"); User user = userAccounts.get(p); if (user != null) { account.put("user", SimpleObject.fromObject(user, ui, "username")); } Provider provider = providerAccounts.get(p); if (provider != null) { account.put("provider", SimpleObject.fromObject(provider, ui, "identifier")); } ret.add(account); } return ret; }
From source file:com.healthcit.cacure.dao.BaseQuestionDao.java
public Set<String> getQuestionsShortNamesLike(Set<String> shortNames, boolean exact) { if (CollectionUtils.isEmpty(shortNames)) { return new HashSet<String>(0); }/*from w ww . ja v a 2 s .co m*/ StringBuffer sb = new StringBuffer("select bq.shortName from BaseQuestion bq where "); int num = 1; for (String shortName : shortNames) { sb.append("bq.shortName like ?"); sb.append(num++); if (num <= shortNames.size()) { sb.append(" OR "); } } Query query = em.createQuery(sb.toString()); num = 1; for (String shortName : shortNames) { query.setParameter(num++, shortName + (exact ? "" : "%")); } List<String> list = (List<String>) query.getResultList(); return new TreeSet<String>(list); }
From source file:com.devnexus.ting.core.service.impl.DefaultTwitterService.java
/** {@inheritDoc} */ @Override// w w w . j a v a 2 s .c o m public Collection<TwitterMessage> getTwitterMessages() { SortedSet<TwitterMessage> twitterMessages = new TreeSet<TwitterMessage>(new Comparator<TwitterMessage>() { @Override public int compare(TwitterMessage twitterMessage1, TwitterMessage twitterMessage2) { return twitterMessage2.getCreatedAt().compareTo(twitterMessage1.getCreatedAt()); } }); twitterMessages.addAll(this.twitterMessages.asMap().values()); return twitterMessages; }