Skip to content

Commit

Permalink
CLDR-16393 spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
srl295 committed Aug 31, 2023
1 parent 8e95df1 commit 1fd4f05
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import org.unicode.cldr.util.CLDRFile;
import org.unicode.cldr.util.CLDRPaths;
import org.unicode.cldr.util.SupplementalDataInfo;
Expand Down Expand Up @@ -68,7 +67,9 @@ public enum CldrVersion {
v41_0,
v42_0,
v43_0,
/** @see CLDRFile#GEN_VERSION */
/**
* @see CLDRFile#GEN_VERSION
*/
baseline;

private final String baseDirectory;
Expand Down Expand Up @@ -101,7 +102,8 @@ public static CldrVersion from(VersionInfo versionInfo) {

public static CldrVersion from(String versionString) {
// treat 'current' as baseline
if (versionString.equals(CLDRFile.GEN_VERSION) || versionString.equals(CLDRFile.GEN_VERSION + ".0")) {
if (versionString.equals(CLDRFile.GEN_VERSION)
|| versionString.equals(CLDRFile.GEN_VERSION + ".0")) {
return CldrVersion.baseline;
}
return valueOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,41 @@ public static final ElementAttributeInfo getInstance(String commonDirectory, Dtd
return eai;
}

private static void addElementAttributeInfo(Map<DtdType, ElementAttributeInfo> result, DtdType type, String path) throws IOException {
private static void addElementAttributeInfo(
Map<DtdType, ElementAttributeInfo> result, DtdType type, String path)
throws IOException {
if (!new File(path).canRead()) {
System.err.println("ElementAttributeInfo: Warning: Sample file did not exist: " + path + " for DtdType " + type.name());
System.err.println(
"ElementAttributeInfo: Warning: Sample file did not exist: "
+ path
+ " for DtdType "
+ type.name());
return; // file doesn't exist.
}
result.put(type, new ElementAttributeInfo(path, type));
}

private static Map<DtdType, ElementAttributeInfo> makeElementAttributeInfoMap(String canonicalCommonDirectory) throws IOException {
private static Map<DtdType, ElementAttributeInfo> makeElementAttributeInfoMap(
String canonicalCommonDirectory) throws IOException {
Map<DtdType, ElementAttributeInfo> result;
result = new HashMap<>();
// pick short files that are in repository
// Add to this when a DTD is added
addElementAttributeInfo(result,
DtdType.ldml,
canonicalCommonDirectory + "/main/root.xml");
addElementAttributeInfo(result,
DtdType.supplementalData,
canonicalCommonDirectory + "/supplemental/plurals.xml");
addElementAttributeInfo(result,
DtdType.ldmlBCP47,
canonicalCommonDirectory + "/bcp47/calendar.xml");
addElementAttributeInfo(result,
DtdType.keyboard,
canonicalCommonDirectory
+ "/../keyboards/3.0/fr-t-k0-azerty.xml");
addElementAttributeInfo(result,
DtdType.keyboardTest,
canonicalCommonDirectory
+ "/../keyboards/test/fr-t-k0-azerty-test.xml");
addElementAttributeInfo(result, DtdType.ldml, canonicalCommonDirectory + "/main/root.xml");
addElementAttributeInfo(
result,
DtdType.supplementalData,
canonicalCommonDirectory + "/supplemental/plurals.xml");
addElementAttributeInfo(
result, DtdType.ldmlBCP47, canonicalCommonDirectory + "/bcp47/calendar.xml");
addElementAttributeInfo(
result,
DtdType.keyboard,
canonicalCommonDirectory + "/../keyboards/3.0/fr-t-k0-azerty.xml");
addElementAttributeInfo(
result,
DtdType.keyboardTest,
canonicalCommonDirectory + "/../keyboards/test/fr-t-k0-azerty-test.xml");
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
import org.unicode.cldr.util.DtdData.Attribute;
import org.unicode.cldr.util.DtdData.Element;
import org.unicode.cldr.util.DtdData.ElementType;
import org.unicode.cldr.util.DtdType.DtdStatus;
import org.unicode.cldr.util.DtdType;
import org.unicode.cldr.util.DtdType.DtdStatus;
import org.unicode.cldr.util.ElementAttributeInfo;
import org.unicode.cldr.util.Factory;
import org.unicode.cldr.util.InputStreamFactory;
Expand Down Expand Up @@ -1007,7 +1007,9 @@ static boolean isLikelyEquivalent(String locale1, String locale2) {

static final Map<String, String> likelyData = SUPPLEMENTAL_DATA_INFO.getLikelySubtags();

private static final EnumSet<CldrVersion> badLdmlICUVersions = EnumSet.of(CldrVersion.v1_1_1, CldrVersion.v1_2, CldrVersion.v1_4_1, CldrVersion.v1_5_1);
private static final EnumSet<CldrVersion> badLdmlICUVersions =
EnumSet.of(
CldrVersion.v1_1_1, CldrVersion.v1_2, CldrVersion.v1_4_1, CldrVersion.v1_5_1);

public void TestLikelySubtagsComplete() {
LanguageTagParser ltp = new LanguageTagParser();
Expand Down Expand Up @@ -1232,7 +1234,9 @@ public void TestBasicDTDCompatibility() {
// test all DTDs
for (DtdType dtd : DtdType.values()) {
if (dtd.getStatus() != DtdType.DtdStatus.active) continue;
if (dtd.firstVersion != null && CldrVersion.LAST_RELEASE_VERSION.isOlderThan(CldrVersion.from(dtd.firstVersion))) {
if (dtd.firstVersion != null
&& CldrVersion.LAST_RELEASE_VERSION.isOlderThan(
CldrVersion.from(dtd.firstVersion))) {
continue; // DTD didn't exist in last release
}
if (dtd == DtdType.ldmlICU) continue;
Expand Down Expand Up @@ -1412,7 +1416,8 @@ public void TestDtdCompatibility() {
if (type.getStatus() != DtdStatus.active) {
continue; // not active
}
if (type.firstVersion != null && version.isOlderThan(CldrVersion.from(type.firstVersion))) {
if (type.firstVersion != null
&& version.isOlderThan(CldrVersion.from(type.firstVersion))) {
continue; // didn't exist at that point
}
DtdData dtdDataOld;
Expand All @@ -1437,8 +1442,9 @@ public void TestDtdCompatibility() {
continue;
} else {
errln(
"v" + version
+ ": "
"v"
+ version
+ ": "
+ e.getClass().getSimpleName()
+ ", "
+ e.getMessage());
Expand Down Expand Up @@ -1469,8 +1475,15 @@ public void TestDtdCompatibility() {
}
Element newChild = newElement.getChildNamed(oldChild.getName());
// skip certain items
if (version.isOlderThan(CldrVersion.v1_6_1) && newElement.getName().equals("zone") && oldChild.getName().equals("usesMetazone")) {
if (logKnownIssue("CLDR-17054", "Breakage with items older than 1.6.1: " + newElement.getName() + " / " + oldChild.getName())) {
if (version.isOlderThan(CldrVersion.v1_6_1)
&& newElement.getName().equals("zone")
&& oldChild.getName().equals("usesMetazone")) {
if (logKnownIssue(
"CLDR-17054",
"Breakage with items older than 1.6.1: "
+ newElement.getName()
+ " / "
+ oldChild.getName())) {
continue;
}
}
Expand Down

0 comments on commit 1fd4f05

Please sign in to comment.