diff --git a/unicodetools/src/main/java/org/unicode/text/UCA/MakeNamesChart.java b/unicodetools/src/main/java/org/unicode/text/UCA/MakeNamesChart.java index 04753950e..a42121ef8 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCA/MakeNamesChart.java +++ b/unicodetools/src/main/java/org/unicode/text/UCA/MakeNamesChart.java @@ -69,17 +69,19 @@ public static void main(String[] args) throws Exception { isWhiteSpace = new UnicodeSet(up.getSet("whitespace=Yes")); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "nameslist_index.html", + MakeNamesChart.class.getResource("nameslist_index.html").getPath(), Utility.UTF8, NAMESLIST_DIR + "index.html"); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, NAMESLIST_DIR + "charts.css"); + MakeNamesChart.class.getResource("charts.css").getPath(), + Utility.LATIN1, + NAMESLIST_DIR + "charts.css"); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "nameslist_help.html", + MakeNamesChart.class.getResource("nameslist_help.html").getPath(), Utility.UTF8, NAMESLIST_DIR + "help.html"); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "nameslist.css", + MakeNamesChart.class.getResource("nameslist.css").getPath(), Utility.LATIN1, NAMESLIST_DIR + "nameslist.css"); diff --git a/unicodetools/src/main/java/org/unicode/text/UCA/WriteCharts.java b/unicodetools/src/main/java/org/unicode/text/UCA/WriteCharts.java index 3b2fbdf32..7d0ccae5b 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCA/WriteCharts.java +++ b/unicodetools/src/main/java/org/unicode/text/UCA/WriteCharts.java @@ -107,18 +107,27 @@ public static void collationChart(UCA uca) throws IOException { final String folder = GEN_CHARTS_DIR + "collation/"; Utility.copyTextFile( - Settings.SRC_UCA_DIR + "index.html", + WriteCharts.class.getResource("index.html").getPath(), Utility.UTF8, folder + "index.html", replacement); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css", null); + WriteCharts.class.getResource("charts.css").getPath(), + Utility.LATIN1, + folder + "charts.css", + null); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "help.html", Utility.UTF8, folder + "help.html", null); + WriteCharts.class.getResource("help.html").getPath(), + Utility.UTF8, + folder + "help.html", + null); indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS); Utility.appendFile( - Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement); + WriteCharts.class.getResource("index_header.html").getPath(), + Utility.UTF8, + indexFile, + replacement); /* indexFile.println(""); @@ -319,18 +328,25 @@ public static void normalizationChart() throws IOException { // System.out.println("File: " + new File(".").getCanonicalPath()); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "index.html", + WriteCharts.class.getResource("index.html").getPath(), Utility.UTF8, folder + "index.html", replacement); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css"); + WriteCharts.class.getResource("charts.css").getPath(), + Utility.LATIN1, + folder + "charts.css"); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "norm_help.html", Utility.UTF8, folder + "help.html"); + WriteCharts.class.getResource("norm_help.html").getPath(), + Utility.UTF8, + folder + "help.html"); indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS); Utility.appendFile( - Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement); + WriteCharts.class.getResource("index_header.html").getPath(), + Utility.UTF8, + indexFile, + replacement); /* indexFile.println(""); @@ -447,18 +463,27 @@ public static void caseChart() throws IOException { final String folder = GEN_CHARTS_DIR + "case/"; Utility.copyTextFile( - Settings.SRC_UCA_DIR + "index.html", + WriteCharts.class.getResource("index.html").getPath(), Utility.UTF8, folder + "index.html", replacement); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css", null); + WriteCharts.class.getResource("charts.css").getPath(), + Utility.LATIN1, + folder + "charts.css", + null); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "case_help.html", Utility.UTF8, folder + "help.html", null); + WriteCharts.class.getResource("case_help.html").getPath(), + Utility.UTF8, + folder + "help.html", + null); indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS); Utility.appendFile( - Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement); + WriteCharts.class.getResource("index_header.html").getPath(), + Utility.UTF8, + indexFile, + replacement); /* indexFile.println(""); @@ -574,18 +599,22 @@ public static void scriptChart() throws IOException { final String folder = GEN_CHARTS_DIR + "script/"; Utility.copyTextFile( - Settings.SRC_UCA_DIR + "index.html", + WriteCharts.class.getResource("index.html").getPath(), Utility.UTF8, folder + "index.html", replacement); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css"); + WriteCharts.class.getResource("charts.css").getPath(), + Utility.LATIN1, + folder + "charts.css"); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "script_help.html", Utility.UTF8, folder + "help.html"); + WriteCharts.class.getResource("script_help.html").getPath(), + Utility.UTF8, + folder + "help.html"); indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS); Utility.appendFile( - Settings.SRC_UCA_DIR + "script_index_header.html", + WriteCharts.class.getResource("script_index_header.html").getPath(), Utility.UTF8, indexFile, replacement); @@ -724,18 +753,25 @@ public static void indexChart() throws IOException { final String folder = GEN_CHARTS_DIR + "name/"; Utility.copyTextFile( - Settings.SRC_UCA_DIR + "index.html", + WriteCharts.class.getResource("index.html").getPath(), Utility.UTF8, folder + "index.html", replacement); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "charts.css", Utility.LATIN1, folder + "charts.css"); + WriteCharts.class.getResource("charts.css").getPath(), + Utility.LATIN1, + folder + "charts.css"); Utility.copyTextFile( - Settings.SRC_UCA_DIR + "name_help.html", Utility.UTF8, folder + "help.html"); + WriteCharts.class.getResource("name_help.html").getPath(), + Utility.UTF8, + folder + "help.html"); indexFile = Utility.openPrintWriter(folder, "index_list.html", Utility.UTF8_WINDOWS); Utility.appendFile( - Settings.SRC_UCA_DIR + "index_header.html", Utility.UTF8, indexFile, replacement); + WriteCharts.class.getResource("index_header.html").getPath(), + Utility.UTF8, + indexFile, + replacement); int columnCount = 0; char lastInitial = 0; diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateCaseFolding.java b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateCaseFolding.java index 93e05b25d..5275e2159 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateCaseFolding.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateCaseFolding.java @@ -872,7 +872,11 @@ static void generateSpecialCasing(boolean normalize) throws IOException { break; case 6: Utility.appendFile( - Settings.SRC_UCD_DIR + "SpecialCasingIota.txt", Utility.UTF8, out); + GenerateCaseFolding.class + .getResource("SpecialCasingIota.txt") + .getPath(), + Utility.UTF8, + out); break; case 7: out.println( @@ -888,7 +892,10 @@ static void generateSpecialCasing(boolean normalize) throws IOException { } out.println(line); } - Utility.appendFile(Settings.SRC_UCD_DIR + "SpecialCasingFooter.txt", Utility.UTF8, out); + Utility.appendFile( + GenerateCaseFolding.class.getResource("SpecialCasingFooter.txt").getPath(), + Utility.UTF8, + out); udf.close(); // Utility.renameIdentical(mostRecent, Utility.getOutputName(newFile), batName[0]); } diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateConfusables.java b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateConfusables.java index c19e670cc..b623aac36 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateConfusables.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateConfusables.java @@ -1421,7 +1421,7 @@ public void writeSourceOrder( if (appendFile) { final String[] replacements = {"%date%", Default.getDate()}; Utility.appendFile( - Settings.SRC_UCD_DIR + "confusablesHeader.txt", + GenerateConfusables.class.getResource("confusablesHeader.txt").getPath(), Utility.UTF8_WINDOWS, out, replacements); diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateConfusablesCopy.java b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateConfusablesCopy.java index 98223af55..d6e9830fe 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateConfusablesCopy.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateConfusablesCopy.java @@ -2125,7 +2125,9 @@ public void writeSourceOrder( if (appendFile) { final String[] replacements = {"%date%", Default.getDate()}; Utility.appendFile( - Settings.SRC_UCD_DIR + "confusablesHeader.txt", + GenerateConfusablesCopy.class + .getResource("confusablesHeader.txt") + .getPath(), Utility.UTF8_WINDOWS, out, replacements); diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateNamedSequences.java b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateNamedSequences.java index acb34dd92..c947feeef 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateNamedSequences.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateNamedSequences.java @@ -160,7 +160,7 @@ public static void generate(String filename2) throws IOException { }; Utility.appendFile( - Settings.SRC_UCD_DIR + "NamedSequences-Template.html", + GenerateNamedSequences.class.getResource("NamedSequences-Template.html").getPath(), Utility.UTF8, out, replacementList); diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateStandardizedVariants.java b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateStandardizedVariants.java index 0045bc7b8..ea9d10338 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/GenerateStandardizedVariants.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/GenerateStandardizedVariants.java @@ -186,7 +186,9 @@ public static void generate() throws IOException { }; Utility.appendFile( - Settings.SRC_UCD_DIR + "StandardizedVariants-Template.html", + GenerateStandardizedVariants.class + .getResource("StandardizedVariants-Template.html") + .getPath(), Utility.UTF8, out, replacementList); diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/MakeUnicodeFiles.java b/unicodetools/src/main/java/org/unicode/text/UCD/MakeUnicodeFiles.java index 7eabf498c..579d063ee 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/MakeUnicodeFiles.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/MakeUnicodeFiles.java @@ -370,7 +370,10 @@ private void build() { try { br = Utility.openReadFile( - Settings.SRC_UCD_DIR + "MakeUnicodeFiles.txt", Utility.UTF8); + MakeUnicodeFiles.class + .getResource("MakeUnicodeFiles.txt") + .getPath(), + Utility.UTF8); String file = null, property = null, value = "", comments = ""; while (true) { String line = br.readLine(); diff --git a/unicodetools/src/main/java/org/unicode/text/UCD/UseTransliterator.java b/unicodetools/src/main/java/org/unicode/text/UCD/UseTransliterator.java index 27e1658a1..0cf56d8b7 100644 --- a/unicodetools/src/main/java/org/unicode/text/UCD/UseTransliterator.java +++ b/unicodetools/src/main/java/org/unicode/text/UCD/UseTransliterator.java @@ -6,7 +6,6 @@ import java.io.PrintWriter; import org.unicode.cldr.draft.FileUtilities; import org.unicode.cldr.util.TransliteratorUtilities; -import org.unicode.text.utility.Settings; public class UseTransliterator { public static void main(String[] args) throws IOException { @@ -15,7 +14,7 @@ public static void main(String[] args) throws IOException { final File f2 = new File("org/unicode/text/UCD/"); System.out.println(f2.getAbsolutePath()); TransliteratorUtilities.registerTransliteratorFromFile( - Settings.SRC_UCD_DIR, "any-temp"); + UseTransliterator.class.getResource("/").getPath(), "any-temp"); final Transliterator t = Transliterator.getInstance("any-temp"); final File f = new File(filename); final String fileContents = diff --git a/unicodetools/src/main/java/org/unicode/text/utility/Settings.java b/unicodetools/src/main/java/org/unicode/text/utility/Settings.java index c5b18af00..e207c63cc 100644 --- a/unicodetools/src/main/java/org/unicode/text/utility/Settings.java +++ b/unicodetools/src/main/java/org/unicode/text/utility/Settings.java @@ -317,12 +317,4 @@ public static void ensureOutputDir(String dir) { } } } - - private static final String SRC_DIR = UnicodeTools.UNICODETOOLS_RSRC_DIR + "org/unicode/text/"; - - /** Used for data files */ - public static final String SRC_UCA_DIR = SRC_DIR + "UCA/"; - - /** Used for data files */ - public static final String SRC_UCD_DIR = SRC_DIR + "UCD/"; } diff --git a/unicodetools/src/main/java/org/unicode/text/utility/UnicodeDataFile.java b/unicodetools/src/main/java/org/unicode/text/utility/UnicodeDataFile.java index 0c48dee8b..8742263e8 100644 --- a/unicodetools/src/main/java/org/unicode/text/utility/UnicodeDataFile.java +++ b/unicodetools/src/main/java/org/unicode/text/utility/UnicodeDataFile.java @@ -70,7 +70,9 @@ private UnicodeDataFile(String directory, String filename, boolean isHTML) throw } try { Utility.appendFile( - Settings.SRC_UCD_DIR + filename + "Header" + fileType, Utility.UTF8_UNIX, out); + getClass().getResource(filename + "Header" + fileType).getPath(), + Utility.UTF8_UNIX, + out); } catch (final RuntimeIOException e) { if (!(e.getCause() instanceof FileNotFoundException)) { throw e; diff --git a/unicodetools/src/test/java/org/unicode/text/UCD/TestTestUnicodeInvariants.java b/unicodetools/src/test/java/org/unicode/text/UCD/TestTestUnicodeInvariants.java index 82a0142f8..d21f50eb8 100644 --- a/unicodetools/src/test/java/org/unicode/text/UCD/TestTestUnicodeInvariants.java +++ b/unicodetools/src/test/java/org/unicode/text/UCD/TestTestUnicodeInvariants.java @@ -18,7 +18,6 @@ public class TestTestUnicodeInvariants { void testSRC_UCD_DIR() { assertAll( "assert that no components of Settings.SRC_UCD_DIR are null", - () -> assertNotNull(Settings.SRC_UCD_DIR, "Settings.SRC_UCD_DIR"), () -> assertNotNull( Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR, @@ -41,17 +40,9 @@ void testUnicodeInvariants() throws IOException { @Test void testAdditionComparisons() throws IOException { - final var directory = - new File( - Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR - + "org/unicode/text/UCD/AdditionComparisons/"); + final var directory = new File(getClass().getResource("AdditionComparisons").getPath()); if (!directory.exists()) { - throw new IOException( - "Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR=" - + Settings.UnicodeTools.UNICODETOOLS_RSRC_DIR - + ", " - + directory.getAbsolutePath() - + " does not exist"); + throw new IOException(directory.getAbsolutePath() + " does not exist"); } int rc = 0; for (var file : directory.listFiles()) {