From ad78cbb617c26a2f66e3942c7459c5dfddbf037a Mon Sep 17 00:00:00 2001 From: Craig Cornelius Date: Mon, 5 Aug 2024 14:49:57 -0700 Subject: [PATCH] ICU4J clear up imports and variable names in listFormat and pluralRules (#265) * Add plural rules to CPP * Add the Rust datetime fmt code * Rust datetime fmt and updates to ICU4C and NodeJS (#240) * Add plural rules to CPP * Starting ICU4X datetime fmt * DateTime format: Set default timezone explicitly * Fix formatting * Added ICU4X timezone computation - not working yet! * DateTime generator updated to ISO formatted string * DateTime updates for Node and ICU4C. * Formatted src/datetimefmt.rs * Updated using CustomTimeZone in ICU4X date time fmt * Cargo clippified * Remove unused function * Update version to ~1.3 * Clean up imports and variable names - listFormat and pluralRules --- .../listformatter/ListFormatterInputJson.java | 6 ++-- .../listformatter/ListFormatterTester.java | 35 +++++++++---------- .../pluralrules/PluralRulesInputJson.java | 2 +- .../pluralrules/PluralRulesTester.java | 24 +++++-------- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/listformatter/ListFormatterInputJson.java b/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/listformatter/ListFormatterInputJson.java index e1052fcd..b49c4b6f 100644 --- a/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/listformatter/ListFormatterInputJson.java +++ b/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/listformatter/ListFormatterInputJson.java @@ -5,16 +5,16 @@ public class ListFormatterInputJson implements ITestTypeInputJson { - public String test_type; + public String testType; public String label; public String locale; - public ListFormatterType list_type; + public ListFormatterType listType; public ListFormatterWidth style; // e.g., SHORT - public Collection input_list; + public Collection inputList; } diff --git a/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/listformatter/ListFormatterTester.java b/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/listformatter/ListFormatterTester.java index c68e18ec..d9b953ea 100644 --- a/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/listformatter/ListFormatterTester.java +++ b/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/listformatter/ListFormatterTester.java @@ -10,13 +10,10 @@ import java.util.Collection; -import java.util.HashMap; import org.unicode.conformance.ExecutorUtils; import org.unicode.conformance.testtype.ITestType; import org.unicode.conformance.testtype.ITestTypeInputJson; import org.unicode.conformance.testtype.ITestTypeOutputJson; -import org.unicode.conformance.testtype.numberformatter.NumberFormatterTestOptionKey; -import org.unicode.conformance.testtype.numberformatter.StyleVal; public class ListFormatterTester implements ITestType { @@ -29,16 +26,16 @@ public ITestTypeInputJson inputMapToJson(Map inputMapData) { result.label = (String) inputMapData.get("label", null); result.locale = (String) inputMapData.get("locale", null); - java.util.Map input_options = (java.util.Map) inputMapData.get("options", null); + java.util.Map inputOptions = (java.util.Map) inputMapData.get("options", null); - result.list_type = ListFormatterType.getFromString( - "" + input_options.get("list_type") + result.listType = ListFormatterType.getFromString( + "" + inputOptions.get("list_type") ); result.style = ListFormatterWidth.getFromString( - "" + input_options.get("style") + "" + inputOptions.get("style") ); - result.input_list = (Collection) inputMapData.get("input_list", null); + result.inputList = (Collection) inputMapData.get("input_list", null); return result; } @@ -82,32 +79,32 @@ public String formatOutputJson(ITestTypeOutputJson outputJson) { } public String getListFormatResultString(ListFormatterInputJson input) { - ListFormatter.Type list_type; - ListFormatter.Width list_width; + ListFormatter.Type listType; + ListFormatter.Width listWidth; ULocale locale = ULocale.forLanguageTag(input.locale); - switch (input.list_type) { - case DISJUNCTION: list_type = Type.OR; + switch (input.listType) { + case DISJUNCTION: listType = Type.OR; break; - case UNIT: list_type = Type.UNITS; + case UNIT: listType = Type.UNITS; break; default: - case CONJUNCTION: list_type = Type.AND; + case CONJUNCTION: listType = Type.AND; break; } switch (input.style) { - case NARROW: list_width = Width.NARROW; + case NARROW: listWidth = Width.NARROW; break; - case SHORT: list_width = Width.SHORT; + case SHORT: listWidth = Width.SHORT; break; default: - case LONG: list_width = Width.WIDE; + case LONG: listWidth = Width.WIDE; break; } - ListFormatter lf = ListFormatter.getInstance(locale, list_type, list_width); + ListFormatter lf = ListFormatter.getInstance(locale, listType, listWidth); - return lf.format(input.input_list); + return lf.format(input.inputList); } } diff --git a/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/pluralrules/PluralRulesInputJson.java b/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/pluralrules/PluralRulesInputJson.java index e8898ac0..10aae758 100644 --- a/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/pluralrules/PluralRulesInputJson.java +++ b/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/pluralrules/PluralRulesInputJson.java @@ -9,7 +9,7 @@ public class PluralRulesInputJson implements ITestTypeInputJson { public String locale; - public PluralRulesType plural_type; + public PluralRulesType pluralType; public double sample; } diff --git a/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/pluralrules/PluralRulesTester.java b/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/pluralrules/PluralRulesTester.java index cac589b2..23897816 100644 --- a/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/pluralrules/PluralRulesTester.java +++ b/executors/icu4j/74/executor-icu4j/src/main/java/org/unicode/conformance/testtype/pluralrules/PluralRulesTester.java @@ -1,21 +1,15 @@ package org.unicode.conformance.testtype.pluralrules; import com.ibm.icu.util.ULocale; -import com.ibm.icu.text.PluralRules.PluralType; import com.ibm.icu.text.PluralRules; import io.lacuna.bifurcan.IMap; import io.lacuna.bifurcan.Map; -import java.util.Collection; - -import java.util.HashMap; import org.unicode.conformance.ExecutorUtils; import org.unicode.conformance.testtype.ITestType; import org.unicode.conformance.testtype.ITestTypeInputJson; import org.unicode.conformance.testtype.ITestTypeOutputJson; -import org.unicode.conformance.testtype.pluralrules.PluralRulesInputJson; -import org.unicode.conformance.testtype.pluralrules.PluralRulesOutputJson; public class PluralRulesTester implements ITestType { @@ -28,14 +22,14 @@ public ITestTypeInputJson inputMapToJson(Map inputMapData) { result.label = (String) inputMapData.get("label", null); result.locale = (String) inputMapData.get("locale", null); - result.plural_type = PluralRulesType.getFromString( + result.pluralType = PluralRulesType.getFromString( "" + inputMapData.get("plural_type", null) ); // Consider compact number format, too. - String sample_string = (String) inputMapData.get("sample", null); + String sampleString = (String) inputMapData.get("sample", null); // Convert this to a number. - result.sample = Double.parseDouble(sample_string); + result.sample = Double.parseDouble(sampleString); return result; } @@ -78,21 +72,21 @@ public IMap convertOutputToMap(ITestTypeOutputJson outputJson) { } public String getPluralRulesResultString(PluralRulesInputJson input) { - PluralRules.PluralType plural_type; + PluralRules.PluralType pluralType; ULocale locale = ULocale.forLanguageTag(input.locale); - switch (input.plural_type) { + switch (input.pluralType) { case ORDINAL: - plural_type = PluralRules.PluralType.ORDINAL; + pluralType = PluralRules.PluralType.ORDINAL; break; default: case CARDINAL: - plural_type = PluralRules.PluralType.CARDINAL; + pluralType = PluralRules.PluralType.CARDINAL; break; } - PluralRules pl_rules = PluralRules.forLocale(locale, plural_type); + PluralRules pluralRules = PluralRules.forLocale(locale, pluralType); - return pl_rules.select(input.sample); + return pluralRules.select(input.sample); } }