java - CollatorProvider mechanism has no effect on Collator -
i have written collatorprovider adds rule respecting whitespaces when ordering user names. i.e: "martin perez" goes before "martinez perez".
public class mycollatorprovider extends collatorprovider { @override public locale[] getavailablelocales() { return new locale[] { new locale("en"), new locale("es","es"), new locale("es"), new locale("fr","fr"), new locale("eu"), new locale("en","en") }; } @override public collator getinstance(locale locale) { rulebasedcollator rbc = (rulebasedcollator) collator.getinstance(); // order names , surnames respecting white spaces // add more rules here .... final string rules = rbc.getrules().replaceall("<'\u005f'", "<' '<'\u005f'"); try { return new rulebasedcollator(rules); } catch (parseexception pe) { throw new error(pe); } } }
i have followed mechanism described in page:https://blogs.oracle.com/kah/entry/user_defined_collation_in_apache
however, deploy jar in jre/lib/ext has no effect on collator, still has old behaviour.
i know jre loads collatorprovider because if change classname in service file exception thrown.
my local code test collator is:
import java.text.collator; public class testcollator { public static void main(string[] args) { // compare 2 strings in default locale collator mycollator = collator.getinstance(); if( mycollator.compare("martin perez", "martinez perez") < 0 ) system.out.println("martin perez va antes que martinez perez."); else system.out.println("martinez perez va antes que martin perez."); } }
i stuck issue. please, me?
Comments
Post a Comment