List of usage examples for java.text Collator getInstance
public static synchronized Collator getInstance()
From source file:edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup.java
/** * Sorts PropertyGroup objects by group rank, then alphanumeric. * @author bdc34 modified by jc55, bjl23 *///from ww w . j a v a 2 s. com public int compareTo(PropertyGroup o2) { Collator collator = Collator.getInstance(); if (o2 == null) { log.error("object NULL in DisplayComparator()"); return 0; } int diff = (this.getDisplayRank() - o2.getDisplayRank()); if (diff == 0) { return collator.compare(this.getName(), o2.getName()); } return diff; }
From source file:edu.cornell.mannlib.vitro.webapp.beans.Ontology.java
public int compareTo(Ontology o2) { Collator collator = Collator.getInstance(); if (o2 == null) { log.error("Ontology NULL in DisplayComparator()"); return 0; }/*from w ww .j a va 2s . c om*/ return collator.compare(this.getName(), o2.getName()); }
From source file:ro.nextreports.designer.action.favorites.FavoritesUtil.java
@SuppressWarnings("unchecked") public static List<FavoriteEntry> loadFavorites(XStream xstream) { List<FavoriteEntry> favorites = new ArrayList<FavoriteEntry>(); FileInputStream fis = null;//w w w.j a va 2s . c o m InputStreamReader reader = null; try { fis = new FileInputStream(Globals.USER_DATA_DIR + "/" + FAVORITES_XML); reader = new InputStreamReader(fis, "UTF-8"); favorites = (List<FavoriteEntry>) xstream.fromXML(reader); } catch (FileNotFoundException ex) { // nothing to do -> file is not created yet } catch (Exception ex) { ex.printStackTrace(); LOG.error(ex.getMessage(), ex); } finally { if (fis != null) { try { fis.close(); } catch (IOException e1) { e1.printStackTrace(); } } } Collections.sort(favorites, new Comparator<FavoriteEntry>() { @Override public int compare(FavoriteEntry o1, FavoriteEntry o2) { return Collator.getInstance().compare(o1.getName(), o2.getName()); } }); return favorites; }
From source file:shuffle.fwk.gui.TypeChooser.java
private void refill() { removeAllItems();/* w w w . ja v a 2 s . c o m*/ if (isFilter) { addItem(getString(KEY_NO_FILTER)); currentSEString = getString(KEY_SUPER_EFFECTIVE); addItem(currentSEString); } List<String> types = new ArrayList<String>(); for (PkmType t : PkmType.values()) { if (PkmType.getMultiplier(PkmType.NORMAL, t) > 0) { types.add(WordUtils.capitalizeFully(t.toString())); } } Collections.sort(types, Collator.getInstance()); for (String item : types) { addItem(item); } }
From source file:com.btmura.android.reddit.content.RelatedSubredditLoader.java
private TreeSet<String> findSubreddits(CharSequence description) { TreeSet<String> subreddits = new TreeSet<String>(Collator.getInstance()); Matcher matcher = SUBREDDIT_PATTERN.matcher(description); while (matcher.find()) { subreddits.add(matcher.group(1)); }/*from ww w . jav a 2 s. c o m*/ return subreddits; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.utils.RequestUtils.java
public static Collection buildExecutionDegreeLabelValueBean(Collection executionDegrees) { final Map duplicateDegreesMap = new HashMap(); for (Iterator iterator = executionDegrees.iterator(); iterator.hasNext();) { InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) iterator.next(); InfoDegree infoDegree = infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree(); String degreeName = infoDegree.getNome(); if (duplicateDegreesMap.get(degreeName) == null) { duplicateDegreesMap.put(degreeName, new Boolean(false)); } else {//from w ww.j a va 2 s . com duplicateDegreesMap.put(degreeName, new Boolean(true)); } } Collection lableValueList = CollectionUtils.collect(executionDegrees, new Transformer() { @Override public Object transform(Object arg0) { InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) arg0; String label = infoExecutionDegree.getInfoDegreeCurricularPlan().getDegreeCurricularPlan() .getPresentationName(infoExecutionDegree.getInfoExecutionYear().getExecutionYear()); String value = infoExecutionDegree.getExternalId().toString(); return new LabelValueBean(label, value); } }); Comparator comparator = new BeanComparator("label", Collator.getInstance()); Collections.sort((List) lableValueList, comparator); return lableValueList; }
From source file:de.blizzy.rust.lootconfig.LootConfigDump.java
private void run() throws IOException { LootConfig config = loadConfig(configFile); Table<LootContainer, Category, Multiset<Float>> dropChances = HashBasedTable.create(); Collection<LootContainer> lootContainers = config.LootContainers.values(); config.Categories.values().stream().filter(Category::hasItemsOrBlueprints).forEach(category -> { lootContainers.forEach(lootContainer -> { Multiset<Float> categoryInContainerDropChances = getItemCategoryDropChances(category, lootContainer);/*from w w w . j a v a 2 s . co m*/ if (!categoryInContainerDropChances.isEmpty()) { dropChances.put(lootContainer, category, categoryInContainerDropChances); } }); }); dropChances.rowKeySet().stream() .filter(lootContainer -> SHOW_DMLOOT || !lootContainer.name.contains("dmloot")) .sorted((lootContainer1, lootContainer2) -> Collator.getInstance().compare(lootContainer1.name, lootContainer2.name)) .forEach(lootContainer -> { System.out.printf("%s (blueprint fragments: %s)", lootContainer, lootContainer.DistributeFragments ? "yes" : "no").println(); Map<Category, Multiset<Float>> lootContainerDropChances = dropChances.row(lootContainer); AtomicDouble lootContainerDropChancesSum = new AtomicDouble(); AtomicInteger categoriesCount = new AtomicInteger(); lootContainerDropChances.entrySet().stream().sorted(this::compareByChances).limit(7) .forEach(categoryDropChancesEntry -> { Category category = categoryDropChancesEntry.getKey(); Multiset<Float> categoryDropChances = categoryDropChancesEntry.getValue(); float categoryDropChancesSum = sum(categoryDropChances); lootContainerDropChancesSum.addAndGet(categoryDropChancesSum); System.out.printf(" %s %s%s%s", formatPercent(categoryDropChancesSum), category, (category.Items.size() > 0) ? " (" + formatItems(category) + ")" : "", (category.Blueprints.size() > 0) ? " [" + formatBlueprints(category) + "]" : "") .println(); categoriesCount.incrementAndGet(); }); if (categoriesCount.get() < lootContainerDropChances.size()) { System.out.printf(" %s other (%d)", formatPercent(1f - (float) lootContainerDropChancesSum.get()), lootContainerDropChances.size() - categoriesCount.get()).println(); } }); }
From source file:org.zaproxy.zap.extension.selenium.BrowserUI.java
/** * Compares the names of browsers, using a {@code Collator} of the default {@code Locale}. * * @see #getName()//from w w w. j a va2 s . com * @see Collator */ @Override public int compareTo(BrowserUI other) { if (other == null) { return 1; } return Collator.getInstance().compare(name, other.name); }
From source file:org.zaproxy.zap.extension.selenium.ProvidedBrowserUI.java
/** * Compares the names of browsers, using a {@code Collator} of the default {@code Locale}. * * @see #getName()/*from ww w.ja va 2 s. c om*/ * @see Collator */ @Override public int compareTo(ProvidedBrowserUI other) { if (other == null) { return 1; } int result = Collator.getInstance().compare(getName(), other.getName()); if (result != 0) { return result; } return Collator.getInstance().compare(browser.getProviderId(), other.browser.getProviderId()); }
From source file:org.sakaiproject.tool.assessment.util.BeanSortComparator.java
private int subCompare(String s1, String s2) { //we do not want to use null values for sorting if (s1 == null) { s1 = "";//from ww w . j a va 2 s . co m } if (s2 == null) { s2 = ""; } // Deal with n/a case if (s1.toLowerCase().startsWith("n/a") && !s2.toLowerCase().startsWith("n/a")) return 1; if (s2.toLowerCase().startsWith("n/a") && !s1.toLowerCase().startsWith("n/a")) return -1; String finalS1 = s1.replaceAll("<.*?>", ""); String finalS2 = s2.replaceAll("<.*?>", ""); RuleBasedCollator collator_ini = (RuleBasedCollator) Collator.getInstance(); try { RuleBasedCollator collator = new RuleBasedCollator( collator_ini.getRules().replaceAll("<'\u005f'", "<' '<'\u005f'")); return collator.compare(finalS1.toLowerCase(), finalS2.toLowerCase()); } catch (ParseException e) { } return Collator.getInstance().compare(finalS1.toLowerCase(), finalS2.toLowerCase()); }