From 7e38630c6765f2ae979df0ae6cd87604735e1858 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 12 Apr 2024 15:42:21 -0500 Subject: [PATCH] CLDR-17504 update SupplementalDataInfo reader to not use reentrant XPathParts - push XPathParts.size() API up to XPathValue.size() - use SimpleXPathParts instead of XPathParts in SupplementalDataInfo --- .../main/java/org/unicode/cldr/util/SimpleXPathParts.java | 5 +++++ .../java/org/unicode/cldr/util/SupplementalDataInfo.java | 2 +- .../src/main/java/org/unicode/cldr/util/XPathParts.java | 2 +- .../src/main/java/org/unicode/cldr/util/XPathValue.java | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/SimpleXPathParts.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/SimpleXPathParts.java index 1fcf04242d5..c06845a6e0e 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/SimpleXPathParts.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/SimpleXPathParts.java @@ -63,4 +63,9 @@ protected void handleAddAttribute(String attribute, String value) { static SimpleXPathParts getFrozenInstance(String xpath) { return new SimpleXPathParts(xpath); } + + @Override + public int size() { + return elements.size(); + } } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/SupplementalDataInfo.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/SupplementalDataInfo.java index be41ef23436..60d54dd7db3 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/SupplementalDataInfo.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/SupplementalDataInfo.java @@ -1372,7 +1372,7 @@ public void cleanup() { @Override public void handlePathValue(String path, String value) { try { - XPathParts parts = XPathParts.getFrozenInstance(path); + XPathValue parts = SimpleXPathParts.getFrozenInstance(path); String level0 = parts.getElement(0); String level1 = parts.size() < 2 ? null : parts.getElement(1); String level2 = parts.size() < 3 ? null : parts.getElement(2); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathParts.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathParts.java index 3f1b030e48f..0c7c65eb9cb 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathParts.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathParts.java @@ -381,7 +381,7 @@ public boolean containsAttributeValue(String attribute, String value) { return false; } - /** How many elements are in this xpath? */ + @Override public int size() { return elements.size(); } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathValue.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathValue.java index 86882f133d2..03eca206cfe 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathValue.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/XPathValue.java @@ -11,4 +11,7 @@ public interface XPathValue { * Returns null if there's nothing. */ String getAttributeValue(int i, String string); + + /** How many elements are in this xpath? */ + int size(); }