|
9 | 9 | import com.ibm.icu.util.ULocale; |
10 | 10 | import com.ibm.icu.util.VersionInfo; |
11 | 11 | import java.text.ParsePosition; |
| 12 | +import java.util.Arrays; |
12 | 13 | import java.util.Comparator; |
13 | 14 | import java.util.List; |
14 | 15 | import java.util.regex.Pattern; |
@@ -221,15 +222,15 @@ public boolean applyPropertyAlias( |
221 | 222 | return status; |
222 | 223 | } |
223 | 224 |
|
224 | | - private static String[][] COARSE_GENERAL_CATEGORIES = { |
225 | | - {"Other", "C", "Cc", "Cf", "Cn", "Co", "Cs"}, |
226 | | - {"Letter", "L", "Ll", "Lm", "Lo", "Lt", "Lu"}, |
227 | | - {"Cased_Letter", "LC", "Ll", "Lt", "Lu"}, |
228 | | - {"Mark", "M", "Mc", "Me", "Mn"}, |
229 | | - {"Number", "N", "Nd", "Nl", "No"}, |
230 | | - {"Punctuation", "P", "Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps"}, |
231 | | - {"Symbol", "S", "Sc", "Sk", "Sm", "So"}, |
232 | | - {"Separator", "Z", "Zl", "Zp", "Zs"}, |
| 225 | + private static String[][][] COARSE_GENERAL_CATEGORIES = { |
| 226 | + {{"Other", "C"}, {"Cc", "Cf", "Cn", "Co", "Cs"}}, |
| 227 | + {{"Letter", "L"}, {"Ll", "Lm", "Lo", "Lt", "Lu"}}, |
| 228 | + {{"Cased_Letter", "LC"}, {"Ll", "Lt", "Lu"}}, |
| 229 | + {{"Mark", "M", "Combining_Mark"}, {"Mc", "Me", "Mn"}}, |
| 230 | + {{"Number", "N"}, {"Nd", "Nl", "No"}}, |
| 231 | + {{"Punctuation", "P"}, {"Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps"}}, |
| 232 | + {{"Symbol", "S"}, {"Sc", "Sk", "Sm", "So"}}, |
| 233 | + {{"Separator", "Z"}, {"Zl", "Zp", "Zs"}}, |
233 | 234 | }; |
234 | 235 |
|
235 | 236 | // TODO(eggrobin): I think this function only ever returns true; might as well make it void. |
@@ -304,13 +305,15 @@ private boolean applyPropertyAlias0( |
304 | 305 | UnicodePropertySymbolTable::parseVersionInfoOrMax)); |
305 | 306 | } else { |
306 | 307 | if (prop.getName().equals("General_Category")) { |
307 | | - for (String[] coarseValue : COARSE_GENERAL_CATEGORIES) { |
308 | | - final String longName = coarseValue[0]; |
309 | | - final String shortName = coarseValue[1]; |
310 | | - if (UnicodeProperty.equalNames(propertyValue, longName) |
311 | | - || UnicodeProperty.equalNames(propertyValue, shortName)) { |
312 | | - for (int i = 2; i < coarseValue.length; ++i) { |
313 | | - prop.getSet(coarseValue[i], result); |
| 308 | + for (String[][] coarseValue : COARSE_GENERAL_CATEGORIES) { |
| 309 | + final String[] aliases = coarseValue[0]; |
| 310 | + if (Arrays.stream(aliases) |
| 311 | + .anyMatch( |
| 312 | + a -> |
| 313 | + UnicodeProperty.equalNames( |
| 314 | + propertyValue, a))) { |
| 315 | + for (var value : coarseValue[1]) { |
| 316 | + prop.getSet(value, result); |
314 | 317 | } |
315 | 318 | return true; |
316 | 319 | } |
|
0 commit comments