Skip to content

Commit

Permalink
CLDR-7428 Freeze collators; finishing touches (#4209)
Browse files Browse the repository at this point in the history
  • Loading branch information
btangmu authored Nov 21, 2024
1 parent a82d6ca commit 80c31b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,11 @@ private static void showDefaultContent(String... strings) {

private static void showSortKey() {
String[] tests = "a ä A ぁ あ ァ ァ ア ア ㋐".split(" ");
// TODO: freeze the Collator; problematic since changed in innermost for loop below
// Reference: https://unicode-org.atlassian.net/browse/CLDR-7428
RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(ULocale.ROOT);
c.setStrength(RuleBasedCollator.QUATERNARY);
c.setCaseLevel(true);
c.setHiraganaQuaternary(true);
// Do not freeze the collator since it is changed in the innermost "for" loop below
for (String test : tests) {
for (boolean caseLevel : new boolean[] {false, true}) {
c.setCaseLevel(caseLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ public void handlePath(String xpath) {
"add annotation names to keywords",
new CLDRFilter() {
Set<String> available = Annotations.getAllAvailable();
TreeSet<String> sorted = new TreeSet<>(Collator.getInstance(ULocale.ROOT));
TreeSet<String> sorted = new TreeSet<>(CollatorHelper.ROOT_COLLATOR);
CLDRFile resolved;
Set<String> handledCharacters = new HashSet<>();
boolean isTop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.unicode.cldr.util.CLDRFile.WinningChoice;
import org.unicode.cldr.util.CLDRPaths;
import org.unicode.cldr.util.CldrUtility;
import org.unicode.cldr.util.CollatorHelper;
import org.unicode.cldr.util.Factory;
import org.unicode.cldr.util.Pair;
import org.unicode.cldr.util.PathUtilities;
Expand Down Expand Up @@ -205,12 +206,7 @@ public void handlePathValue(String path, String value) {
}
}

public static Collator col = Collator.getInstance(ULocale.ROOT); // freeze below

static {
col.setStrength(Collator.SECONDARY);
col = col.freeze();
}
public static Collator col = CollatorHelper.ROOT_SECONDARY;

private static OtherHandler otherHandler = new OtherHandler();

Expand Down

0 comments on commit 80c31b7

Please sign in to comment.