/** * We don't need to use the language parameter, so map this to * the standard sort string filter * * @param str string * @param lang language * @return string */ @Override public String filter(String str, String lang) { return filter(str); }
/** * Get a Locale dependent collator * * @return The collator to use */ private static RuleBasedCollator getCollator() { // Get the Locale to use Locale locale = getSortLocale(); if (locale != null) { // Get collator for the supplied Locale RuleBasedCollator collator = (RuleBasedCollator) Collator.getInstance(locale); if (collator != null) { return collator; } } return null; }
/** * Uses a Locale dependent Collator to generate a sort string * * @param str The string to parse * @return String the sort ordering text */ @Override public String filter(String str) { RuleBasedCollator collator = getCollator(); // Have we got a collator? if (collator != null) { int element; StringBuffer buf = new StringBuffer(); // Iterate through the elements of the collator CollationElementIterator iter = collator.getCollationElementIterator(str); while ((element = iter.next()) != CollationElementIterator.NULLORDER) { // Generate a hexadecimal string representation of the Collation element // This can then be compared in a text sort ;-) String test = Integer.toString(element, 16); buf.append(test); } return buf.toString(); } return str; }