throw new IllegalArgumentException("Unknown collation strength: '" + s + "'"); sorter = new UcaSorter(sortString.substring(startPar+1, commaPos), sortString.substring(commaPos+1, commaopt), strength); } else { sorter = new UcaSorter(sortString.substring(startPar+1, commaPos), sortString.substring(commaPos+1, endPar), strength); sorter = new UcaSorter(sortString.substring(startPar+1, endPar));
} else if (sorterType == Sorting.UcaSorter.class) { Sorting.UcaSorter uca = (Sorting.UcaSorter) f.getSorter(); String ucaLocale = uca.getLocale(); Sorting.UcaSorter.Strength ucaStrength = uca.getStrength(); yql.append("[{\"") .append(YqlParser.SORTING_FUNCTION)
public void setLocale(String locale, Strength strength) { this.locale = locale; this.strength = strength; ULocale uloc; try { uloc = new ULocale(locale); } catch (Throwable e) { throw new RuntimeException("ULocale("+locale+") failed with exception " + e.toString()); } try { collator = Collator.getInstance(uloc); if (collator == null) { throw new RuntimeException("No collator available for: " + locale); } } catch (Throwable e) { throw new RuntimeException("Collator.getInstance(ULocale("+locale+")) failed with exception " + e.toString()); } collator.setStrength(strength2Collator(strength)); // collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION); } public String getLocale() { return locale; }
f.setSorter(new Sorting.UcaSorter(name, locale, Sorting.UcaSorter.Strength.UNDEFINED)); } else { String locale = sorter.getLocale(); Sorting.UcaSorter.Strength strength = sorter.getStrength(); if (sorter.getStrength() == Sorting.UcaSorter.Strength.UNDEFINED) { strength = config2Strength(attrConfig.sortstrength()); if ((sorter.getStrength() == Sorting.UcaSorter.Strength.UNDEFINED) || (sorter.getLocale() == null) || sorter.getLocale().isEmpty()) { sorter.setLocale(locale, strength);
public UcaSorter(String fieldName, String locale, Strength strength) { super(fieldName); setLocale(locale, strength); } public UcaSorter(String fieldName) { super(fieldName); }
@Override public String toString() { return "uca(" + getName() + ',' + locale + ',' + ((strength != Strength.UNDEFINED) ? strength.toString() : "PRIMARY") + ')'; } @Override
public UcaSorter clone() { UcaSorter clone = (UcaSorter)super.clone(); if (locale != null) { clone.setLocale(locale, strength); } return clone; } @SuppressWarnings({ "rawtypes", "unchecked" })