Auto-formats the GWT tools projects (excluding api-checker covered in another patch) Review at http://gwt-code-reviews.appspot.com/1402803 git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10004 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/BrowserInfo.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/BrowserInfo.java index 33bbe91..63b5721 100644 --- a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/BrowserInfo.java +++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/BrowserInfo.java
@@ -45,8 +45,7 @@ userAgent = userAgent.toLowerCase(); // browser engine name - boolean isGecko = userAgent.indexOf("gecko") != -1 - && userAgent.indexOf("safari") == -1; + boolean isGecko = userAgent.indexOf("gecko") != -1 && userAgent.indexOf("safari") == -1; boolean isAppleWebKit = userAgent.indexOf("applewebkit") != -1; // browser name @@ -56,40 +55,35 @@ boolean isOpera = userAgent.indexOf("opera") != -1; boolean isIcab = userAgent.indexOf("icab") != -1; boolean isAol = userAgent.indexOf("aol") != -1; - boolean isIE = userAgent.indexOf("msie") != -1 && !isOpera - && (userAgent.indexOf("webtv") == -1); - boolean isMozilla = isGecko - && userAgent.indexOf("gecko/") + 14 == userAgent.length(); - boolean isFirefox = userAgent.indexOf("firefox/") != -1 - || userAgent.indexOf("firebird/") != -1; - boolean isNS = isGecko ? userAgent.indexOf("netscape") != -1 - : userAgent.indexOf("mozilla") != -1 && !isOpera && !isSafari - && userAgent.indexOf("spoofer") == -1 - && userAgent.indexOf("compatible") == -1 - && userAgent.indexOf("webtv") == -1 + boolean isIE = + userAgent.indexOf("msie") != -1 && !isOpera && (userAgent.indexOf("webtv") == -1); + boolean isMozilla = isGecko && userAgent.indexOf("gecko/") + 14 == userAgent.length(); + boolean isFirefox = userAgent.indexOf("firefox/") != -1 || userAgent.indexOf("firebird/") != -1; + boolean isNS = + isGecko ? userAgent.indexOf("netscape") != -1 : userAgent.indexOf("mozilla") != -1 + && !isOpera && !isSafari && userAgent.indexOf("spoofer") == -1 + && userAgent.indexOf("compatible") == -1 && userAgent.indexOf("webtv") == -1 && userAgent.indexOf("hotjava") == -1; // spoofing and compatible browsers boolean isIECompatible = userAgent.indexOf("msie") != -1 && !isIE; - boolean isNSCompatible = userAgent.indexOf("mozilla") != -1 && !isNS - && !isMozilla; + boolean isNSCompatible = userAgent.indexOf("mozilla") != -1 && !isNS && !isMozilla; // rendering engine versions - String geckoVersion = isGecko ? userAgent.substring( - userAgent.lastIndexOf("gecko/") + 6, - userAgent.lastIndexOf("gecko/") + 14) : "-1"; - String equivalentMozilla = isGecko - ? userAgent.substring(userAgent.indexOf("rv:") + 3) : "-1"; - String appleWebKitVersion = isAppleWebKit - ? userAgent.substring(userAgent.indexOf("applewebkit/") + 12) : "-1"; + String geckoVersion = + isGecko ? userAgent.substring(userAgent.lastIndexOf("gecko/") + 6, userAgent + .lastIndexOf("gecko/") + 14) : "-1"; + String equivalentMozilla = isGecko ? userAgent.substring(userAgent.indexOf("rv:") + 3) : "-1"; + String appleWebKitVersion = + isAppleWebKit ? userAgent.substring(userAgent.indexOf("applewebkit/") + 12) : "-1"; // float versionMinor = parseFloat(navigator.appVersion); String versionMinor = ""; // correct version number if (isGecko && !isMozilla) { - versionMinor = userAgent.substring(userAgent.indexOf("/", - userAgent.indexOf("gecko/") + 6) + 1); + versionMinor = + userAgent.substring(userAgent.indexOf("/", userAgent.indexOf("gecko/") + 6) + 1); } else if (isMozilla) { versionMinor = userAgent.substring(userAgent.indexOf("rv:") + 3); } else if (isIE) { @@ -118,15 +112,15 @@ // platform boolean isWin = userAgent.indexOf("win") != -1; - boolean isWin32 = isWin && userAgent.indexOf("95") != -1 - || userAgent.indexOf("98") != -1 || userAgent.indexOf("nt") != -1 - || userAgent.indexOf("win32") != -1 || userAgent.indexOf("32bit") != -1 - || userAgent.indexOf("xp") != -1; + boolean isWin32 = + isWin && userAgent.indexOf("95") != -1 || userAgent.indexOf("98") != -1 + || userAgent.indexOf("nt") != -1 || userAgent.indexOf("win32") != -1 + || userAgent.indexOf("32bit") != -1 || userAgent.indexOf("xp") != -1; boolean isMac = userAgent.indexOf("mac") != -1; - boolean isUnix = userAgent.indexOf("unix") != -1 - || userAgent.indexOf("sunos") != -1 || userAgent.indexOf("bsd") != -1 - || userAgent.indexOf("x11") != -1; + boolean isUnix = + userAgent.indexOf("unix") != -1 || userAgent.indexOf("sunos") != -1 + || userAgent.indexOf("bsd") != -1 || userAgent.indexOf("x11") != -1; boolean isLinux = userAgent.indexOf("linux") != -1; @@ -134,11 +128,11 @@ /* * this.isNS4x = (this.isNS && this.versionMajor == 4); this.isNS40x = * (this.isNS4x && this.versionMinor < 4.5); this.isNS47x = (this.isNS4x && - * this.versionMinor >= 4.7); this.isNS4up = (this.isNS && this.versionMinor >= - * 4); this.isNS6x = (this.isNS && this.versionMajor == 6); this.isNS6up = - * (this.isNS && this.versionMajor >= 6); this.isNS7x = (this.isNS && - * this.versionMajor == 7); this.isNS7up = (this.isNS && this.versionMajor >= - * 7); + * this.versionMinor >= 4.7); this.isNS4up = (this.isNS && this.versionMinor + * >= 4); this.isNS6x = (this.isNS && this.versionMajor == 6); this.isNS6up + * = (this.isNS && this.versionMajor >= 6); this.isNS7x = (this.isNS && + * this.versionMajor == 7); this.isNS7up = (this.isNS && this.versionMajor + * >= 7); * * this.isIE4x = (this.isIE && this.versionMajor == 4); this.isIE4up = * (this.isIE && this.versionMajor >= 4); this.isIE5x = (this.isIE && @@ -150,16 +144,14 @@ * this.isIE4xMac = (this.isIE4x && this.isMac); */ - String name = isGecko ? "Gecko" : isAppleWebKit ? "Apple WebKit" - : isKonqueror ? "Konqueror" : isSafari ? "Safari" : isOpera ? "Opera" - : isIE ? "IE" : isMozilla ? "Mozilla" : isFirefox ? "Firefox" - : isNS ? "Netscape" : ""; + String name = + isGecko ? "Gecko" : isAppleWebKit ? "Apple WebKit" : isKonqueror ? "Konqueror" : isSafari + ? "Safari" : isOpera ? "Opera" : isIE ? "IE" : isMozilla ? "Mozilla" : isFirefox + ? "Firefox" : isNS ? "Netscape" : ""; - name += " " - + version - + " on " - + (isWin ? "Windows" : isMac ? "Mac" : isUnix ? "Unix" : isLinux - ? "Linux" : "Unknown"); + name += + " " + version + " on " + + (isWin ? "Windows" : isMac ? "Mac" : isUnix ? "Unix" : isLinux ? "Linux" : "Unknown"); return name; }
diff --git a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportViewer.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportViewer.java index d4e2bb3..4e7c4df 100644 --- a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportViewer.java +++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportViewer.java
@@ -53,8 +53,8 @@ * running within a servlet container. * * <code>ReportViewer's</code> GWT XML module is configured to start these - * servlets by default. Just start <code>ReportViewer</code> in hosted mode, - * and GWT will run them within its own embedded servlet engine. For example, + * servlets by default. Just start <code>ReportViewer</code> in hosted mode, and + * GWT will run them within its own embedded servlet engine. For example, * * <pre>java -cp <classpath> com.google.gwt.dev.GWTShell -out * ReportViewerShell/www @@ -89,8 +89,7 @@ } } - private static final String imageServer = GWT.getModuleBaseURL() - + "test_images/"; + private static final String imageServer = GWT.getModuleBaseURL() + "test_images/"; HTML detailsLabel; @@ -137,8 +136,8 @@ reportServer.getReportSummaries(new AsyncCallback<List<ReportSummary>>() { public void onFailure(Throwable caught) { - String msg = "<p>" + caught.toString() + "</p>" - + "<p>Is your path to the reports correct?</p>"; + String msg = + "<p>" + caught.toString() + "</p>" + "<p>Is your path to the reports correct?</p>"; statusLabel.setHTML(msg); } @@ -168,8 +167,7 @@ return; } if (currentSelectedRow != -1) { - summariesTable.getRowFormatter().removeStyleName(currentSelectedRow, - "viewer-SelectedRow"); + summariesTable.getRowFormatter().removeStyleName(currentSelectedRow, "viewer-SelectedRow"); } currentToken = token; currentSelectedRow = row; @@ -197,8 +195,7 @@ tempReportTable.setWidget(0, 1, new Label("GWT Version")); if (report == null) { - tempReportTable.setWidget(1, 0, - new Label("No currently selected report.")); + tempReportTable.setWidget(1, 0, new Label("No currently selected report.")); tempReportTable.getFlexCellFormatter().setColSpan(1, 0, 3); return tempReportTable; } @@ -224,8 +221,7 @@ categoryTable.setBorderWidth(0); categoryTable.setCellPadding(5); categoryTable.setText(0, 0, c.getName()); - categoryTable.getFlexCellFormatter().setStyleName(0, 0, - "benchmark-category"); + categoryTable.getFlexCellFormatter().setStyleName(0, 0, "benchmark-category"); categoryTable.setWidget(0, 1, new Label("Description")); categoryTable.setWidget(1, 0, new Label(c.getName())); @@ -259,12 +255,10 @@ codeHtml = "<i>(source not available)</i>"; } benchmarkTable.setWidget(1, 0, new HTML(codeHtml)); - benchmarkTable.getFlexCellFormatter().setStyleName(0, 0, - "benchmark-name"); + benchmarkTable.getFlexCellFormatter().setStyleName(0, 0, "benchmark-name"); // benchmarkTable.getFlexCellFormatter().setStyleName( 0, 1, // "benchmark-description" ); - benchmarkTable.getFlexCellFormatter().setStyleName(1, 0, - "benchmark-code"); + benchmarkTable.getFlexCellFormatter().setStyleName(1, 0, "benchmark-code"); // TODO(tobyr) Provide detailed benchmark information. // Following bits of commented code are steps in that direction. @@ -326,13 +320,11 @@ // Currently only support graphs for results of 2 variables or less if (numVariables <= 2) { - resultsTable.setWidget(0, k, new Image(getImageUrl(report.getId(), - c.getName(), benchmark.getClassName(), benchmark.getName(), - result.getAgent()))); + resultsTable.setWidget(0, k, new Image(getImageUrl(report.getId(), c.getName(), + benchmark.getClassName(), benchmark.getName(), result.getAgent()))); } else { if (k == 0) { - resultsTable.setHTML(0, k, "<b>" - + BrowserInfo.getBrowser(result.getAgent()) + resultsTable.setHTML(0, k, "<b>" + BrowserInfo.getBrowser(result.getAgent()) + "</b><br><font size=\"-1\">(Graphs are not yet available " + "for benchmarks with more than two parameters)</font>"); } @@ -349,8 +341,8 @@ * HasVerticalAlignment.ALIGN_TOP); */ - resultsFormatter.setAlignment(2, k, - HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP); + resultsFormatter.setAlignment(2, k, HasHorizontalAlignment.ALIGN_LEFT, + HasVerticalAlignment.ALIGN_TOP); // A table of straight data for all trials for an agent FlexTable trialsTable = new FlexTable(); @@ -362,8 +354,7 @@ if (k == 0) { resultsTable.setWidget(1, k, visibilityButton); resultsFormatter.setColSpan(1, k, benchmark.getResults().size()); - resultsFormatter.setAlignment(1, k, - HasHorizontalAlignment.ALIGN_LEFT, + resultsFormatter.setAlignment(1, k, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE); } @@ -424,11 +415,9 @@ for (int i = 0; i < summaries.size(); ++i) { ReportSummary summary = summaries.get(i); int index = i + 1; - tempSummariesTable.setWidget(index, 0, new Hyperlink(summary.getId(), - summary.getId())); + tempSummariesTable.setWidget(index, 0, new Hyperlink(summary.getId(), summary.getId())); tempSummariesTable.setWidget(index, 1, new Label(summary.getDateString())); - tempSummariesTable.setWidget(index, 2, new Label( - String.valueOf(summary.getNumTests()))); + tempSummariesTable.setWidget(index, 2, new Label(String.valueOf(summary.getNumTests()))); } tempSummariesTable.addTableListener(new SummariesTableListener()); @@ -472,10 +461,10 @@ }); } - private String getImageUrl(String report, String category, String testClass, - String testMethod, String agent) { - return imageServer + encode(report) + "/" + encode(category) + "/" - + encode(testClass) + "/" + encode(testMethod) + "/" + encode(agent); + private String getImageUrl(String report, String category, String testClass, String testMethod, + String agent) { + return imageServer + encode(report) + "/" + encode(category) + "/" + encode(testClass) + "/" + + encode(testMethod) + "/" + encode(agent); } private void init() {
diff --git a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportDatabase.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportDatabase.java index 8d3160b..5911fa9 100644 --- a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportDatabase.java +++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportDatabase.java
@@ -171,8 +171,7 @@ } synchronized (reportsLock) { - List<ReportSummary> summaries = new ArrayList<ReportSummary>( - reports.size()); + List<ReportSummary> summaries = new ArrayList<ReportSummary>(reports.size()); for (ReportEntry entry : reports.values()) { summaries.add(entry.summary); }
diff --git a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportImageServer.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportImageServer.java index 3fbd66c..673d20c 100644 --- a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportImageServer.java +++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportImageServer.java
@@ -99,8 +99,7 @@ || e.getClass().getName().endsWith(".EofException")) { // No big deal, the client browser terminated a download. } else { - logException("An error occured while trying to create the chart.", e, - response); + logException("An error occured while trying to create the chart.", e, response); } return; } @@ -197,8 +196,9 @@ DefaultCategoryDataset data = new DefaultCategoryDataset(); data.addValue(firstTrial.getRunTimeMillis(), "result", "result"); - JFreeChart chart = ChartFactory.createBarChart(title, testName, - valueTitle, data, PlotOrientation.VERTICAL, false, false, false); + JFreeChart chart = + ChartFactory.createBarChart(title, testName, valueTitle, data, PlotOrientation.VERTICAL, + false, false, false); CategoryPlot p = chart.getCategoryPlot(); ValueAxis axis = p.getRangeAxis(); axis.setUpperBound(maxTime + maxTime * 0.1); @@ -221,8 +221,9 @@ data.addSeries(series); - JFreeChart chart = ChartFactory.createXYLineChart(title, domainVariable, - valueTitle, data, PlotOrientation.VERTICAL, false, false, false); + JFreeChart chart = + ChartFactory.createXYLineChart(title, domainVariable, valueTitle, data, + PlotOrientation.VERTICAL, false, false, false); XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setUpperBound(maxTime + maxTime * 0.1); double maxDomainValue = getMaxValue(comparativeResults, domainVariable); @@ -249,8 +250,9 @@ } // TODO(tobyr) - Handle graphs above 2 variables - JFreeChart chart = ChartFactory.createXYLineChart(title, domainVariable, - valueTitle, data, PlotOrientation.VERTICAL, true, true, false); + JFreeChart chart = + ChartFactory.createXYLineChart(title, domainVariable, valueTitle, data, + PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setUpperBound(maxTime + maxTime * 0.1); double maxDomainValue = getMaxValue(comparativeResults, domainVariable); @@ -268,8 +270,8 @@ // Code for creating a category data set - probably better with a bar chart // instead of line chart /* - * DefaultCategoryDataset data = new DefaultCategoryDataset(); String series = - * domainVariable; + * DefaultCategoryDataset data = new DefaultCategoryDataset(); String series + * = domainVariable; * * for ( Iterator it = trials.iterator(); it.hasNext(); ) { Trial trial = * (Trial) it.next(); double time = trial.getRunTimeMillis(); String @@ -312,8 +314,7 @@ return null; } - private Category getCategoryByName(List<Category> categories, - String categoryName) { + private Category getCategoryByName(List<Category> categories, String categoryName) { for (Category category : categories) { if (category.getName().equals(categoryName)) { return category; @@ -337,10 +338,10 @@ Shape square = new Rectangle2D.Double(-offset, -offset, size, size); Shape circle = new Ellipse2D.Double(-offset, -offset, size, size); - Shape triangle = new Polygon(new int[] {0, iOffset, -iOffset}, new int[] { - -iOffset, iOffset, iOffset}, 3); - Shape diamond = new Polygon(new int[] {0, iOffset, 0, -iOffset}, new int[] { - -iOffset, 0, iOffset, 0}, 4); + Shape triangle = + new Polygon(new int[] {0, iOffset, -iOffset}, new int[] {-iOffset, iOffset, iOffset}, 3); + Shape diamond = + new Polygon(new int[] {0, iOffset, 0, -iOffset}, new int[] {-iOffset, 0, iOffset, 0}, 4); Shape ellipse = new Ellipse2D.Double(-offset, -offset / 2, size, size / 2); return new DefaultDrawingSupplier(colors, @@ -377,8 +378,8 @@ return null; } - private void handleRequest(HttpServletRequest request, - HttpServletResponse response) throws IOException { + private void handleRequest(HttpServletRequest request, HttpServletResponse response) + throws IOException { String uri = request.getRequestURI(); String requestString = uri.split("test_images/")[1]; @@ -410,8 +411,7 @@ Plot plot = chart.getPlot(); plot.setDrawingSupplier(getDrawingSupplier()); - plot.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 640, 480, - new Color(200, 200, 200))); + plot.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 640, 480, new Color(200, 200, 200))); if (plot instanceof XYPlot) { XYPlot xyplot = (XYPlot) plot; @@ -429,8 +429,8 @@ // Try to fit all the graphs into a 1024 window, with a min of 240 and a max // of 480 - final int graphWidth = Math.max(240, Math.min(480, - (1024 - 10 * results.size()) / results.size())); + final int graphWidth = + Math.max(240, Math.min(480, (1024 - 10 * results.size()) / results.size())); BufferedImage img = chart.createBufferedImage(graphWidth, 240); byte[] image = EncoderUtil.encode(img, ImageFormat.PNG); @@ -444,8 +444,7 @@ output.write(image); } - private void logException(String msg, Exception e, - HttpServletResponse response) { + private void logException(String msg, Exception e, HttpServletResponse response) { ServletContext servletContext = getServletContext(); servletContext.log(msg, e); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
diff --git a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportServerImpl.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportServerImpl.java index a6bae6b..f9657d1 100644 --- a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportServerImpl.java +++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportServerImpl.java
@@ -25,8 +25,7 @@ /** * Implements the ReportServer RPC interface. */ -public class ReportServerImpl extends RemoteServiceServlet implements - ReportServer { +public class ReportServerImpl extends RemoteServiceServlet implements ReportServer { public Report getReport(String reportId) { return ReportDatabase.getInstance().getReport(reportId);
diff --git a/tools/cldr-import/src/com/google/gwt/tools/cldr/CurrencyDataProcessor.java b/tools/cldr-import/src/com/google/gwt/tools/cldr/CurrencyDataProcessor.java index c28947f..7896b89 100644 --- a/tools/cldr-import/src/com/google/gwt/tools/cldr/CurrencyDataProcessor.java +++ b/tools/cldr-import/src/com/google/gwt/tools/cldr/CurrencyDataProcessor.java
@@ -42,8 +42,7 @@ private Set<String> stillInUse = new HashSet<String>(); - public CurrencyDataProcessor(File outputDir, Factory cldrFactory, - LocaleData localeData) { + public CurrencyDataProcessor(File outputDir, Factory cldrFactory, LocaleData localeData) { super(outputDir, cldrFactory, localeData); } @@ -64,8 +63,7 @@ protected void printHeader(PrintWriter pw) { pw.println("# Do not edit - generated from Unicode CLDR data"); pw.println("#"); - pw.println("# The key is an ISO4217 currency code, and the value is of the " - + "form:"); + pw.println("# The key is an ISO4217 currency code, and the value is of the " + "form:"); pw.println("# display name|symbol|decimal digits|not-used-flag"); pw.println("# If a symbol is not supplied, the currency code will be used"); pw.println("# If # of decimal digits is omitted, 2 is used"); @@ -73,19 +71,18 @@ pw.println("# Trailing empty fields can be omitted"); pw.println(); } - + @Override protected void writeOutputFiles() throws IOException { for (GwtLocale locale : localeData.getNonEmptyLocales()) { String path = "client/impl/cldr/CurrencyData"; - PrintWriter pw = createOutputFile(path + Processor.localeSuffix(locale) - + ".properties"); + PrintWriter pw = createOutputFile(path + Processor.localeSuffix(locale) + ".properties"); printHeader(pw); Map<String, String> map = localeData.getEntries("currency", locale); String[] keys = new String[map.size()]; map.keySet().toArray(keys); Arrays.sort(keys); - + for (String key : keys) { pw.print(key); pw.print(" = "); @@ -96,15 +93,13 @@ } private void loadLocaleIndependentCurrencyData() { - CLDRFile supp = cldrFactory.make("supplementalData", true, - DraftStatus.approved); - + CLDRFile supp = cldrFactory.make("supplementalData", true, DraftStatus.approved); + // load the table of default # of decimal places for each currency currencyFractions = new HashMap<String, Integer>(); defaultCurrencyFraction = 0; XPathParts parts = new XPathParts(); - Iterator<String> iterator = supp.iterator( - "//supplementalData/currencyData/fractions/info"); + Iterator<String> iterator = supp.iterator("//supplementalData/currencyData/fractions/info"); while (iterator.hasNext()) { String path = iterator.next(); parts.set(supp.getFullXPath(path)); @@ -116,16 +111,15 @@ int digits = Integer.valueOf(attr.get("digits")); // TODO(jat): make use of the "rounding" attribute, currently only on CHF if ("DEFAULT".equalsIgnoreCase(curCode)) { - defaultCurrencyFraction = digits; + defaultCurrencyFraction = digits; } else { currencyFractions.put(curCode, digits); } } - + // find which currencies are still in use in some region, everything else // should be marked as deprecated - iterator = supp.iterator( - "//supplementalData/currencyData/region"); + iterator = supp.iterator("//supplementalData/currencyData/region"); while (iterator.hasNext()) { String path = iterator.next(); parts.set(supp.getFullXPath(path)); @@ -135,8 +129,7 @@ } String region = parts.findAttributeValue("region", "iso3166"); String curCode = attr.get("iso4217"); - if ("ZZ".equals(region) || "false".equals(attr.get("tender")) - || "XXX".equals(curCode)) { + if ("ZZ".equals(region) || "false".equals(attr.get("tender")) || "XXX".equals(curCode)) { // ZZ is an undefined region, XXX is an unknown currency code (and needs // to be special-cased because it is listed as used in Anartica!) continue;
diff --git a/tools/cldr-import/src/com/google/gwt/tools/cldr/DateTimeFormatInfoProcessor.java b/tools/cldr-import/src/com/google/gwt/tools/cldr/DateTimeFormatInfoProcessor.java index ced118f..2ca504b 100644 --- a/tools/cldr-import/src/com/google/gwt/tools/cldr/DateTimeFormatInfoProcessor.java +++ b/tools/cldr-import/src/com/google/gwt/tools/cldr/DateTimeFormatInfoProcessor.java
@@ -49,16 +49,15 @@ public class DateTimeFormatInfoProcessor extends Processor { private static final String[] DAYS = new String[] { - "sun", "mon", "tue", "wed", "thu", "fri", "sat" - }; + "sun", "mon", "tue", "wed", "thu", "fri", "sat"}; /** - * Map of skeleton format patterns and the method name suffix that uses them. + * Map of skeleton format patterns and the method name suffix that uses them. */ private static final Map<String, String> FORMATS; /** - * Index of the formats, ordered by the method name. + * Index of the formats, ordered by the method name. */ private static final SortedMap<String, String> FORMAT_BY_METHOD; @@ -112,8 +111,7 @@ private final RegionLanguageData regionLanguageData; - public DateTimeFormatInfoProcessor(File outputDir, Factory cldrFactory, - LocaleData localeData) { + public DateTimeFormatInfoProcessor(File outputDir, Factory cldrFactory, LocaleData localeData) { super(outputDir, cldrFactory, localeData); regionLanguageData = new RegionLanguageData(cldrFactory); } @@ -121,10 +119,9 @@ @Override protected void cleanupData() { System.out.println("Removing duplicates from date/time formats"); - localeData.copyLocaleData("en", "default", "era-wide", "era-abbrev", - "quarter-wide", "quarter-abbrev", "day-wide", "day-sa-wide", - "day-narrow", "day-sa-narrow", "day-abbrev", "day-sa-abbrev", - "month-wide", "month-sa-wide", "month-narrow", "month-sa-narrow", + localeData.copyLocaleData("en", "default", "era-wide", "era-abbrev", "quarter-wide", + "quarter-abbrev", "day-wide", "day-sa-wide", "day-narrow", "day-sa-narrow", "day-abbrev", + "day-sa-abbrev", "month-wide", "month-sa-wide", "month-narrow", "month-sa-narrow", "month-abbrev", "month-sa-abbrev"); removeUnusedFormats(); localeData.removeDuplicates("predef"); @@ -145,15 +142,15 @@ /** * Generate an override for a method which takes String arguments, which * simply redirect to another method based on a default value. - * + * * @param pw * @param category * @param locale * @param method * @param args */ - protected void generateArgMethod(PrintWriter pw, String category, - GwtLocale locale, String method, String... args) { + protected void generateArgMethod(PrintWriter pw, String category, GwtLocale locale, + String method, String... args) { String value = localeData.getEntry(category, locale, "default"); if (value != null && value.length() > 0) { pw.println(); @@ -167,8 +164,8 @@ prefix = ", "; } pw.println(") {"); - pw.print(" return " + method + Character.toTitleCase(value.charAt(0)) - + value.substring(1) + "("); + pw.print(" return " + method + Character.toTitleCase(value.charAt(0)) + value.substring(1) + + "("); prefix = ""; for (String arg : args) { pw.print(prefix + arg); @@ -181,7 +178,7 @@ /** * Generate an override for a method which takes String arguments. - * + * * @param pw * @param category * @param locale @@ -189,8 +186,8 @@ * @param method * @param args */ - protected void generateArgMethodRedirect(PrintWriter pw, String category, - GwtLocale locale, String key, String method, final String... args) { + protected void generateArgMethodRedirect(PrintWriter pw, String category, GwtLocale locale, + String key, String method, final String... args) { String value = localeData.getEntry(category, locale, key); if (value != null) { pw.println(); @@ -211,24 +208,22 @@ for (TemplateChunk chunk : chunks) { chunk.accept(new DefaultTemplateChunkVisitor() { @Override - public void visit(ArgumentChunk argChunk) - throws UnableToCompleteException { + public void visit(ArgumentChunk argChunk) throws UnableToCompleteException { gen.appendStringValuedExpression(args[argChunk.getArgumentNumber()]); } @Override - public void visit(StringChunk stringChunk) - throws UnableToCompleteException { + public void visit(StringChunk stringChunk) throws UnableToCompleteException { gen.appendStringLiteral(stringChunk.getString()); } }); } } catch (ParseException e) { - throw new RuntimeException("Unable to parse pattern '" + value - + "' for locale " + locale + " key " + category + "/" + key, e); + throw new RuntimeException("Unable to parse pattern '" + value + "' for locale " + locale + + " key " + category + "/" + key, e); } catch (UnableToCompleteException e) { - throw new RuntimeException("Unable to parse pattern '" + value - + "' for locale " + locale + " key " + category + "/" + key, e); + throw new RuntimeException("Unable to parse pattern '" + value + "' for locale " + locale + + " key " + category + "/" + key, e); } gen.completeString(); pw.println(" return " + buf.toString() + ";"); @@ -244,8 +239,7 @@ * @param key * @param method */ - protected void generateDayNumber(PrintWriter pw, GwtLocale locale, - String key, String method) { + protected void generateDayNumber(PrintWriter pw, GwtLocale locale, String key, String method) { String day = localeData.getEntry("weekdata", locale, key); if (day != null) { int value = getDayNumber(day); @@ -268,8 +262,8 @@ * @param skeleton * @param methodSuffix */ - protected void generateFormat(GwtLocale locale, PrintWriter pw, - String skeleton, String methodSuffix) { + protected void generateFormat(GwtLocale locale, PrintWriter pw, String skeleton, + String methodSuffix) { String pattern = localeData.getEntry("predef", locale, skeleton); generateStringValue(pw, "format" + methodSuffix, pattern); } @@ -284,14 +278,11 @@ * @param methodPrefix * @param keys */ - protected void generateFullStringList(PrintWriter pw, String group, - GwtLocale locale, String methodPrefix, String... keys) { - generateStringListPair(pw, group, locale, methodPrefix, "Full", "wide", - keys); - generateStringListPair(pw, group, locale, methodPrefix, "Narrow", "narrow", - keys); - generateStringListPair(pw, group, locale, methodPrefix, "Short", "abbrev", - keys); + protected void generateFullStringList(PrintWriter pw, String group, GwtLocale locale, + String methodPrefix, String... keys) { + generateStringListPair(pw, group, locale, methodPrefix, "Full", "wide", keys); + generateStringListPair(pw, group, locale, methodPrefix, "Narrow", "narrow", keys); + generateStringListPair(pw, group, locale, methodPrefix, "Short", "abbrev", keys); } /** @@ -301,14 +292,12 @@ * @param pw * @param methodPrefix */ - protected void generateStandaloneRedirect(PrintWriter pw, - String methodPrefix) { + protected void generateStandaloneRedirect(PrintWriter pw, String methodPrefix) { pw.println(); if (getOverrides()) { pw.println(" @Override"); } - pw.println(" public String[] " + methodPrefix - + "Standalone" + "() {"); + pw.println(" public String[] " + methodPrefix + "Standalone" + "() {"); pw.println(" return " + methodPrefix + "();"); pw.println(" }"); } @@ -324,21 +313,19 @@ * @param keys * @return true if the method was skipped as identical to its ancestor */ - protected boolean generateStringList(PrintWriter pw, String category, - String fallbackCategory, GwtLocale locale, String method, - String... keys) { + protected boolean generateStringList(PrintWriter pw, String category, String fallbackCategory, + GwtLocale locale, String method, String... keys) { Map<String, String> map = localeData.getEntries(category, locale); - Map<String, String> fallback = fallbackCategory == null ? - Collections.<String, String>emptyMap() - : localeData.getEntries(fallbackCategory, locale); - if (map == null || map.isEmpty() && fallback != null - && !fallback.isEmpty()) { + Map<String, String> fallback = + fallbackCategory == null ? Collections.<String, String> emptyMap() : localeData.getEntries( + fallbackCategory, locale); + if (map == null || map.isEmpty() && fallback != null && !fallback.isEmpty()) { return true; } if (map != null && !map.isEmpty()) { if (fallbackCategory != null) { // see if the entry is the same as the fallback - boolean different = false; + boolean different = false; for (String key : keys) { String value = map.get(key); if (value != null && !value.equals(fallback.get(key))) { @@ -363,8 +350,7 @@ value = fallback.get(key); } if (value == null) { - System.err.println("Missing \"" + key + "\" in " + locale + "/" - + category); + System.err.println("Missing \"" + key + "\" in " + locale + "/" + category); value = ""; } if (first) { @@ -380,18 +366,16 @@ return false; } - protected void generateStringListPair(PrintWriter pw, String group, - GwtLocale locale, String methodPrefix, String width, String categorySuffix, - String... keys) { - generateStringList(pw, group + "-" + categorySuffix, null, locale, - methodPrefix + width, keys); - String redirect = localeData.getEntry(group + "-sa-" + categorySuffix - + "-redirect", locale, "redirect"); + protected void generateStringListPair(PrintWriter pw, String group, GwtLocale locale, + String methodPrefix, String width, String categorySuffix, String... keys) { + generateStringList(pw, group + "-" + categorySuffix, null, locale, methodPrefix + width, keys); + String redirect = + localeData.getEntry(group + "-sa-" + categorySuffix + "-redirect", locale, "redirect"); if ("yes".equals(redirect)) { generateStandaloneRedirect(pw, methodPrefix + width); } else { - generateStringList(pw, group + "-sa-" + categorySuffix, group + "-" - + categorySuffix, locale, methodPrefix + width + "Standalone", keys); + generateStringList(pw, group + "-sa-" + categorySuffix, group + "-" + categorySuffix, locale, + methodPrefix + width + "Standalone", keys); } } @@ -409,21 +393,17 @@ // differences that don't matter. localeData.addEntries("dayPeriod-abbrev", cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/dayPeriods/" - + "dayPeriodContext[@type=\"format\"]/" - + "dayPeriodWidth[@type=\"abbreviated\"]/dayPeriod[@type=\"am\"]", - "dayPeriod", "type"); + + "dayPeriodContext[@type=\"format\"]/" + + "dayPeriodWidth[@type=\"abbreviated\"]/dayPeriod[@type=\"am\"]", "dayPeriod", "type"); localeData.addEntries("dayPeriod-abbrev", cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/dayPeriods/" - + "dayPeriodContext[@type=\"format\"]/" - + "dayPeriodWidth[@type=\"abbreviated\"]/dayPeriod[@type=\"pm\"]", - "dayPeriod", "type"); + + "dayPeriodContext[@type=\"format\"]/" + + "dayPeriodWidth[@type=\"abbreviated\"]/dayPeriod[@type=\"pm\"]", "dayPeriod", "type"); localeData.addEntries("era-abbrev", cldrFactory, - "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/eras/eraAbbr", - "era", "type"); + "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/eras/eraAbbr", "era", "type"); localeData.addEntries("era-wide", cldrFactory, - "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/eras/eraNames", - "era", "type"); + "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/eras/eraNames", "era", "type"); localeData.addDateTimeFormatEntries("date", cldrFactory); localeData.addDateTimeFormatEntries("time", cldrFactory); localeData.addDateTimeFormatEntries("dateTime", cldrFactory); @@ -460,21 +440,20 @@ pw.println("// DO NOT EDIT - GENERATED FROM CLDR AND ICU DATA"); pw.println(); if (locale.isDefault()) { - pw.println("/**"); + pw.println("/**"); pw.println(" * Default implementation of DateTimeFormatInfo interface, " - + "using values from"); + + "using values from"); pw.println(" * the CLDR root locale."); pw.println(" * <p>"); pw.println(" * Users who need to create their own DateTimeFormatInfo " - + "implementation are"); + + "implementation are"); pw.println(" * encouraged to extend this class so their implementation " - + "won't break when "); + + "won't break when "); pw.println(" * new methods are added."); pw.println(" */"); } else { - pw.println("/**"); - pw.println(" * Implementation of DateTimeFormatInfo for the \"" - + locale + "\" locale."); + pw.println("/**"); + pw.println(" * Implementation of DateTimeFormatInfo for the \"" + locale + "\" locale."); pw.println(" */"); } pw.print("public class " + myClass); @@ -491,27 +470,25 @@ pw.println(" {"); // write AM/PM names - generateStringList(pw, "dayPeriod-abbrev", null, locale, "ampms", "am", - "pm"); + generateStringList(pw, "dayPeriod-abbrev", null, locale, "ampms", "am", "pm"); // write standard date formats - generateArgMethod(pw, "date", locale, "dateFormat"); + generateArgMethod(pw, "date", locale, "dateFormat"); generateStringMethod(pw, "date", locale, "full", "dateFormatFull"); generateStringMethod(pw, "date", locale, "long", "dateFormatLong"); generateStringMethod(pw, "date", locale, "medium", "dateFormatMedium"); generateStringMethod(pw, "date", locale, "short", "dateFormatShort"); // write methods for assembling date/time formats - generateArgMethod(pw, "dateTime", locale, "dateTime", "timePattern", + generateArgMethod(pw, "dateTime", locale, "dateTime", "timePattern", "datePattern"); + generateArgMethodRedirect(pw, "dateTime", locale, "full", "dateTimeFull", "timePattern", "datePattern"); - generateArgMethodRedirect(pw, "dateTime", locale, "full", "dateTimeFull", - "timePattern", "datePattern"); - generateArgMethodRedirect(pw, "dateTime", locale, "long", "dateTimeLong", - "timePattern", "datePattern"); - generateArgMethodRedirect(pw, "dateTime", locale, "medium", - "dateTimeMedium", "timePattern", "datePattern"); - generateArgMethodRedirect(pw, "dateTime", locale, "short", - "dateTimeShort", "timePattern", "datePattern"); + generateArgMethodRedirect(pw, "dateTime", locale, "long", "dateTimeLong", "timePattern", + "datePattern"); + generateArgMethodRedirect(pw, "dateTime", locale, "medium", "dateTimeMedium", "timePattern", + "datePattern"); + generateArgMethodRedirect(pw, "dateTime", locale, "short", "dateTimeShort", "timePattern", + "datePattern"); // write era names generateStringList(pw, "era-wide", null, locale, "erasFull", "0", "1"); @@ -526,24 +503,20 @@ } // write month names - generateFullStringList(pw, "month", locale, "months", "1", "2", "3", "4", - "5", "6", "7", "8", "9", "10", "11", "12"); - + generateFullStringList(pw, "month", locale, "months", "1", "2", "3", "4", "5", "6", "7", "8", + "9", "10", "11", "12"); + // write quarter names - generateStringList(pw, "quarter-wide", null, locale, "quartersFull", "1", - "2", "3", "4"); - generateStringList(pw, "quarter-abbrev", null, locale, "quartersShort", - "1", "2", "3", "4"); - + generateStringList(pw, "quarter-wide", null, locale, "quartersFull", "1", "2", "3", "4"); + generateStringList(pw, "quarter-abbrev", null, locale, "quartersShort", "1", "2", "3", "4"); + // write standard time formats - generateArgMethod(pw, "time", locale, "timeFormat"); + generateArgMethod(pw, "time", locale, "timeFormat"); generateStringMethod(pw, "time", locale, "full", "timeFormatFull"); generateStringMethod(pw, "time", locale, "long", "timeFormatLong"); - generateStringMethod(pw, "time", locale, "medium", - "timeFormatMedium"); - generateStringMethod(pw, "time", locale, "short", - "timeFormatShort"); - + generateStringMethod(pw, "time", locale, "medium", "timeFormatMedium"); + generateStringMethod(pw, "time", locale, "short", "timeFormatShort"); + // write weekday names generateFullStringList(pw, "day", locale, "weekdays", DAYS); @@ -576,9 +549,8 @@ String cldrPattern = localeData.getEntry("predef", locale, skeleton); String pattern = dtpg.getBestPattern(skeleton); if (cldrPattern != null && !cldrPattern.equals(pattern)) { - System.err.println("Mismatch on skeleton pattern in locale " + locale - + " for skeleton '" + skeleton + "': icu='" + pattern - + "', cldr='" + cldrPattern + "'"); + System.err.println("Mismatch on skeleton pattern in locale " + locale + " for skeleton '" + + skeleton + "': icu='" + pattern + "', cldr='" + cldrPattern + "'"); } localeData.addEntry("predef", locale, skeleton, pattern); } @@ -589,14 +561,14 @@ * Load the week start and weekend range values from CLDR. */ private void loadWeekData() { - localeData.addTerritoryEntries("weekdata", cldrFactory, - regionLanguageData, "//supplementalData/weekData/firstDay", "firstDay", "day"); - localeData.addTerritoryEntries("weekdata", cldrFactory, - regionLanguageData, "//supplementalData/weekData/weekendStart", "weekendStart", "day"); - localeData.addTerritoryEntries("weekdata", cldrFactory, - regionLanguageData, "//supplementalData/weekData/weekendEnd", "weekendEnd", "day"); - localeData.addTerritoryEntries("weekdata", cldrFactory, - regionLanguageData, "//supplementalData/weekData/minDays", "minDays", "count"); + localeData.addTerritoryEntries("weekdata", cldrFactory, regionLanguageData, + "//supplementalData/weekData/firstDay", "firstDay", "day"); + localeData.addTerritoryEntries("weekdata", cldrFactory, regionLanguageData, + "//supplementalData/weekData/weekendStart", "weekendStart", "day"); + localeData.addTerritoryEntries("weekdata", cldrFactory, regionLanguageData, + "//supplementalData/weekData/weekendEnd", "weekendEnd", "day"); + localeData.addTerritoryEntries("weekdata", cldrFactory, regionLanguageData, + "//supplementalData/weekData/minDays", "minDays", "count"); } /**
diff --git a/tools/cldr-import/src/com/google/gwt/tools/cldr/GenerateGwtCldrData.java b/tools/cldr-import/src/com/google/gwt/tools/cldr/GenerateGwtCldrData.java index 41199d9..217286b 100644 --- a/tools/cldr-import/src/com/google/gwt/tools/cldr/GenerateGwtCldrData.java +++ b/tools/cldr-import/src/com/google/gwt/tools/cldr/GenerateGwtCldrData.java
@@ -43,14 +43,12 @@ private static boolean DEBUG = false; private static final Class<? extends Processor>[] PROCESSORS; - + static { - PROCESSORS = new Class[] { - CurrencyDataProcessor.class, - DateTimeFormatInfoProcessor.class, - ListFormattingProcessor.class, - LocalizedNamesProcessor.class, - }; + PROCESSORS = + new Class[] { + CurrencyDataProcessor.class, DateTimeFormatInfoProcessor.class, + ListFormattingProcessor.class, LocalizedNamesProcessor.class,}; } public static void main(String[] args) throws IOException, SecurityException, @@ -58,13 +56,11 @@ IllegalAccessException, InvocationTargetException { System.out.println("Starting to generate from CLDR data (ignore -D lines " + "produced by cldr-tools)"); - UOption[] options = { - UOption.HELP_H(), - UOption.HELP_QUESTION_MARK(), - UOption.SOURCEDIR().setDefault(CldrUtility.MAIN_DIRECTORY), // C:\cvsdata/unicode\cldr\diff\summary - outputDir().setDefault("./"), - restrictLocales(), - }; + UOption[] options = + { + UOption.HELP_H(), UOption.HELP_QUESTION_MARK(), + UOption.SOURCEDIR().setDefault(CldrUtility.MAIN_DIRECTORY), // C:\cvsdata/unicode\cldr\diff\summary + outputDir().setDefault("./"), restrictLocales(),}; UOption.parseArgs(args, options); String sourceDir = options[2].value; // SOURCEDIR String targetDir = options[3].value; // outputDir @@ -72,17 +68,17 @@ Factory cldrFactory = Factory.make(sourceDir, ".*"); Set<String> locales = cldrFactory.getAvailable(); if (DEBUG) { - locales = new HashSet<String>(Arrays.asList(new String[] { - "root", "en", "zh", "zh_Hans", "zh_Hant", "zh_CN", "zh_TW"})); + locales = + new HashSet<String>(Arrays.asList(new String[] { + "root", "en", "zh", "zh_Hans", "zh_Hant", "zh_CN", "zh_TW"})); } System.out.println("Processing " + locales.size() + " locales"); File outputDir = new File(targetDir); LocaleData localeData = new LocaleData(factory, locales); for (Class<? extends Processor> processorClass : PROCESSORS) { - Constructor<? extends Processor> ctor = processorClass.getConstructor( - File.class, Factory.class, LocaleData.class); - Processor processor = ctor.newInstance(outputDir, cldrFactory, - localeData); + Constructor<? extends Processor> ctor = + processorClass.getConstructor(File.class, Factory.class, LocaleData.class); + Processor processor = ctor.newInstance(outputDir, cldrFactory, localeData); processor.run(); } System.out.println("Finished.");
diff --git a/tools/cldr-import/src/com/google/gwt/tools/cldr/ListFormattingProcessor.java b/tools/cldr-import/src/com/google/gwt/tools/cldr/ListFormattingProcessor.java index 9713c40..a37f9ee 100644 --- a/tools/cldr-import/src/com/google/gwt/tools/cldr/ListFormattingProcessor.java +++ b/tools/cldr-import/src/com/google/gwt/tools/cldr/ListFormattingProcessor.java
@@ -29,8 +29,7 @@ */ public class ListFormattingProcessor extends Processor { - public ListFormattingProcessor(File outputDir, Factory cldrFactory, - LocaleData localeData) { + public ListFormattingProcessor(File outputDir, Factory cldrFactory, LocaleData localeData) { super(outputDir, cldrFactory, localeData); } @@ -42,19 +41,17 @@ @Override protected void loadData() throws IOException { System.out.println("Loading data for list formatting"); - localeData.addEntries("list", cldrFactory, - "//ldml/listPatterns/listPattern", "listPatternPart", "type"); + localeData.addEntries("list", cldrFactory, "//ldml/listPatterns/listPattern", + "listPatternPart", "type"); } @Override protected void writeOutputFiles() throws IOException { for (GwtLocale locale : localeData.getNonEmptyLocales("list")) { PrintWriter pw = null; - for (Map.Entry<String, String> entry : localeData.getEntries("list", - locale).entrySet()) { + for (Map.Entry<String, String> entry : localeData.getEntries("list", locale).entrySet()) { if (pw == null) { - pw = createOutputFile("rebind/cldr/ListPatterns_" - + locale.getAsString() + ".properties"); + pw = createOutputFile("rebind/cldr/ListPatterns_" + locale.getAsString() + ".properties"); } pw.println(entry.getKey() + "=" + entry.getValue()); }
diff --git a/tools/cldr-import/src/com/google/gwt/tools/cldr/LocaleData.java b/tools/cldr-import/src/com/google/gwt/tools/cldr/LocaleData.java index a90262f..7fedd06 100644 --- a/tools/cldr-import/src/com/google/gwt/tools/cldr/LocaleData.java +++ b/tools/cldr-import/src/com/google/gwt/tools/cldr/LocaleData.java
@@ -83,10 +83,8 @@ return false; } Currency other = (Currency) obj; - return code.equals(other.code) - && equalsNullCheck(displayName, other.displayName) - && equalsNullCheck(symbol, other.symbol) - && equalsNullCheck(pattern, other.pattern) + return code.equals(other.code) && equalsNullCheck(displayName, other.displayName) + && equalsNullCheck(symbol, other.symbol) && equalsNullCheck(pattern, other.pattern) && equalsNullCheck(decimalSeparator, other.decimalSeparator) && equalsNullCheck(groupingSeparator, other.groupingSeparator) && decimalDigits == other.decimalDigits && inUse == other.inUse; @@ -126,11 +124,9 @@ @Override public int hashCode() { - return code.hashCode() + 17 * hashCodeNullCheck(displayName) + 19 - * hashCodeNullCheck(symbol) + 23 * hashCodeNullCheck(pattern) + 29 - * hashCodeNullCheck(decimalSeparator) + 31 - * hashCodeNullCheck(groupingSeparator) + 37 * decimalDigits - + (inUse ? 41 : 0); + return code.hashCode() + 17 * hashCodeNullCheck(displayName) + 19 * hashCodeNullCheck(symbol) + + 23 * hashCodeNullCheck(pattern) + 29 * hashCodeNullCheck(decimalSeparator) + 31 + * hashCodeNullCheck(groupingSeparator) + 37 * decimalDigits + (inUse ? 41 : 0); } /** @@ -247,7 +243,7 @@ } public MapKey inNewLocale(GwtLocale newLocale) { - return new MapKey(category, newLocale); + return new MapKey(category, newLocale); } @Override @@ -265,17 +261,16 @@ public static String getCldrLocale(GwtLocale locale) { return locale.isDefault() ? "root" : locale.toString(); } - + /** * Get the value of a given category of territory data inherited by a locale. * * @param locale the locale to search for * @param map the map containing territory=>value data * @return the requested value from the closest ancestor of the specified - * locale, or null if not found + * locale, or null if not found */ - private static String getTerritoryData(GwtLocale locale, - Map<String, String> map) { + private static String getTerritoryData(GwtLocale locale, Map<String, String> map) { if (map == null) { return null; } @@ -291,13 +286,13 @@ } return null; } - + private final Map<GwtLocale, String> allLocales; private final GwtLocale defaultLocale; private final HashMap<GwtLocale, GwtLocale> inheritsFrom; - + private final Map<GwtLocale, Integer> localeDepth; private final GwtLocaleFactory localeFactory; @@ -310,8 +305,7 @@ * @param localeFactory * @param localeNames */ - public LocaleData(GwtLocaleFactory localeFactory, - Collection<String> localeNames) { + public LocaleData(GwtLocaleFactory localeFactory, Collection<String> localeNames) { this.localeFactory = localeFactory; defaultLocale = localeFactory.getDefault(); allLocales = new HashMap<GwtLocale, String>(); @@ -336,9 +330,8 @@ * @param key * @param attribute */ - public void addAttributeEntry(String category, GwtLocale locale, - Factory cldrFactory, String path, String tag, String key, - String attribute) { + public void addAttributeEntry(String category, GwtLocale locale, Factory cldrFactory, + String path, String tag, String key, String attribute) { Map<String, String> map = getMap(category, locale); CLDRFile cldr = cldrFactory.make(allLocales.get(locale), true); XPathParts parts = new XPathParts(); @@ -357,46 +350,44 @@ * @param category * @param cldrFactory * @param currencyFractions map of currency fraction data extracted from - * locale-independent data + * locale-independent data * @param defaultCurrencyFraction * @param stillInUse */ public void addCurrencyEntries(String category, Factory cldrFactory, - Map<String, Integer> currencyFractions, int defaultCurrencyFraction, - Set<String> stillInUse) { + Map<String, Integer> currencyFractions, int defaultCurrencyFraction, Set<String> stillInUse) { for (GwtLocale locale : allLocales.keySet()) { // skip the "default" locale for now if (locale.isDefault()) { continue; } - addCurrencyEntries(category, locale, cldrFactory, currencyFractions, - defaultCurrencyFraction, stillInUse); + addCurrencyEntries(category, locale, cldrFactory, currencyFractions, defaultCurrencyFraction, + stillInUse); } // run the "default" locale last, to override inherited entries GwtLocale locale = localeFactory.getDefault(); - addCurrencyEntries(category, locale, cldrFactory, currencyFractions, - defaultCurrencyFraction, stillInUse); + addCurrencyEntries(category, locale, cldrFactory, currencyFractions, defaultCurrencyFraction, + stillInUse); } public void addDateTimeFormatEntries(String group, Factory cldrFactory) { - addAttributeEntries(group, cldrFactory, - "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + group - + "Formats/default", "default", "default", "choice"); + addAttributeEntries(group, cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + + group + "Formats/default", "default", "default", "choice"); addDateTimeFormatEntries(group, "full", cldrFactory); addDateTimeFormatEntries(group, "long", cldrFactory); addDateTimeFormatEntries(group, "medium", cldrFactory); addDateTimeFormatEntries(group, "short", cldrFactory); } - public void addEntries(String category, Factory cldrFactory, String prefix, - String tag, String keyAttribute) { + public void addEntries(String category, Factory cldrFactory, String prefix, String tag, + String keyAttribute) { for (GwtLocale locale : allLocales.keySet()) { addEntries(category, locale, cldrFactory, prefix, tag, keyAttribute); } } - public void addEntries(String category, GwtLocale locale, Factory cldrFactory, - String prefix, String tag, String keyAttribute) { + public void addEntries(String category, GwtLocale locale, Factory cldrFactory, String prefix, + String tag, String keyAttribute) { Map<String, String> map = getMap(category, locale); CLDRFile cldr = cldrFactory.make(allLocales.get(locale), true); XPathParts parts = new XPathParts(); @@ -425,35 +416,37 @@ } } - public void addEntry(String category, GwtLocale locale, String key, - String value) { + public void addEntry(String category, GwtLocale locale, String key, String value) { Map<String, String> map = getMap(category, locale); map.put(key, value); } /** - * @param period "month", "day", "quarter", "dayPeriod", + * @param period "month", "day", "quarter", "dayPeriod", * @param cldrFactory */ public void addNameEntries(String period, Factory cldrFactory) { - addEntries(period + "-abbrev", cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period - + "s/" + period + "Context[@type=\"format\"]/" + period - + "Width[@type=\"abbreviated\"]", period, "type"); - addEntries(period + "-narrow", cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period - + "s/" + period + "Context[@type=\"format\"]/" + period - + "Width[@type=\"narrow\"]", period, "type"); - addEntries(period + "-wide", cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period - + "s/" + period + "Context[@type=\"format\"]/" + period - + "Width[@type=\"wide\"]", period, "type"); - addEntries(period + "-sa-abbrev", cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period - + "s/" + period + "Context[@type=\"stand-alone\"]/" + period - + "Width[@type=\"abbreviated\"]", period, "type"); - addEntries(period + "-sa-narrow", cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period - + "s/" + period + "Context[@type=\"stand-alone\"]/" + period - + "Width[@type=\"narrow\"]", period, "type"); - addEntries(period + "-sa-wide", cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period - + "s/" + period + "Context[@type=\"stand-alone\"]/" + period - + "Width[@type=\"wide\"]", period, "type"); + addEntries(period + "-abbrev", cldrFactory, + "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period + "s/" + period + + "Context[@type=\"format\"]/" + period + "Width[@type=\"abbreviated\"]", period, + "type"); + addEntries(period + "-narrow", cldrFactory, + "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period + "s/" + period + + "Context[@type=\"format\"]/" + period + "Width[@type=\"narrow\"]", period, "type"); + addEntries(period + "-wide", cldrFactory, + "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period + "s/" + period + + "Context[@type=\"format\"]/" + period + "Width[@type=\"wide\"]", period, "type"); + addEntries(period + "-sa-abbrev", cldrFactory, + "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period + "s/" + period + + "Context[@type=\"stand-alone\"]/" + period + "Width[@type=\"abbreviated\"]", period, + "type"); + addEntries(period + "-sa-narrow", cldrFactory, + "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period + "s/" + period + + "Context[@type=\"stand-alone\"]/" + period + "Width[@type=\"narrow\"]", period, + "type"); + addEntries(period + "-sa-wide", cldrFactory, + "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + period + "s/" + period + + "Context[@type=\"stand-alone\"]/" + period + "Width[@type=\"wide\"]", period, "type"); } /** @@ -467,8 +460,7 @@ * @param keyAttribute the attribute in the tag to use as the key */ public void addTerritoryEntries(String category, Factory cldrFactory, - RegionLanguageData regionLanguageData, String prefix, String tag, - String keyAttribute) { + RegionLanguageData regionLanguageData, String prefix, String tag, String keyAttribute) { CLDRFile supp = cldrFactory.make("supplementalData", true); Map<String, String> map = new HashMap<String, String>(); XPathParts parts = new XPathParts(); @@ -500,11 +492,9 @@ } String language = locale.getAsString(); Map<String, Double> langMap = new HashMap<String, Double>(); - for (RegionLanguageData.RegionPopulation langData - : regionLanguageData.getRegions(language)) { + for (RegionLanguageData.RegionPopulation langData : regionLanguageData.getRegions(language)) { String region = langData.getRegion(); - GwtLocale regionLocale = localeFactory.fromString(language + "_" - + region); + GwtLocale regionLocale = localeFactory.fromString(language + "_" + region); String day = getTerritoryData(regionLocale, map); if (day != null) { Double pop = langMap.get(day); @@ -549,15 +539,14 @@ * @param baseCategory * @param standaloneCategory */ - public void computeRedirects(String baseCategory, - String standaloneCategory) { + public void computeRedirects(String baseCategory, String standaloneCategory) { for (GwtLocale locale : allLocales.keySet()) { MapKey baseKey = new MapKey(baseCategory, locale); MapKey standaloneKey = new MapKey(standaloneCategory, locale); Map<String, String> baseMap = maps.get(baseKey); Map<String, String> standaloneMap = maps.get(standaloneKey); - if (baseMap != null && standaloneMap != null && (standaloneMap.isEmpty() - || baseMap.equals(standaloneMap))) { + if (baseMap != null && standaloneMap != null + && (standaloneMap.isEmpty() || baseMap.equals(standaloneMap))) { addEntry(standaloneCategory + "-redirect", locale, "redirect", "yes"); } } @@ -570,8 +559,7 @@ * @param destLocaleName destination locale name * @param categories list of categories to copy */ - public void copyLocaleData(String srcLocaleName, String destLocaleName, - String... categories) { + public void copyLocaleData(String srcLocaleName, String destLocaleName, String... categories) { GwtLocale src = localeFactory.fromString(srcLocaleName); GwtLocale dest = localeFactory.fromString(destLocaleName); for (String category : categories) { @@ -590,8 +578,7 @@ for (Map.Entry<MapKey, Map<String, String>> entry : maps.entrySet()) { Map<String, String> map = entry.getValue(); if (entry.getKey().getLocale().equals(locale) && !map.isEmpty()) { - result.put(entry.getKey().getCategory(), - Collections.unmodifiableMap(entry.getValue())); + result.put(entry.getKey().getCategory(), Collections.unmodifiableMap(entry.getValue())); } } return result; @@ -642,8 +629,8 @@ * @return GwtLocale instance for CLDR locale */ public GwtLocale getGwtLocale(String localeName) { - return "root".equals(localeName) ? localeFactory.getDefault() - : localeFactory.fromString(localeName); + return "root".equals(localeName) ? localeFactory.getDefault() : localeFactory + .fromString(localeName); } /** @@ -663,14 +650,14 @@ /** * @return all locales that have some data associated with them in the - * specified category. + * specified category. */ public Set<GwtLocale> getNonEmptyLocales(String category) { Set<GwtLocale> result = new HashSet<GwtLocale>(); for (Map.Entry<MapKey, Map<String, String>> entry : maps.entrySet()) { Map<String, String> map = entry.getValue(); if (!category.equals(entry.getKey().category) || map.isEmpty()) { - continue; + continue; } result.add(entry.getKey().getLocale()); } @@ -680,12 +667,12 @@ /** * Return the nearest ancestor locale of the supplied locale which has any * values present. - * + * * @param locale * @return GwtLocale of nearest ancestor */ public GwtLocale inheritsFrom(GwtLocale locale) { - GwtLocale parent = inheritsFrom.get(locale); + GwtLocale parent = inheritsFrom.get(locale); while (parent != null && parent != defaultLocale) { for (Map.Entry<MapKey, Map<String, String>> entry : maps.entrySet()) { if (entry.getKey().getLocale().equals(parent)) { @@ -703,17 +690,17 @@ /** * Return the nearest ancestor locale of the supplied locale which has any * values present in the specified category. - * + * * @param category * @param locale * @return GwtLocale of nearest ancestor with the specified category */ public GwtLocale inheritsFrom(String category, GwtLocale locale) { - GwtLocale parent = inheritsFrom.get(locale); + GwtLocale parent = inheritsFrom.get(locale); while (parent != null && parent != defaultLocale) { Map<String, String> map = getMap(category, parent); if (!map.isEmpty()) { - return parent; + return parent; } parent = inheritsFrom.get(parent); } @@ -729,7 +716,7 @@ /** * Remove locale entries that completely duplicate their parent. - * + * * @param matchCategory */ public void removeCompleteDuplicates(String matchCategory) { @@ -772,7 +759,7 @@ /** * Remove entries that are duplicates of the entries in the parent locale. - * + * * @param matchCategory */ public void removeDuplicates(String matchCategory) { @@ -805,15 +792,14 @@ } /** - * Remove entries in the specified category and locale which match any of - * the supplied keys. + * Remove entries in the specified category and locale which match any of the + * supplied keys. * * @param category * @param locale * @param keys */ - public void removeEntries(String category, GwtLocale locale, - Collection<String> keys) { + public void removeEntries(String category, GwtLocale locale, Collection<String> keys) { Map<String, String> map = getMap(category, locale); map.keySet().removeAll(keys); } @@ -837,31 +823,29 @@ maps.clear(); } - private void addAttributeEntries(String category, Factory cldrFactory, - String prefix, String tag, String key, String attribute) { + private void addAttributeEntries(String category, Factory cldrFactory, String prefix, String tag, + String key, String attribute) { for (GwtLocale locale : allLocales.keySet()) { - addAttributeEntry(category, locale, cldrFactory, prefix, tag, key, - attribute); + addAttributeEntry(category, locale, cldrFactory, prefix, tag, key, attribute); } } /** - * Add currency entries for the specified locale. If this locale is not the + * Add currency entries for the specified locale. If this locale is not the * default locale, also add default entries into the default locale to make - * sure it has entries for any currency present in any locale. Note that - * this means that the default locale must be processed last. + * sure it has entries for any currency present in any locale. Note that this + * means that the default locale must be processed last. * * @param category * @param locale * @param cldrFactory * @param currencyFractions map of currency fraction data extracted from - * locale-independent data + * locale-independent data * @param defaultCurrencyFraction * @param stillInUse */ - private void addCurrencyEntries(String category, GwtLocale locale, - Factory cldrFactory, Map<String, Integer> currencyFractions, - int defaultCurrencyFraction, Set<String> stillInUse) { + private void addCurrencyEntries(String category, GwtLocale locale, Factory cldrFactory, + Map<String, Integer> currencyFractions, int defaultCurrencyFraction, Set<String> stillInUse) { Map<String, String> outputMap = getMap(category, locale); Map<String, String> defaultMap = null; if (!locale.isDefault()) { @@ -870,8 +854,7 @@ Map<String, Currency> tempMap = new HashMap<String, Currency>(); CLDRFile cldr = cldrFactory.make(allLocales.get(locale), true); XPathParts parts = new XPathParts(); - Iterator<String> iterator = cldr.iterator( - "//ldml/numbers/currencies"); + Iterator<String> iterator = cldr.iterator("//ldml/numbers/currencies"); while (iterator.hasNext()) { String path = iterator.next(); path = cldr.getFullXPath(path); @@ -917,8 +900,8 @@ } else if ("group".equalsIgnoreCase(field)) { currency.setGroupingSeparator(value); } else { - System.err.println("Ignoring unknown field \"" + field - + "\" on currency data for \"" + currencyCode + "\""); + System.err.println("Ignoring unknown field \"" + field + "\" on currency data for \"" + + currencyCode + "\""); } } for (Currency currency : tempMap.values()) { @@ -933,13 +916,11 @@ } } - private void addDateTimeFormatEntries(String group, String length, - Factory cldrFactory) { - addEntries(group, cldrFactory, - "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + group - + "Formats/" + group + "FormatLength" - + "[@type=\"" + length + "\"]/" + group + "Format[@type=\"standard\"]" - + "/pattern[@type=\"standard\"]", group + "FormatLength", "type"); + private void addDateTimeFormatEntries(String group, String length, Factory cldrFactory) { + addEntries(group, cldrFactory, "//ldml/dates/calendars/calendar[@type=\"gregorian\"]/" + group + + "Formats/" + group + "FormatLength" + "[@type=\"" + length + "\"]/" + group + + "Format[@type=\"standard\"]" + "/pattern[@type=\"standard\"]", group + "FormatLength", + "type"); } private void buildInheritsFrom() { @@ -983,7 +964,7 @@ * * @param currency * @return a string containing the property file entry for the specified - * currency + * currency */ private String encodeCurrencyData(Currency currency) { StringBuilder buf = new StringBuilder(); @@ -1016,7 +997,8 @@ /** * Get a map for a given class/locale combination. - * @param category + * + * @param category * @param locale * * @return map for the specified class/locale @@ -1039,7 +1021,7 @@ MapKey[] keys = keySet.toArray(new MapKey[keySet.size()]); Arrays.sort(keys, new Comparator<MapKey>() { private final Comparator<GwtLocale> depthComparator = new LocaleComparator(); - + public int compare(MapKey a, MapKey b) { return depthComparator.compare(a.getLocale(), b.getLocale()); }
diff --git a/tools/cldr-import/src/com/google/gwt/tools/cldr/LocalizedNamesProcessor.java b/tools/cldr-import/src/com/google/gwt/tools/cldr/LocalizedNamesProcessor.java index dc5a3e0..02ee2b7 100644 --- a/tools/cldr-import/src/com/google/gwt/tools/cldr/LocalizedNamesProcessor.java +++ b/tools/cldr-import/src/com/google/gwt/tools/cldr/LocalizedNamesProcessor.java
@@ -42,7 +42,7 @@ private final int index; private final CollationKey key; - + public IndexedName(Collator collator, int index, String value) { this.index = index; this.key = collator.getCollationKey(value); @@ -76,16 +76,14 @@ private final RegionLanguageData regionLanguageData; - public LocalizedNamesProcessor(File outputDir, Factory cldrFactory, - LocaleData localeData) { + public LocalizedNamesProcessor(File outputDir, Factory cldrFactory, LocaleData localeData) { super(outputDir, cldrFactory, localeData); regionLanguageData = new RegionLanguageData(cldrFactory); } @Override protected void cleanupData() { - localeData.copyLocaleData("en", "default", "territory", "languages", - "scripts", "variants"); + localeData.copyLocaleData("en", "default", "territory", "languages", "scripts", "variants"); // Generate a sort order before removing duplicates for (GwtLocale locale : localeData.getNonEmptyLocales("territory")) { // TODO(jat): deal with language population data that has a script @@ -97,9 +95,9 @@ countryCodes.add(regionCode); } } - Locale javaLocale = new Locale( - locale.getLanguageNotNull(), locale.getRegionNotNull(), - locale.getVariantNotNull()); + Locale javaLocale = + new Locale(locale.getLanguageNotNull(), locale.getRegionNotNull(), locale + .getVariantNotNull()); Collator collator = Collator.getInstance(javaLocale); IndexedName[] names = new IndexedName[countryCodes.size()]; for (int i = 0; i < names.length; ++i) { @@ -146,19 +144,18 @@ @Override protected void loadData() throws IOException { System.out.println("Loading data for localized names"); - localeData.addEntries("territory", cldrFactory, - "//ldml/localeDisplayNames/territories", "territory", "type"); - localeData.addEntries("language", cldrFactory, - "//ldml/localeDisplayNames/languages", "language", "type"); - localeData.addEntries("script", cldrFactory, - "//ldml/localeDisplayNames/scripts", "script", "type"); - localeData.addEntries("variant", cldrFactory, - "//ldml/localeDisplayNames/variants", "variant", "type"); - localeData.addEntries("localePattern", cldrFactory, - "//ldml/localeDisplayNames/localePattern", "localePattern", "unused"); + localeData.addEntries("territory", cldrFactory, "//ldml/localeDisplayNames/territories", + "territory", "type"); + localeData.addEntries("language", cldrFactory, "//ldml/localeDisplayNames/languages", + "language", "type"); + localeData.addEntries("script", cldrFactory, "//ldml/localeDisplayNames/scripts", "script", + "type"); + localeData.addEntries("variant", cldrFactory, "//ldml/localeDisplayNames/variants", "variant", + "type"); + localeData.addEntries("localePattern", cldrFactory, "//ldml/localeDisplayNames/localePattern", + "localePattern", "unused"); localeData.addEntries("localeSeparator", cldrFactory, - "//ldml/localeDisplayNames/localeSeparator", "localeSeparator", - "unused"); + "//ldml/localeDisplayNames/localeSeparator", "localeSeparator", "unused"); } @Override @@ -174,31 +171,28 @@ } String[] sortOrder = getRegionOrder(namesMap.get("!sortorder")); String[] likelyOrder = getRegionOrder(namesMap.get("!likelyorder")); - if (regionCodesWithNames.isEmpty() && sortOrder == null - && likelyOrder == null) { + if (regionCodesWithNames.isEmpty() && sortOrder == null && likelyOrder == null) { // nothing to do return; } // sort for deterministic output Collections.sort(regionCodesWithNames); if (locale.isDefault()) { - generateDefaultLocale(namesMap, regionCodesWithNames, sortOrder, - likelyOrder); + generateDefaultLocale(namesMap, regionCodesWithNames, sortOrder, likelyOrder); } - generateLocale(locale, namesMap, regionCodesWithNames, sortOrder, - likelyOrder); + generateLocale(locale, namesMap, regionCodesWithNames, sortOrder, likelyOrder); } } /** - * @param namesMap - * @param regionCodesWithNames - * @param sortOrder - * @param likelyOrder + * @param namesMap + * @param regionCodesWithNames + * @param sortOrder + * @param likelyOrder */ private void generateDefaultLocale(Map<String, String> namesMap, - List<String> regionCodesWithNames, String[] sortOrder, - String[] likelyOrder) throws IOException { + List<String> regionCodesWithNames, String[] sortOrder, String[] likelyOrder) + throws IOException { PrintWriter pw = null; try { pw = createOutputFile("client/DefaultLocalizedNames.java"); @@ -207,11 +201,10 @@ pw.println(); pw.println("// DO NOT EDIT - GENERATED FROM CLDR DATA"); pw.println(); - pw.println("/**"); - pw.println(" * Default LocalizedNames implementation."); + pw.println("/**"); + pw.println(" * Default LocalizedNames implementation."); pw.println(" */"); - pw.print("public class DefaultLocalizedNames extends " - + "DefaultLocalizedNamesBase {"); + pw.print("public class DefaultLocalizedNames extends " + "DefaultLocalizedNamesBase {"); if (likelyOrder != null) { writeStringListMethod(pw, "loadLikelyRegionCodes", likelyOrder); } @@ -222,8 +215,7 @@ for (String code : regionCodesWithNames) { String name = namesMap.get(code); if (name != null) { - pw.println(" namesMap.put(\"" + quote(code) + "\", \"" - + quote(name) + "\");"); + pw.println(" namesMap.put(\"" + quote(code) + "\", \"" + quote(name) + "\");"); } } pw.println(" }"); @@ -240,14 +232,14 @@ /** * @param locale - * @param likelyOrder - * @param sortOrder - * @param regionCodesWithNames - * @param namesMap + * @param likelyOrder + * @param sortOrder + * @param regionCodesWithNames + * @param namesMap */ private void generateLocale(GwtLocale locale, Map<String, String> namesMap, - List<String> regionCodesWithNames, String[] sortOrder, - String[] likelyOrder) throws IOException { + List<String> regionCodesWithNames, String[] sortOrder, String[] likelyOrder) + throws IOException { PrintWriter pw = null; try { pw = createFile("LocalizedNamesImpl", "java", locale.getAsString()); @@ -260,16 +252,14 @@ } pw.println("// DO NOT EDIT - GENERATED FROM CLDR DATA"); pw.println(); - pw.println("/**"); - pw.println(" * Localized names for the \"" + locale + "\" locale."); + pw.println("/**"); + pw.println(" * Localized names for the \"" + locale + "\" locale."); pw.println(" */"); - pw.print("public class LocalizedNamesImpl" + localeSuffix(locale) - + " extends "); + pw.print("public class LocalizedNamesImpl" + localeSuffix(locale) + " extends "); if (locale.isDefault()) { pw.print("LocalizedNamesImplBase"); } else { - pw.print("LocalizedNamesImpl" + localeSuffix(localeData.inheritsFrom( - locale))); + pw.print("LocalizedNamesImpl" + localeSuffix(localeData.inheritsFrom(locale))); } pw.println(" {"); if (!locale.isDefault()) { @@ -287,16 +277,14 @@ for (String code : regionCodesWithNames) { String name = namesMap.get(code); if (name != null && !name.equals(code)) { - pw.println(" namesMap.put(\"" + quote(code) + "\", \"" - + quote(name) + "\");"); + pw.println(" namesMap.put(\"" + quote(code) + "\", \"" + quote(name) + "\");"); } } pw.println(" }"); pw.println(); pw.println(" @Override"); pw.println(" protected JavaScriptObject loadNameMapNative() {"); - pw.println(" return overrideMap(super.loadNameMapNative(), " - + "loadMyNameMap());"); + pw.println(" return overrideMap(super.loadNameMapNative(), " + "loadMyNameMap());"); pw.println(" }"); pw.println(); pw.println(" private native JavaScriptObject loadMyNameMap() /*-{"); @@ -306,8 +294,7 @@ } else if (!regionCodesWithNames.isEmpty()) { pw.println(); pw.println(" @Override"); - pw.println(" protected native JavaScriptObject loadNameMapNative() " - + "/*-{"); + pw.println(" protected native JavaScriptObject loadNameMapNative() " + "/*-{"); generateNativeMap(pw, regionCodesWithNames, namesMap); pw.println(" }-*/;"); } @@ -323,8 +310,8 @@ * @param regionCodesWithNames * @param namesMap */ - private void generateNativeMap(PrintWriter pw, - List<String> regionCodesWithNames, Map<String, String> namesMap) { + private void generateNativeMap(PrintWriter pw, List<String> regionCodesWithNames, + Map<String, String> namesMap) { pw.println(" return {"); boolean firstLine = true; for (String code : regionCodesWithNames) { @@ -347,8 +334,9 @@ * @return region populations speaking this language */ private Set<RegionPopulation> getRegionsForLocale(GwtLocale locale) { - Set<RegionPopulation> retVal = regionLanguageData.getRegions( - locale.getLanguageNotNull() + "_" + locale.getScriptNotNull()); + Set<RegionPopulation> retVal = + regionLanguageData + .getRegions(locale.getLanguageNotNull() + "_" + locale.getScriptNotNull()); if (retVal.isEmpty()) { retVal = regionLanguageData.getRegions(locale.getLanguageNotNull()); } @@ -362,8 +350,7 @@ * @param methodName the name of the method to create * @param values the list of string values to return. */ - private void writeStringListMethod(PrintWriter pw, String methodName, - String[] values) { + private void writeStringListMethod(PrintWriter pw, String methodName, String[] values) { pw.println(); pw.println(" @Override"); pw.println(" public String[] " + methodName + "() {");
diff --git a/tools/cldr-import/src/com/google/gwt/tools/cldr/Processor.java b/tools/cldr-import/src/com/google/gwt/tools/cldr/Processor.java index 78b4dd1..0d351f8 100644 --- a/tools/cldr-import/src/com/google/gwt/tools/cldr/Processor.java +++ b/tools/cldr-import/src/com/google/gwt/tools/cldr/Processor.java
@@ -48,7 +48,7 @@ protected static String localeSuffix(GwtLocale locale) { return (locale.isDefault() ? "" : "_") + locale.getAsString(); } - + /** * @param value * @return value with all quotes escaped @@ -57,7 +57,7 @@ return value.replace("\"", "\\\""); } - protected final Factory cldrFactory; + protected final Factory cldrFactory; protected final LocaleData localeData; @@ -72,8 +72,7 @@ * @param cldrFactory CLDR factory used to create new CLDRFile instances * @param localeData LocaleData instance to collect data from CLDR files */ - protected Processor(File outputDir, Factory cldrFactory, - LocaleData localeData) { + protected Processor(File outputDir, Factory cldrFactory, LocaleData localeData) { this.outputDir = outputDir; this.cldrFactory = cldrFactory; this.localeData = localeData; @@ -83,9 +82,9 @@ /** * Execute this processor. * - * It will call loadData, cleanupData, writeOutputFiles, and then reset on - * its localeData instance. - * + * It will call loadData, cleanupData, writeOutputFiles, and then reset on its + * localeData instance. + * * @throws IOException */ public final void run() throws IOException { @@ -110,14 +109,13 @@ * Create an output file including any parent directories. * * @param name name of file, which will be prefixed by - * user/src/com/google/gwt/i18n/client/impl/cldr + * user/src/com/google/gwt/i18n/client/impl/cldr * @param ext extension for file * @param locale locale name or null if not localized * @return a PrintWriter instance * @throws IOException */ - protected PrintWriter createFile(String name, String ext, String locale) - throws IOException { + protected PrintWriter createFile(String name, String ext, String locale) throws IOException { if (locale == null || locale.length() == 0) { locale = ""; } else { @@ -126,13 +124,12 @@ return createOutputFile("client/impl/cldr/" + name + locale + "." + ext); } - protected PrintWriter createOutputFile(String suffix) - throws IOException, FileNotFoundException { + protected PrintWriter createOutputFile(String suffix) throws IOException, FileNotFoundException { return createOutputFile(I18N_PACKAGE_PATH, suffix); } - protected PrintWriter createOutputFile(String prefix, String suffix) - throws IOException, FileNotFoundException { + protected PrintWriter createOutputFile(String prefix, String suffix) throws IOException, + FileNotFoundException { PrintWriter pw; File f = new File(outputDir, prefix + suffix); File parent = f.getParentFile(); @@ -140,13 +137,14 @@ parent.mkdirs(); } f.createNewFile(); - pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(f), "UTF-8")), false); + pw = + new PrintWriter( + new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), "UTF-8")), false); return pw; } - protected void generateIntMethod(PrintWriter pw, String category, - GwtLocale locale, String key, String method) { + protected void generateIntMethod(PrintWriter pw, String category, GwtLocale locale, String key, + String method) { String value = localeData.getEntry(category, locale, key); if (value != null) { pw.println(); @@ -159,14 +157,13 @@ } } - protected void generateStringMethod(PrintWriter pw, String category, - GwtLocale locale, String key, String method) { + protected void generateStringMethod(PrintWriter pw, String category, GwtLocale locale, + String key, String method) { String value = localeData.getEntry(category, locale, key); generateStringValue(pw, method, value); } - protected void generateStringValue(PrintWriter pw, String method, - String value) { + protected void generateStringValue(PrintWriter pw, String method, String value) { if (value != null) { pw.println(); if (useOverride) { @@ -187,7 +184,7 @@ /** * Load data needed by this processor. - * + * * @throws IOException */ protected abstract void loadData() throws IOException; @@ -204,12 +201,10 @@ pw.println(" * "); pw.println(" * http://www.apache.org/licenses/LICENSE-2.0"); pw.println(" * "); - pw.println(" * Unless required by applicable law or agreed to in writing, " - + "software"); + pw.println(" * Unless required by applicable law or agreed to in writing, " + "software"); pw.println(" * distributed under the License is distributed on an \"AS " + "IS\" BASIS, WITHOUT"); - pw.println(" * WARRANTIES OR CONDITIONS OF ANY KIND, either express or " - + "implied. See the"); + pw.println(" * WARRANTIES OR CONDITIONS OF ANY KIND, either express or " + "implied. See the"); pw.println(" * License for the specific language governing permissions and " + "limitations under"); pw.println(" * the License."); @@ -227,7 +222,7 @@ /** * Write output files produced by this processor. - * + * * @throws IOException */ protected abstract void writeOutputFiles() throws IOException;
diff --git a/tools/cldr-import/src/com/google/gwt/tools/cldr/RegionLanguageData.java b/tools/cldr-import/src/com/google/gwt/tools/cldr/RegionLanguageData.java index bdab309..2cb6447 100644 --- a/tools/cldr-import/src/com/google/gwt/tools/cldr/RegionLanguageData.java +++ b/tools/cldr-import/src/com/google/gwt/tools/cldr/RegionLanguageData.java
@@ -36,14 +36,12 @@ /** * Stores the populate literate in a given language. */ - public static class LanguagePopulation implements - Comparable<LanguagePopulation> { + public static class LanguagePopulation implements Comparable<LanguagePopulation> { private final String language; private final double literatePopulation; private final boolean official; - public LanguagePopulation(String language, double literatePopulation, - boolean official) { + public LanguagePopulation(String language, double literatePopulation, boolean official) { this.language = language; this.literatePopulation = literatePopulation; this.official = official; @@ -102,8 +100,7 @@ private final double literatePopulation; private final boolean official; - public RegionPopulation(String region, double literatePopulation, - boolean official) { + public RegionPopulation(String region, double literatePopulation, boolean official) { this.region = region; this.literatePopulation = literatePopulation; this.official = official; @@ -187,11 +184,9 @@ } regionMap = new HashMap<String, SortedSet<LanguagePopulation>>(); languageMap = new HashMap<String, SortedSet<RegionPopulation>>(); - CLDRFile supp = cldrFactory.make("supplementalData", true, - DraftStatus.approved); + CLDRFile supp = cldrFactory.make("supplementalData", true, DraftStatus.approved); XPathParts parts = new XPathParts(); - Iterator<String> iterator = supp.iterator( - "//supplementalData/territoryInfo/territory"); + Iterator<String> iterator = supp.iterator("//supplementalData/territoryInfo/territory"); while (iterator.hasNext()) { String path = iterator.next(); parts.set(supp.getFullXPath(path)); @@ -200,19 +195,15 @@ continue; } String territory = parts.findAttributeValue("territory", "type"); - String literacyPercentStr = parts.findAttributeValue("territory", - "literacyPercent"); - String populationStr = parts.findAttributeValue("territory", - "population"); - String populationPercentStr = parts.findAttributeValue( - "languagePopulation", "populationPercent"); - String statusStr = parts.findAttributeValue("languagePopulation", - "officialStatus"); + String literacyPercentStr = parts.findAttributeValue("territory", "literacyPercent"); + String populationStr = parts.findAttributeValue("territory", "population"); + String populationPercentStr = + parts.findAttributeValue("languagePopulation", "populationPercent"); + String statusStr = parts.findAttributeValue("languagePopulation", "officialStatus"); double literacyPercent = Double.parseDouble(literacyPercentStr) * .01; double population = Double.parseDouble(populationStr); double populationPercent = Double.parseDouble(populationPercentStr) * .01; - double literatePopulation = population * populationPercent - * literacyPercent; + double literatePopulation = population * populationPercent * literacyPercent; boolean official = "official".equals(statusStr); SortedSet<RegionPopulation> regPop = languageMap.get(language); if (regPop == null) { @@ -225,8 +216,7 @@ langPop = new TreeSet<LanguagePopulation>(); regionMap.put(territory, langPop); } - langPop.add(new LanguagePopulation(language, literatePopulation, - official)); + langPop.add(new LanguagePopulation(language, literatePopulation, official)); } } }
diff --git a/tools/cldr-import/test/com/google/gwt/tools/cldr/LocaleDataTest.java b/tools/cldr-import/test/com/google/gwt/tools/cldr/LocaleDataTest.java index 817139c..5a03e07 100644 --- a/tools/cldr-import/test/com/google/gwt/tools/cldr/LocaleDataTest.java +++ b/tools/cldr-import/test/com/google/gwt/tools/cldr/LocaleDataTest.java
@@ -30,7 +30,7 @@ public class LocaleDataTest extends TestCase { private static final GwtLocaleFactoryImpl localeFactory; - + static { localeFactory = new GwtLocaleFactoryImpl(); } @@ -39,8 +39,8 @@ * Test method for {@link LocaleData#getAllLocales()}. */ public void testGetAllLocales() { - LocaleData localeData = new LocaleData(localeFactory, Arrays.asList( - "root", "en", "en_US", "ar", "ar_IQ")); + LocaleData localeData = + new LocaleData(localeFactory, Arrays.asList("root", "en", "en_US", "ar", "ar_IQ")); Set<GwtLocale> locales = localeData.getAllLocales(); assertEquals(5, locales.size()); GwtLocale localeEn = localeFactory.fromString("en"); @@ -57,8 +57,8 @@ * Test method for {@link LocaleData#getNonEmptyLocales()}. */ public void testGetNonEmptyLocales() { - LocaleData localeData = new LocaleData(localeFactory, Arrays.asList( - "root", "en", "en_US", "ar", "ar_IQ")); + LocaleData localeData = + new LocaleData(localeFactory, Arrays.asList("root", "en", "en_US", "ar", "ar_IQ")); Iterator<GwtLocale> it = localeData.getNonEmptyLocales().iterator(); assertFalse(it.hasNext()); GwtLocale localeEn = localeFactory.fromString("en"); @@ -81,8 +81,8 @@ * Test method for {@link LocaleData#getNonEmptyLocales(java.lang.String)}. */ public void testGetNonEmptyLocalesString() { - LocaleData localeData = new LocaleData(localeFactory, Arrays.asList( - "root", "en", "en_US", "ar", "ar_IQ")); + LocaleData localeData = + new LocaleData(localeFactory, Arrays.asList("root", "en", "en_US", "ar", "ar_IQ")); Iterator<GwtLocale> it = localeData.getNonEmptyLocales("foo").iterator(); assertFalse(it.hasNext()); GwtLocale localeEn = localeFactory.fromString("en"); @@ -108,11 +108,13 @@ } /** - * Test method for {@link LocaleData#inheritsFrom(com.google.gwt.i18n.shared.GwtLocale)}. + * Test method for + * {@link LocaleData#inheritsFrom(com.google.gwt.i18n.shared.GwtLocale)}. */ public void testInheritsFrom() { - LocaleData localeData = new LocaleData(localeFactory, Arrays.asList( - "root", "en", "en_US", "en_US_VARIANT", "ar", "ar_IQ")); + LocaleData localeData = + new LocaleData(localeFactory, Arrays.asList("root", "en", "en_US", "en_US_VARIANT", "ar", + "ar_IQ")); GwtLocale localeEn = localeFactory.fromString("en"); localeData.addEntry("foo", localeEn, "k1", "v1"); GwtLocale localeEnUs = localeFactory.fromString("en_us"); @@ -127,11 +129,14 @@ } /** - * Test method for {@link LocaleData#inheritsFrom(java.lang.String, com.google.gwt.i18n.shared.GwtLocale)}. + * Test method for + * {@link LocaleData#inheritsFrom(java.lang.String, com.google.gwt.i18n.shared.GwtLocale)} + * . */ public void testInheritsFromWithCategory() { - LocaleData localeData = new LocaleData(localeFactory, Arrays.asList( - "root", "en", "en_US", "en_US_VARIANT", "ar", "ar_IQ")); + LocaleData localeData = + new LocaleData(localeFactory, Arrays.asList("root", "en", "en_US", "en_US_VARIANT", "ar", + "ar_IQ")); GwtLocale localeEn = localeFactory.fromString("en"); localeData.addEntry("foo", localeEn, "k1", "v1"); GwtLocale localeEnUs = localeFactory.fromString("en_us"); @@ -151,8 +156,8 @@ * Test method for {@link LocaleData#removeCompleteDuplicates()}. */ public void testRemoveCompleteDuplicates() { - LocaleData localeData = new LocaleData(localeFactory, Arrays.asList( - "root", "en", "en_US", "ar", "ar_IQ")); + LocaleData localeData = + new LocaleData(localeFactory, Arrays.asList("root", "en", "en_US", "ar", "ar_IQ")); GwtLocale localeEn = localeFactory.fromString("en"); GwtLocale localeEnUs = localeFactory.fromString("en_us"); localeData.addEntry("foo", localeEn, "k1", "v1"); @@ -171,8 +176,8 @@ * Test method for {@link LocaleData#removeDuplicates()}. */ public void testRemoveDuplicates() { - LocaleData localeData = new LocaleData(localeFactory, Arrays.asList( - "root", "en", "en_US", "ar", "ar_IQ")); + LocaleData localeData = + new LocaleData(localeFactory, Arrays.asList("root", "en", "en_US", "ar", "ar_IQ")); GwtLocale localeEn = localeFactory.fromString("en"); GwtLocale localeEnUs = localeFactory.fromString("en_us"); localeData.addEntry("foo", localeEn, "k1", "v1");
diff --git a/tools/datetimefmtcreator/src/com/google/gwt/tools/datetimefmtcreator/DateTimeFormatCreator.java b/tools/datetimefmtcreator/src/com/google/gwt/tools/datetimefmtcreator/DateTimeFormatCreator.java index 0315142..dab5439 100644 --- a/tools/datetimefmtcreator/src/com/google/gwt/tools/datetimefmtcreator/DateTimeFormatCreator.java +++ b/tools/datetimefmtcreator/src/com/google/gwt/tools/datetimefmtcreator/DateTimeFormatCreator.java
@@ -51,21 +51,17 @@ public class DateTimeFormatCreator { private static class DtfiGenerator { - - private static void buildPatterns(GwtLocale locale, - TreeMap<Key, String[]> properties) { + + private static void buildPatterns(GwtLocale locale, TreeMap<Key, String[]> properties) { ULocale ulocale = new ULocale(ULocale.canonicalize(locale.getAsString())); - DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance( - ulocale); + DateTimePatternGenerator dtpg = DateTimePatternGenerator.getInstance(ulocale); for (Map.Entry<String, String> entry : patterns.entrySet()) { - properties.put(new Key(locale, "format" + entry.getKey()), new String[] { - dtpg.getBestPattern(entry.getValue()) - }); + properties.put(new Key(locale, "format" + entry.getKey()), new String[] {dtpg + .getBestPattern(entry.getValue())}); } } - private static GwtLocale findEarliestAncestor(GwtLocale locale, - Set<GwtLocale> set) { + private static GwtLocale findEarliestAncestor(GwtLocale locale, Set<GwtLocale> set) { if (set == null) { return null; } @@ -76,7 +72,7 @@ } return null; } - + private static String quote(String value) { return value.replaceAll("\"", "\\\\\""); } @@ -107,6 +103,7 @@ private File propDir; private File src; + public DtfiGenerator(File src) { this.src = src; String packageName = DateTimeConstantsImpl.class.getPackage().getName(); @@ -117,10 +114,8 @@ } } - public void generate() throws FileNotFoundException, - IOException { - final Pattern dtcProps = Pattern.compile( - "DateTimeConstantsImpl(.*)\\.properties"); + public void generate() throws FileNotFoundException, IOException { + final Pattern dtcProps = Pattern.compile("DateTimeConstantsImpl(.*)\\.properties"); String[] propFiles = propDir.list(new FilenameFilter() { public boolean accept(File dir, String name) { return dtcProps.matcher(name).matches(); @@ -133,8 +128,8 @@ generateSources(properties, parents); } - private void addLocaleParent(Map<GwtLocale, Set<GwtLocale>> parents, - GwtLocale keyLocale, GwtLocale parentLocale) { + private void addLocaleParent(Map<GwtLocale, Set<GwtLocale>> parents, GwtLocale keyLocale, + GwtLocale parentLocale) { Set<GwtLocale> parentSet = parents.get(keyLocale); if (parentSet == null) { parentSet = new HashSet<GwtLocale>(); @@ -144,12 +139,10 @@ } @SuppressWarnings("unchecked") - private void collectPropertyData(String[] propFiles, - TreeMap<Key, String[]> properties, GwtLocaleFactory factory) - throws FileNotFoundException, IOException { + private void collectPropertyData(String[] propFiles, TreeMap<Key, String[]> properties, + GwtLocaleFactory factory) throws FileNotFoundException, IOException { for (String propFile : propFiles) { - if (!propFile.startsWith("DateTimeConstantsImpl") - || !propFile.endsWith(".properties")) { + if (!propFile.startsWith("DateTimeConstantsImpl") || !propFile.endsWith(".properties")) { continue; } int len = propFile.length(); @@ -167,8 +160,7 @@ Map<String, String> map = props.getPropertyMap(); for (Map.Entry<String, String> entry : map.entrySet()) { String[] value = split(entry.getValue()); - if ("dateFormats".equals(entry.getKey()) - || "timeFormats".equals(entry.getKey()) + if ("dateFormats".equals(entry.getKey()) || "timeFormats".equals(entry.getKey()) || "weekendRange".equals(entry.getKey())) { // split these out into separate fields for (int i = 0; i < value.length; ++i) { @@ -189,8 +181,8 @@ } } - private PrintWriter createClassSource(String packageName, - String className) throws FileNotFoundException { + private PrintWriter createClassSource(String packageName, String className) + throws FileNotFoundException { String path = packageName.replace('.', '/') + "/" + className + ".java"; File f = new File(src, path); FileOutputStream ostr = new FileOutputStream(f); @@ -203,7 +195,7 @@ out.println(" * the License at"); out.println(" * "); out.println(" * http://www.apache.org/licenses/LICENSE-2.0"); - out.println(" *"); + out.println(" *"); out.println(" * Unless required by applicable law or agreed to in writing, software"); out.println(" * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT"); out.println(" * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the"); @@ -217,8 +209,7 @@ return out; } - private void generateAlias(GwtLocale locale, GwtLocale parent) - throws IOException { + private void generateAlias(GwtLocale locale, GwtLocale parent) throws IOException { System.out.println("Generating alias " + locale); String suffix; if (parent.isDefault()) { @@ -232,22 +223,20 @@ try { out = createClassSource(packageName, className); out.println("/**"); - out.println(" * Locale \"" + locale + "\" is an alias for \"" + parent - + "\"."); + out.println(" * Locale \"" + locale + "\" is an alias for \"" + parent + "\"."); out.println(" */"); - out.println("public class " + className - + " extends DateTimeFormatInfoImpl" + suffix + " {"); + out.println("public class " + className + " extends DateTimeFormatInfoImpl" + suffix + " {"); out.println("}"); } finally { if (out != null) { out.close(); } } - + } - private void generateLocale(GwtLocale locale, GwtLocale parent, - Map<String, String[]> values) throws IOException { + private void generateLocale(GwtLocale locale, GwtLocale parent, Map<String, String[]> values) + throws IOException { System.out.println("Generating locale " + locale); boolean addOverrides = true; PrintWriter out = null; @@ -277,11 +266,10 @@ String className = "DateTimeFormatInfoImpl_" + locale.getAsString(); out = createClassSource(packageName, className); out.println("/**"); - out.println(" * Implementation of DateTimeFormatInfo for locale \"" - + locale + "\"."); + out.println(" * Implementation of DateTimeFormatInfo for locale \"" + locale + "\"."); out.println(" */"); - out.println("public class " + className - + " extends DateTimeFormatInfoImpl" + suffix + " {"); + out.println("public class " + className + " extends DateTimeFormatInfoImpl" + suffix + + " {"); } Set<String> keySet = values.keySet(); String[] keys = keySet.toArray(new String[keySet.size()]); @@ -320,8 +308,7 @@ if (addOverrides) { out.println(" @Override"); } - out.println(" public " + type.getSimpleName() + " " + name - + "() {"); + out.println(" public " + type.getSimpleName() + " " + name + "() {"); out.print(" return "); if (relayMethod != null) { out.println(relayMethod + "();"); @@ -391,43 +378,41 @@ } } - private void generateSources(TreeMap<Key, String[]> properties, - Map<GwtLocale, Set<GwtLocale>> parents) throws IOException { - Set<GwtLocale> locales = new HashSet<GwtLocale>(); - // process sorted locales/keys, generating each locale on change - GwtLocale lastLocale = null; - Map<String, String[]> thisLocale = new HashMap<String, String[]>(); - for (Entry<Key, String[]> entry : properties.entrySet()) { - if (lastLocale != null && lastLocale != entry.getKey().locale) { - GwtLocale parent = findEarliestAncestor(lastLocale, - parents.get(lastLocale)); + private void generateSources(TreeMap<Key, String[]> properties, + Map<GwtLocale, Set<GwtLocale>> parents) throws IOException { + Set<GwtLocale> locales = new HashSet<GwtLocale>(); + // process sorted locales/keys, generating each locale on change + GwtLocale lastLocale = null; + Map<String, String[]> thisLocale = new HashMap<String, String[]>(); + for (Entry<Key, String[]> entry : properties.entrySet()) { + if (lastLocale != null && lastLocale != entry.getKey().locale) { + GwtLocale parent = findEarliestAncestor(lastLocale, parents.get(lastLocale)); + generateLocale(lastLocale, parent, thisLocale); + thisLocale.clear(); + lastLocale = null; + } + if (lastLocale == null) { + lastLocale = entry.getKey().locale; + locales.add(lastLocale); + } + thisLocale.put(entry.getKey().key, entry.getValue()); + } + if (lastLocale != null) { + GwtLocale parent = findEarliestAncestor(lastLocale, parents.get(lastLocale)); generateLocale(lastLocale, parent, thisLocale); - thisLocale.clear(); - lastLocale = null; } - if (lastLocale == null) { - lastLocale = entry.getKey().locale; - locales.add(lastLocale); - } - thisLocale.put(entry.getKey().key, entry.getValue()); - } - if (lastLocale != null) { - GwtLocale parent = findEarliestAncestor(lastLocale, - parents.get(lastLocale)); - generateLocale(lastLocale, parent, thisLocale); - } - Set<GwtLocale> seen = new HashSet<GwtLocale>(locales); - for (GwtLocale locale : locales) { - for (GwtLocale alias : locale.getAliases()) { - if (!seen.contains(alias)) { - seen.add(alias); -// generateAlias(alias, locale); + Set<GwtLocale> seen = new HashSet<GwtLocale>(locales); + for (GwtLocale locale : locales) { + for (GwtLocale alias : locale.getAliases()) { + if (!seen.contains(alias)) { + seen.add(alias); + // generateAlias(alias, locale); + } } } } - } - /** + /** * Check if a given entry within a locale is inherited from a parent. * * @param properties @@ -435,7 +420,7 @@ * @param key * @param value * @return true if the value is the same as the first parent defining that - * value + * value */ private boolean isInherited(TreeMap<Key, String[]> properties, Map<GwtLocale, Set<GwtLocale>> parents, Key key, String[] value) { @@ -465,16 +450,14 @@ * @param properties * @return inheritance map */ - private Map<GwtLocale, Set<GwtLocale>> removeInheritedValues( - TreeMap<Key, String[]> properties) { + private Map<GwtLocale, Set<GwtLocale>> removeInheritedValues(TreeMap<Key, String[]> properties) { // remove entries identical to a parent locale Map<GwtLocale, Set<GwtLocale>> parents = new HashMap<GwtLocale, Set<GwtLocale>>(); Set<Entry<Key, String[]>> entrySet = properties.entrySet(); Iterator<Entry<Key, String[]>> it = entrySet.iterator(); while (it.hasNext()) { Entry<Key, String[]> entry = it.next(); - if (isInherited(properties, parents, entry.getKey(), - entry.getValue())) { + if (isInherited(properties, parents, entry.getKey(), entry.getValue())) { it.remove(); } } @@ -544,56 +527,41 @@ static { fieldMap.put("ampms", new FieldMapping("ampms", String[].class)); - fieldMap.put("dateFormats0", new FieldMapping("dateFormatFull", - String.class)); - fieldMap.put("dateFormats1", new FieldMapping("dateFormatLong", - String.class)); - fieldMap.put("dateFormats2", new FieldMapping("dateFormatMedium", - String.class)); - fieldMap.put("dateFormats3", new FieldMapping("dateFormatShort", - String.class)); - fieldMap.put("timeFormats0", new FieldMapping("timeFormatFull", - String.class)); - fieldMap.put("timeFormats1", new FieldMapping("timeFormatLong", - String.class)); - fieldMap.put("timeFormats2", new FieldMapping("timeFormatMedium", - String.class)); - fieldMap.put("timeFormats3", new FieldMapping("timeFormatShort", - String.class)); + fieldMap.put("dateFormats0", new FieldMapping("dateFormatFull", String.class)); + fieldMap.put("dateFormats1", new FieldMapping("dateFormatLong", String.class)); + fieldMap.put("dateFormats2", new FieldMapping("dateFormatMedium", String.class)); + fieldMap.put("dateFormats3", new FieldMapping("dateFormatShort", String.class)); + fieldMap.put("timeFormats0", new FieldMapping("timeFormatFull", String.class)); + fieldMap.put("timeFormats1", new FieldMapping("timeFormatLong", String.class)); + fieldMap.put("timeFormats2", new FieldMapping("timeFormatMedium", String.class)); + fieldMap.put("timeFormats3", new FieldMapping("timeFormatShort", String.class)); fieldMap.put("eraNames", new FieldMapping("erasFull", String[].class)); fieldMap.put("eras", new FieldMapping("erasShort", String[].class)); fieldMap.put("quarters", new FieldMapping("quartersFull", String[].class)); - fieldMap.put("shortQuarters", new FieldMapping("quartersShort", - String[].class)); - fieldMap.put("firstDayOfTheWeek", new FieldMapping("firstDayOfTheWeek", - Integer.class)); + fieldMap.put("shortQuarters", new FieldMapping("quartersShort", String[].class)); + fieldMap.put("firstDayOfTheWeek", new FieldMapping("firstDayOfTheWeek", Integer.class)); fieldMap.put("months", new FieldMapping("monthsFull", String[].class)); - fieldMap.put("standaloneMonths", new FieldMapping("monthsFullStandalone", - String[].class, "months")); - fieldMap.put("narrowMonths", new FieldMapping("monthsNarrow", - String[].class)); - fieldMap.put("standaloneNarrowMonths", new FieldMapping( - "monthsNarrowStandalone", String[].class, "narrowMonths")); - fieldMap.put("shortMonths", new FieldMapping("monthsShort", - String[].class)); - fieldMap.put("standaloneShortMonths", new FieldMapping( - "monthsShortStandalone", String[].class, "shortMonths")); + fieldMap.put("standaloneMonths", new FieldMapping("monthsFullStandalone", String[].class, + "months")); + fieldMap.put("narrowMonths", new FieldMapping("monthsNarrow", String[].class)); + fieldMap.put("standaloneNarrowMonths", new FieldMapping("monthsNarrowStandalone", + String[].class, "narrowMonths")); + fieldMap.put("shortMonths", new FieldMapping("monthsShort", String[].class)); + fieldMap.put("standaloneShortMonths", new FieldMapping("monthsShortStandalone", String[].class, + "shortMonths")); fieldMap.put("weekendRange0", new FieldMapping("weekendStart", int.class)); fieldMap.put("weekendRange1", new FieldMapping("weekendEnd", int.class)); - fieldMap.put("firstDayOfTheWeek", new FieldMapping("firstDayOfTheWeek", - int.class)); + fieldMap.put("firstDayOfTheWeek", new FieldMapping("firstDayOfTheWeek", int.class)); fieldMap.put("weekdays", new FieldMapping("weekdaysFull", String[].class)); - fieldMap.put("standaloneWeekdays", new FieldMapping( - "weekdaysFullStandalone", String[].class, "weekdays")); - fieldMap.put("shortWeekdays", new FieldMapping("weekdaysShort", - String[].class)); - fieldMap.put("standaloneShortWeekdays", new FieldMapping( - "weekdaysShortStandalone", String[].class, "shortWeekdays")); - fieldMap.put("narrowWeekdays", new FieldMapping("weekdaysNarrow", - String[].class)); - fieldMap.put("standaloneNarrowWeekdays", new FieldMapping( - "weekdaysNarrowStandalone", String[].class, "narrowWeekdays")); - + fieldMap.put("standaloneWeekdays", new FieldMapping("weekdaysFullStandalone", String[].class, + "weekdays")); + fieldMap.put("shortWeekdays", new FieldMapping("weekdaysShort", String[].class)); + fieldMap.put("standaloneShortWeekdays", new FieldMapping("weekdaysShortStandalone", + String[].class, "shortWeekdays")); + fieldMap.put("narrowWeekdays", new FieldMapping("weekdaysNarrow", String[].class)); + fieldMap.put("standaloneNarrowWeekdays", new FieldMapping("weekdaysNarrowStandalone", + String[].class, "narrowWeekdays")); + // patterns to use with DateTimePatternGenerator patterns.put("Day", "d"); patterns.put("Hour12Minute", "hmm"); @@ -625,8 +593,7 @@ */ public static void main(String[] args) throws IOException { if (args.length != 1) { - System.err.println("Usage: " - + DateTimeFormatCreator.class.getSimpleName() + " gwt-root-dir"); + System.err.println("Usage: " + DateTimeFormatCreator.class.getSimpleName() + " gwt-root-dir"); return; } File gwt = new File(args[0]);