Skip to content

Commit

Permalink
CLDR-17188 Revert "CLDR-15034 DTD @match: add validity/bcp47 and semv…
Browse files Browse the repository at this point in the history
…er match types (#3109)"

This reverts commit fb4e2c9.
  • Loading branch information
srl295 committed Oct 24, 2023
1 parent 7260262 commit 8bc6a76
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 142 deletions.
6 changes: 6 additions & 0 deletions tools/cldr-code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
<groupId>com.google.myanmartools</groupId>
<artifactId>myanmar-tools</artifactId>
</dependency>

<!-- for XSD generation -->
<dependency>
<groupId>org.relaxng</groupId>
<artifactId>trang</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> lang;
private final Predicate<String> script;
Expand Down Expand Up @@ -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<Status> statuses = null;
if (slashPos > 0) {
Expand Down Expand Up @@ -602,7 +557,7 @@ public String getName() {
return "regex/" + pattern;
}

protected RegexMatchValue(String key) {
private RegexMatchValue(String key) {
pattern = Pattern.compile(key);
}

Expand All @@ -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
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,6 @@
<artifactId>jjwt-gson</artifactId>
<version>${jjwt.version}</version>
</dependency>

<!-- for semver -->
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>semver4j</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit 8bc6a76

Please sign in to comment.