Skip to content

Commit

Permalink
Coarse GC
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Jan 18, 2024
1 parent 80377e3 commit 1f0e84d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeSetUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@ public boolean applyPropertyAlias(
return status;
}

private static String[][] COARSE_GENERAL_CATEGORIES = {
{"Other", "C", "Cc", "Cf", "Cn", "Co", "Cs"},
{"Letter", "L", "Ll", "Lm", "Lo", "Lt", "Lu"},
{"Cased_Letter", "LC", "Ll", "Lt", "Lu"},
{"Mark", "M", "Mc", "Me", "Mn"},
{"Number", "N", "Nd", "Nl", "No"},
{"Punctuation", "P", "Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps"},
{"Symbol", "S", "Sc", "Sk", "Sm", "So"},
{"Separator", "Z", "Zl", "Zp", "Zs"},
};

// TODO(eggrobin): I think this function only ever returns true; might as well make it void.
private boolean applyPropertyAlias0(
UnicodeProperty prop, String propertyValue, UnicodeSet result, boolean invert) {
result.clear();
Expand Down Expand Up @@ -282,6 +294,19 @@ private boolean applyPropertyAlias0(
if (isAge) {
set = prop.getSet(new ComparisonMatcher(propertyValue, Relation.geq));
} else {
if (prop.getName().equals("General_Category")) {
for (String[] coarseValue : COARSE_GENERAL_CATEGORIES) {
final String longName = coarseValue[0];
final String shortName = coarseValue[1];
if (UnicodeProperty.equalNames(propertyValue, longName)
|| UnicodeProperty.equalNames(propertyValue, shortName)) {
for (int i = 2; i < coarseValue.length; ++i) {
prop.getSet(coarseValue[i], result);
}
return true;
}
}
}
set = prop.getSet(propertyValue);
}
} else if (isAge) {
Expand Down

0 comments on commit 1f0e84d

Please sign in to comment.