Code example for RuleBasedCollator

Methods: getRules

0
    String DIN5007_2_tailorings =
      "& ae , a\u0308 & AE , A\u0308"+ 
      "& oe , o\u0308 & OE , O\u0308"+ 
      "& ue , u\u0308 & UE , u\u0308"; 
 
    RuleBasedCollator tailoredCollator = new RuleBasedCollator(baseCollator.getRules() + DIN5007_2_tailorings);
    String tailoredRules = tailoredCollator.getRules();
    // 
    // at this point, you would save these tailoredRules to a file,  
    // and use the custom parameter. 
    // 
    String germanUmlaut = "Töne";
    String germanOE = "Toene";
    CollationKeyFilterFactory factory = new CollationKeyFilterFactory();
    Map<String,String> args = new HashMap<String,String>();
    args.put("custom", "rules.txt");
    args.put("strength", "primary");
    factory.init(args);
    factory.inform(new StringMockSolrResourceLoader(tailoredRules));
    TokenStream tsUmlaut = factory.create(
        new KeywordTokenizer(new StringReader(germanUmlaut)));