diff --git a/tools/cldr-code/pom.xml b/tools/cldr-code/pom.xml index 72e747ba9bb..3e049635594 100644 --- a/tools/cldr-code/pom.xml +++ b/tools/cldr-code/pom.xml @@ -56,6 +56,12 @@ com.google.myanmartools myanmar-tools + + + + org.relaxng + trang + diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/MatchValue.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/MatchValue.java index 973186181c6..6db7d62a381 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/MatchValue.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/MatchValue.java @@ -13,9 +13,6 @@ import com.ibm.icu.text.UnicodeSet.SpanCondition; import com.ibm.icu.util.ULocale; import com.ibm.icu.util.VersionInfo; -import com.vdurmont.semver4j.Semver; -import com.vdurmont.semver4j.Semver.SemverType; -import com.vdurmont.semver4j.SemverException; import java.text.ParseException; import java.util.Date; import java.util.EnumSet; @@ -82,9 +79,6 @@ public static MatchValue of(String command) { case "regex": result = RegexMatchValue.of(subargument); break; - case "semver": - result = SemverMatchValue.of(subargument); - break; case "metazone": result = MetazoneMatchValue.of(subargument); break; @@ -114,42 +108,6 @@ public static MatchValue of(String command) { } } - /** Check that a bcp47 locale ID is well-formed. Does not check validity. */ - public static class BCP47LocaleWellFormedMatchValue extends MatchValue { - static final UnicodeSet basechars = new UnicodeSet("[A-Za-z0-9_]"); - - public BCP47LocaleWellFormedMatchValue() {} - - @Override - public String getName() { - return "validity/bcp47-wellformed"; - } - - @Override - public boolean is(String item) { - if (item.equals("und")) return true; // special case because of the matcher - if (item.contains("_")) return false; // reject any underscores - try { - ULocale l = ULocale.forLanguageTag(item); - if (l == null || l.getBaseName().isEmpty()) { - return false; // failed to parse - } - - // check with lstr parser - LanguageTagParser ltp = new LanguageTagParser(); - ltp.set(item); - } catch (Throwable t) { - return false; // string failed - } - return true; - } - - @Override - public String getSample() { - return "de-u-nu-ethi"; - } - } - public static class LocaleMatchValue extends MatchValue { private final Predicate lang; private final Predicate script; @@ -325,9 +283,6 @@ public static MatchValue of(String typeName) { if (typeName.equals("locale")) { return new LocaleMatchValue(); } - if (typeName.equals("bcp47-wellformed")) { - return new BCP47LocaleWellFormedMatchValue(); - } int slashPos = typeName.indexOf('/'); Set statuses = null; if (slashPos > 0) { @@ -602,7 +557,7 @@ public String getName() { return "regex/" + pattern; } - protected RegexMatchValue(String key) { + private RegexMatchValue(String key) { pattern = Pattern.compile(key); } @@ -616,34 +571,6 @@ public boolean is(String item) { } } - public static class SemverMatchValue extends MatchValue { - @Override - public String getName() { - return "semver"; - } - - protected SemverMatchValue(String key) { - super(); - } - - public static SemverMatchValue of(String key) { - if (key != null) { - throw new IllegalArgumentException("No parameter allowed"); - } - return new SemverMatchValue(key); - } - - @Override - public boolean is(String item) { - try { - new Semver(item, SemverType.STRICT); - return true; - } catch (SemverException e) { - return false; - } - } - } - public static class VersionMatchValue extends MatchValue { @Override diff --git a/tools/cldr-code/src/test/java/org/unicode/cldr/util/TestMatchValue.java b/tools/cldr-code/src/test/java/org/unicode/cldr/util/TestMatchValue.java deleted file mode 100644 index 48dd73d4119..00000000000 --- a/tools/cldr-code/src/test/java/org/unicode/cldr/util/TestMatchValue.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.unicode.cldr.util; - -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.google.common.collect.ImmutableSet; -import org.junit.jupiter.api.Test; -import org.unicode.cldr.util.MatchValue.SemverMatchValue; -import org.unicode.cldr.util.MatchValue.ValidityMatchValue; - -public class TestMatchValue { - @Test - void TestSemverMatchValue() { - // assert that no keyword is allowed - assertThrows( - IllegalArgumentException.class, - () -> { - SemverMatchValue.of("Not Allowed"); - }); - - final SemverMatchValue m = SemverMatchValue.of(null); - - ImmutableSet is_semver = ImmutableSet.of("0.0.0", "1.0.0", "42.0.0-BETA3"); - assertAll( - "is=true", - is_semver.stream().map(v -> () -> assertTrue(m.is(v), v + ": Should be a semver"))); - - ImmutableSet not_semver = ImmutableSet.of("0.0", "v1.0", "Some Version", ""); - assertAll( - "is=true", - not_semver.stream() - .map(v -> () -> assertFalse(m.is(v), v + ": Should NOT be a semver"))); - } - - @Test - void TestBcp47MatchValue() { - // assert that no keyword is allowed - final MatchValue m = ValidityMatchValue.of("bcp47-wellformed"); - - ImmutableSet is_bcp47 = - ImmutableSet.of("und", "mt-Latn", "und-US-u-rg-ustx-tz-uschi"); - assertAll( - "is=true", - is_bcp47.stream().map(v -> () -> assertTrue(m.is(v), v + ": Should be bcp47"))); - - ImmutableSet not_bcp47 = - ImmutableSet.of( - "de_DE@PREEURO", "en_US_POSIX", "a b c", "a", "aa-BB-CCC-DDDD-EEEEE-u-u-u"); - assertAll( - "is=true", - not_bcp47.stream() - .map( - v -> - () -> - assertFalse( - m.is(v), - v + ": Should NOT be a bcp47 version"))); - } -} diff --git a/tools/pom.xml b/tools/pom.xml index a77e4951215..d4586a63c36 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -179,13 +179,6 @@ jjwt-gson ${jjwt.version} - - - - com.vdurmont - semver4j - 3.1.0 -