i = limit;
}
int length = reorderCodes.size();
- if(length == 1 && reorderCodes.get(0) == Collator.ReorderCodes.DEFAULT) {
- // The root collator does not have a reordering, by definition.
+ if(length == 1 && reorderCodes.get(0) == Collator.ReorderCodes.NONE) {
settings.resetReordering();
return;
}
/**
* Gets a script or reorder code from its string representation.
* @return the script/reorder code, or
- * -1==Collator.ReorderCodes.REORDER_CODE_DEFAULT, or
- * -2 if not recognized
+ * -1 if not recognized
*/
public static int getReorderCode(String word) {
for(int i = 0; i < gSpecialReorderCodes.length; ++i) {
} catch (IllegalIcuArgumentException e) {
// fall through
}
- if(word.equalsIgnoreCase("default")) {
- return Collator.ReorderCodes.DEFAULT;
+ if(word.equalsIgnoreCase("others")) {
+ return Collator.ReorderCodes.OTHERS; // same as Zzzz = USCRIPT_UNKNOWN
}
- return -2;
+ return -1;
}
private static int getOnOffValue(String s) {
private static final int getReorderCode(String keyword, String s) {
return Collator.ReorderCodes.FIRST +
getIntValue(keyword, s, "space", "punct", "symbol", "currency", "digit");
+ // Not supporting "others" = UCOL_REORDER_CODE_OTHERS
+ // as a synonym for Zzzz = USCRIPT_UNKNOWN for now:
+ // Avoid introducing synonyms/aliases.
}
/**
@Override
public void setReorderCodes(int... order) {
checkNotFrozen();
- if(order == null ?
+ int length = (order != null) ? order.length : 0;
+ if(length == 1 && order[0] == ReorderCodes.NONE) {
+ length = 0;
+ }
+ if(length == 0 ?
settings.readOnly().reorderCodes.length == 0 :
Arrays.equals(order, settings.readOnly().reorderCodes)) {
return;
}
- int length = (order != null) ? order.length : 0;
CollationSettings defaultSettings = getDefaultSettings();
if(length == 1 && order[0] == Collator.ReorderCodes.DEFAULT) {
if(settings.readOnly() != defaultSettings) {
<1 a
<1 ae
<2 ä
+
+** test: import rules from a language with non-Latin native script, and reset the reordering, ICU ticket 10998
+# Greek should sort Greek first.
+@ rules
+[import el]
+* compare
+<1 4
+<1 Ω
+<1 L
+
+# Import Greek, and then reset the reordering.
+@ rules
+[import el][reorder Zzzz]
+* compare
+<1 4
+<1 L
+<1 Ω
+
+# "others" is a synonym for Zzzz.
+@ rules
+[import el][reorder others]
+* compare
+<1 4
+<1 L
+<1 Ω
errln("ERROR: collation result should have been greater.");
}
+ /* clear the reordering using [NONE] */
+ myCollation.setReorderCodes(new int[]{ ReorderCodes.NONE });
+ retrievedReorderCodes = myCollation.getReorderCodes();
+ if (retrievedReorderCodes.length != 0) {
+ errln("ERROR: [NONE] retrieved reorder codes was not null.");
+ }
+
boolean gotException = false;
/* set duplicates in the reorder codes */
try {
String name = fileLine.substring(start, limit);
int code = CollationRuleParser.getReorderCode(name);
if (code < -1) {
- logln(fileLine);
- error = new ParseException("invalid reorder code '" + name + "' on line "
- + fileLineNumber, fileLineNumber);
- return;
+ if (name.equalsIgnoreCase("default")) {
+ code = ReorderCodes.DEFAULT; // -1
+ } else {
+ logln(fileLine);
+ error = new ParseException("invalid reorder code '" + name + "' on line "
+ + fileLineNumber, fileLineNumber);
+ return;
+ }
}
reorderCodes.addElement(code);
start = limit;