See Also: RuleBasedCollator Members
A concrete subclass of Java.Text.Collator. It is based on the ICU RuleBasedCollator which implements the CLDR and Unicode collation algorithms.
Most of the time, you create a Java.Text.Collator instance for a Java.Util.Locale by calling the Collator.Instance factory method. You can construct a RuleBasedCollator if you need a custom sort order.
The root collator's sort order is the CLDR root collation order which in turn is the Unicode default sort order with a few modifications. A RuleBasedCollator is built from a rule String which changes the sort order of some characters and strings relative to the default order.
A rule string usually contains one or more rule chains. A rule chain consists of a reset followed by one or more rules. The reset anchors the following rules in the default sort order. The rules change the order of the their characters and strings relative to the reset point.
A reset is an ampersand & followed by one or more characters for the reset position. A rule is a relation operator, which specifies the level of difference, also followed by one or more characters. A multi-character rule creates a "contraction". A multi-character reset position usually creates "expansions".
For example, the following rules make "ä" sort with a diacritic-like (secondary) difference from "ae" (like in German phonebook sorting), and make "å" and "aa" sort as a base letter (primary) after "z" (like in Danish). Uppercase forms sort with a case-like (tertiary) difference after their lowercase forms.
java Example
&AE<<ä <<<Ä &z<å<<<Å<<<aa<<<Aa<<<AA
For details see
Note: earlier versions of RuleBasedCollator up to and including Android 4.4 (KitKat) allowed the omission of the reset from the first rule chain. This was interpreted as an implied reset after the last non-Han script in the default order. However, this is not a useful reset position, except for large tailorings of Han characters themselves. Starting with the CLDR 24 collation specification and the ICU 53 implementation, the initial reset is required.
If the rule string does not follow the syntax, then RuleBasedCollator throws a ParseException.