[cp-patches] Remaining Locale Updates for RH712013

Dr Andrew John Hughes ahughes at redhat.com
Wed Feb 15 23:12:39 UTC 2012


As promised, I've committed the remaining fixes for the locale issues
first discovered in the libgcj Fedora bug, RH712013:

https://bugzilla.redhat.com/show_bug.cgi?id=712013

The following commits finish the job:

1.  https://lists.gnu.org/archive/html/commit-classpath/2012-02/msg00001.html
This alters the cp-tools localegen tool so that it no longer overwrites elements
with the same path within the XML tree.  As an example, in the Welsh locale
(cy.xml in CLDR 1.6.0) there are two paths dates.calendars.calendar.months.monthContext
which are differentiated by the attribute type using the values "format" and "stand-alone".
The default one to use should be "format" but the cp-tools parser has been parsing this
one and then overwriting it with the stand-alone one (which occurs second in the XML file)
as it doesn't check whether there is already a value for that path.  This patch changes
the parser to retain a list of the elements with that path, not just a single one.
The property generator then picks the appropriate one from that list.
2.  https://lists.gnu.org/archive/html/commit-classpath/2012-02/msg00000.html
This patch just updates the locale data in Classpath with the results of using the updated
generator on CLDR 1.6.0.
3.  https://lists.gnu.org/archive/html/commit-classpath/2012-02/msg00005.html
This simple patch just stops the property generator from adding a trailing separator to
ordered list content (months, weekdays, etc.).  There was a FIXME for this in the code already.
4.  https://lists.gnu.org/archive/html/commit-classpath/2012-02/msg00004.html
This is again the corresponding Classpath patch which updates the data and removes the hack
that drops the last character of the input data.

All four patches are attached.
-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

PGP Key: 248BDC07 (https://keys.indymedia.org/)
Fingerprint = EC5A 1F5E C0AD 1D15 8F1F  8F91 3B96 A578 248B DC07
-------------- next part --------------
A non-text attachment was scrubbed...
Name: locale-10.diff.gz
Type: application/octet-stream
Size: 92111 bytes
Desc: not available
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20120215/f2fc1d3c/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: locale-11.diff.gz
Type: application/octet-stream
Size: 41526 bytes
Desc: not available
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20120215/f2fc1d3c/attachment-0003.obj 
-------------- next part --------------
Index: src/gnu/ldml/Analyzer.java
===================================================================
RCS file: /sources/classpath/cp-tools/src/gnu/ldml/Analyzer.java,v
retrieving revision 1.9
diff -u -u -r1.9 Analyzer.java
--- src/gnu/ldml/Analyzer.java	20 Jan 2012 15:13:50 -0000	1.9
+++ src/gnu/ldml/Analyzer.java	2 Feb 2012 02:07:46 -0000
@@ -26,6 +26,7 @@
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Map;
 import java.net.URL;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -38,36 +39,64 @@
 public class Analyzer
 {
 
-  private static Hashtable<String,Element> flattenBranch(Element e)
+  static Map<String,List<Element>> flattenBranch(Element e)
   {
-    Hashtable<String,Element> table = new Hashtable<String,Element>();
-    ArrayList<Element> stack = new ArrayList<Element>();
-    int stack_sz;
+    Map<String,List<Element>> table = new HashMap<String,List<Element>>();
+    List<Element> stack = new ArrayList<Element>();
+    int stackSize;
     stack.add(e);
     while (stack.size() != 0)
       {
-        stack_sz = stack.size();
-        for (int i = 0; i < stack_sz; i++)
+        stackSize = stack.size();
+        for (int i = 0; i < stackSize; i++)
           {
             Element elt = stack.get(i);
-            if(elt != null)
+            if (elt != null)
               {
                 if (elt.children.size() != 0)
                   {
                     stack.addAll(elt.children);
                   }
-                table.put(elt.getFullName(), elt);
+                String fullName = elt.getFullName();
+                List<Element> elms = table.get(fullName);
+                if (elms == null)
+                  {
+                    elms = new ArrayList<Element>();
+                    table.put(elt.getFullName(), elms);
+                  }
+                boolean added = elms.add(elt);
+                if (!added)
+                  throw new Error("Couldn't add " + elt);
               }
           }
-        stack.subList(0, stack_sz).clear();
+        stack.subList(0, stackSize).clear();
       }
     return table;
   }
+
+  public static Element getSingleElement(List<Element> elms)
+  {
+    Element returnedElement = null;
+
+    if (elms == null)
+      return null;
+    if (elms.size() > 1)
+      {
+        for (Element elm : elms)
+          if (elm.getAltText().equals(""))
+            returnedElement = elm;
+        if (returnedElement == null)
+          throw new IllegalArgumentException("No default element: " + elms);
+        return returnedElement;
+      }
+    return elms.get(0);
+  }
+
   private boolean is_collation;
   private Collection<String> locales;
   private Parser mainParser;
   private Hashtable<String,Parser> parserTable = new Hashtable<String,Parser>();
-  private Hashtable<String,Element> treeFlattened;
+  private Map<String,List<Element>> treeFlattened;
 
   public Analyzer(URL mainFile) throws IOException, ParseException
   {
@@ -123,28 +152,29 @@
         e2.initCause(e);
         throw e2;
       }
-    Hashtable<String,Element> table = flattenTree();
+    Map<String,List<Element>> table = flattenTree();
     locales = new HashSet<String>();
-    Element elt = table.get("ldml.identity.language");
+    Element elt = getSingleElement(table.get("ldml.identity.language"));
     String mainIdentity;
     if (elt == null)
       throw new ParseException(
                                "No identity.language tag in XML. Cannot identify the resource file.");
     mainIdentity = elt.defaultType.intern();
-    elt = table.get("ldml.identity.territory");
+    elt = getSingleElement(table.get("ldml.identity.territory"));
     if (elt != null)
       {
         mainIdentity += "_" + elt.defaultType;
-        elt = table.get("ldml.identity.variant");
+        elt = getSingleElement(table.get("ldml.identity.variant"));
         if (elt != null)
           mainIdentity += "_" + elt.defaultType;
       }
-    elt = table.get("ldml.identity.script");
+    elt = getSingleElement(table.get("ldml.identity.script"));
     if (elt != null)
       mainIdentity += "_" + elt.defaultType;
     locales.add(mainIdentity);
     // Process ldml/collations at validSublocales
-    ListDataElement collations = (ListDataElement) table.get("ldml.collations");
+    ListDataElement collations = (ListDataElement)
+      getSingleElement(table.get("ldml.collations"));
     if (collations != null)
       {
         /*
@@ -250,11 +280,11 @@
      * find the right element specified by the position and the argument of
      * AliasElement.
      */
-    Hashtable<String,Element> table = flattenBranch(p.rootElement);
+    Map<String,List<Element>> table = flattenBranch(p.rootElement);
     String elementName = alias.superElement.getFullName();
     while (elementName.length() != 0)
       {
-        Element e = table.get(elementName);
+        Element e = getSingleElement(table.get(elementName));
         if (e == null)
           {
             int idx = elementName.lastIndexOf('.');
@@ -284,7 +314,7 @@
     return null;
   }
 
-  public Hashtable<String,Element> flattenTree()
+  public Map<String,List<Element>> flattenTree()
   {
     if (treeFlattened != null)
       return treeFlattened;
Index: src/gnu/ldml/DataElement.java
===================================================================
RCS file: /sources/classpath/cp-tools/src/gnu/ldml/DataElement.java,v
retrieving revision 1.4
diff -u -u -r1.4 DataElement.java
--- src/gnu/ldml/DataElement.java	20 Jan 2012 15:13:50 -0000	1.4
+++ src/gnu/ldml/DataElement.java	2 Feb 2012 02:07:46 -0000
@@ -29,6 +29,18 @@
     super(p, parent, name);
   }
 
+  public DataElement(Parser p, Element parent, String name,
+                     Draft draft)
+  {
+    super(p, parent, name, draft);
+  }
+
+  public DataElement(Parser p, Element parent, String name,
+                     Draft draft, String altText)
+  {
+    super(p, parent, name, draft, altText);
+  }
+
   @Override
   public String toString()
   {
Index: src/gnu/ldml/Element.java
===================================================================
RCS file: /sources/classpath/cp-tools/src/gnu/ldml/Element.java,v
retrieving revision 1.5
diff -u -u -r1.5 Element.java
--- src/gnu/ldml/Element.java	20 Jan 2012 15:13:50 -0000	1.5
+++ src/gnu/ldml/Element.java	2 Feb 2012 02:07:46 -0000
@@ -31,18 +31,73 @@
   public Parser parentParser;
   public String qualifiedName;
   public Element superElement;
+  private Draft draft;
+  private String altText;
 
   private Element()
   {
   }
 
+  /**
+   * Constructs a new element from a given parser
+   * with the specified parent element, name, approved
+   * draft status and no alternative text.
+   *
+   * @param p the parser which created this.
+   * @param parent the parent element.
+   * @param name the name of the element.
+   */
   public Element(Parser p, Element parent, String name)
   {
+    this(p, parent, name, null, null);
+  }
+
+  /**
+   * Constructs a new element from a given parser
+   * with the specified parent element, name, draft
+   * status and no alternative text.
+   *
+   * @param p the parser which created this.
+   * @param parent the parent element.
+   * @param name the name of the element.
+   * @param draft the draft status (optional,
+   *        defaults to approved if {@code null}).
+   */
+  public Element(Parser p, Element parent, String name,
+                 Draft draft)
+  {
+    this(p, parent, name, draft, null);
+  }
+
+  /**
+   * Constructs a new element from a given parser
+   * with the specified parent element, name, draft
+   * status and alternative text.
+   *
+   * @param p the parser which created this.
+   * @param parent the parent element.
+   * @param name the name of the element.
+   * @param draft the draft status (optional,
+   *        defaults to approved if {@code null}).
+   * @param altText the alternative text (optional,
+   *        defaults to the empty string if {@code null}).
+   */
+  public Element(Parser p, Element parent, String name,
+                 Draft draft, String altText)
+  {
     parentParser = p;
     superElement = parent;
     qualifiedName = name;
     if (parent != ROOT)
       parent.addChild(this);
+    if (draft == null)
+      this.draft = Draft.APPROVED;
+    else
+      this.draft = draft;
+    if (altText == null)
+      this.altText = "";
+    else
+      this.altText = altText;
   }
 
   public void addChild(Element e)
@@ -65,7 +120,30 @@
       ",displayName=" + displayName +
       ",parentParser=" + parentParser +
       ",qualifiedName=" + qualifiedName +
-      ",superElement=" + superElement.qualifiedName + "]";
+      ",superElement=" + superElement.qualifiedName +
+      ",draft=" + draft +
+      ",altText=" + altText +
+      "]";
+  }
+
+  /**
+   * Returns the alternative text.
+   *
+   * @return the alternative text.
+   */
+  public String getAltText()
+  {
+    return altText;
+  }
+
+  /**
+   * Returns the draft status.
+   *
+   * @return the draft status.
+   */
+  public Draft getDraft()
+  {
+    return draft;
   }
 
 }
Index: src/gnu/ldml/Leaf.java
===================================================================
RCS file: /sources/classpath/cp-tools/src/gnu/ldml/Leaf.java,v
retrieving revision 1.1
diff -u -u -r1.1 Leaf.java
--- src/gnu/ldml/Leaf.java	30 Jan 2012 11:40:51 -0000	1.1
+++ src/gnu/ldml/Leaf.java	2 Feb 2012 02:07:46 -0000
@@ -19,9 +19,6 @@
  */
 package gnu.ldml;
 
-import java.util.HashMap;
-import java.util.Map;
-
 /**
  * Represents a leaf node containing data in the parsed
  * XML file.
@@ -32,32 +29,6 @@
   implements Comparable<Leaf>
 {
 
-  public enum Draft
-  {
-    APPROVED("approved"),
-    CONTRIBUTED("contributed"),
-    PROVISIONAL("provisional"),
-    UNCONFIRMED("unconfirmed");
-
-    private static final Map<String, Draft> stringToEnum =
-      new HashMap<String, Draft>();
-
-    static
-    {
-      for (Draft draft : values())
-        stringToEnum.put(draft.toString(), draft);
-    }
-
-    private final String draft;
-
-    Draft(final String draft) { this.draft = draft; }
-    @Override public String toString() { return draft; }
-    public static Draft fromString(String draft)
-    {
-      return stringToEnum.get(draft);
-    }
-  }
-
   /**
    * The data.
    */
Index: src/gnu/ldml/ListDataElement.java
===================================================================
RCS file: /sources/classpath/cp-tools/src/gnu/ldml/ListDataElement.java,v
retrieving revision 1.8
diff -u -u -r1.8 ListDataElement.java
--- src/gnu/ldml/ListDataElement.java	30 Jan 2012 11:40:51 -0000	1.8
+++ src/gnu/ldml/ListDataElement.java	2 Feb 2012 02:07:46 -0000
@@ -19,9 +19,9 @@
  */
 package gnu.ldml;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -36,30 +36,12 @@
     super(p, parent, name);
   }
 
-  public HashMap<String,Element> flattenLeaf(String name)
+  public Map<String,List<Element>> flattenLeaf(String name)
   {
     Element listObject = listElms.get(name);
     if (listObject == null)
       return null;
-    HashMap<String,Element> table = new HashMap<String,Element>();
-    ArrayList<Element> stack = new ArrayList<Element>();
-    int stackSize;
-    stack.add(listObject);
-    while (stack.size() != 0)
-      {
-        stackSize = stack.size();
-        for (int i = 0; i < stackSize; i++)
-          {
-            Element elt = stack.get(i);
-            if (elt.children.size() != 0)
-              {
-                stack.addAll(elt.children);
-              }
-            table.put(elt.getFullName(), elt);
-          }
-        stack.subList(0, stackSize).clear();
-      }
-    return table;
+    return Analyzer.flattenBranch(listObject);
   }
 
   public Iterator<String> leaves()
Index: src/gnu/ldml/Parser.java
===================================================================
RCS file: /sources/classpath/cp-tools/src/gnu/ldml/Parser.java,v
retrieving revision 1.11
diff -u -u -r1.11 Parser.java
--- src/gnu/ldml/Parser.java	30 Jan 2012 11:40:54 -0000	1.11
+++ src/gnu/ldml/Parser.java	2 Feb 2012 02:07:46 -0000
@@ -145,7 +145,7 @@
   {
     String typeName;
     StringBuffer listData;
-    Leaf.Draft draft;
+    Draft draft;
     String altText;
 
     public void start(String qName, Attributes atts) throws SAXException
@@ -153,7 +153,7 @@
       typeName = atts.getValue("type");
       if (typeName == null)
         throw new SAXException("<" + qName + "> must have a type attribute");
-      draft = Leaf.Draft.fromString(atts.getValue("draft"));
+      draft = Draft.fromString(atts.getValue("draft"));
       altText = atts.getValue("alt");
       listData = new StringBuffer();
     }
@@ -195,7 +195,9 @@
     public void start(String qName, Attributes atts) throws SAXException
     {
       super.start(qName, atts);
-      parentElement = elt = new DataElement(Parser.this, parentElement, qName);
+      parentElement = elt = new DataElement(Parser.this, parentElement, qName,
+                                            Draft.fromString(atts.getValue("draft")),
+                                            atts.getValue("alt"));
     }
 
     public void characters(char[] ch, int start, int length)
Index: src/gnu/localegen/PropertiesGenerator.java
===================================================================
RCS file: /sources/classpath/cp-tools/src/gnu/localegen/PropertiesGenerator.java,v
retrieving revision 1.12
diff -u -u -r1.12 PropertiesGenerator.java
--- src/gnu/localegen/PropertiesGenerator.java	30 Jan 2012 11:40:56 -0000	1.12
+++ src/gnu/localegen/PropertiesGenerator.java	2 Feb 2012 02:07:46 -0000
@@ -353,8 +353,8 @@
       while (keys.hasNext())
         {
           String zoneName = keys.next();
-          Map<String,Element> zoneTable;
-          DataElement zoneData;
+          Map<String,List<Element>> zoneTable;
+          List<Element> zoneData;
           StringBuilder buffer2 = new StringBuilder();
           boolean zoneDataFound = false;
 
@@ -364,12 +364,13 @@
           zoneTable = listElt.flattenLeaf(zoneName);
           for (int j = 0; j < classpathZoneOrder.length; j++)
           {
-            zoneData = (DataElement)zoneTable.get(classpathZoneOrder[j]);
+            zoneData = zoneTable.get(classpathZoneOrder[j]);
             if (zoneData == null)
-              zoneData = (DataElement) zoneTable.get(classpathMetazoneOrder[j]);
+              zoneData = zoneTable.get(classpathMetazoneOrder[j]);
             if (zoneData != null)
               {
-                buffer2.append(convertToJavaString(zoneData.data));
+                buffer2.append(convertToJavaString(((DataElement)
+                                                    Analyzer.getSingleElement(zoneData)).data));
                 zoneDataFound = true;
               }
             buffer2.append("\\u00ae");
@@ -471,10 +472,10 @@
     this.locale = locale;
   }
 
-  public void addCurrencyFormatContent(Map<String,Element> tree)
+  public void addCurrencyFormatContent(Map<String,List<Element>> tree)
   {
     DataElement dataElt = (DataElement)
-      tree.get("ldml.numbers.currencyFormats.currencyFormatLength.currencyFormat.pattern");
+      Analyzer.getSingleElement(tree.get("ldml.numbers.currencyFormats.currencyFormatLength.currencyFormat.pattern"));
 
     if (dataElt == null)
       return;
@@ -487,9 +488,9 @@
     localeContents.add(new StringContent("currencyFormat", data));
   }
 
-  public void addStringContent(Map<String,Element> tree, String ref, String name)
+  public void addStringContent(Map<String,List<Element>> tree, String ref, String name)
   {
-    DataElement dataElt = (DataElement) tree.get(ref);
+    DataElement dataElt = (DataElement) Analyzer.getSingleElement(tree.get(ref));
     if (dataElt == null)
       return;
     // Java doesn't have the 'v' pattern character so replace with z
@@ -509,48 +510,69 @@
                                               prependNull, appendNull));
   }
 
-  private void computeCalendar(Map<String,Element> flattree)
+  private void addContextualContent(Map<String,List<Element>> tree, String ref,
+                                    String name, String[] order, int prependNull,
+                                    int appendNull)
+  {
+    List<Element> elts = tree.get(ref);
+    if (elts == null)
+      return;
+    for (Element elt : elts)
+      {
+        Element context = elt.superElement.superElement;
+        if (context.defaultType.equals("format"))
+          {
+            ListDataElement data = (ListDataElement) elt;
+            localeContents.add(new OrderedListContent(name, data.getData(), order,
+                                                      prependNull, appendNull));
+          }
+      }
+  }
+
+  private void computeCalendar(Map<String,List<Element>> flattree)
   {
     ListDataElement calendarElement;
-    calendarElement = (ListDataElement) flattree.get("ldml.dates.calendars");
+    calendarElement = (ListDataElement)
+      Analyzer.getSingleElement(flattree.get("ldml.dates.calendars"));
     if (calendarElement != null)
       {
         // GNU Classpath only supports gregorian calendar ATM. We will upgrade
         // the code
         // once it has been done in GNU Classpath.
-        Map<String,Element> calendarLeaf = calendarElement.flattenLeaf("gregorian");
+        Map<String,List<Element>> calendarLeaf = calendarElement.flattenLeaf("gregorian");
         int i = 0;
         if (calendarLeaf == null)
           return;
-        addOrderedListContent(
+        addContextualContent(
                               calendarLeaf,
                               "calendar.months.monthContext.monthWidth.abbreviated",
                               "shortMonths", gnu.ldml.Constants.monthsOrder[i],
                               0, 1);
-        addOrderedListContent(calendarLeaf,
+        addContextualContent(calendarLeaf,
                               "calendar.months.monthContext.monthWidth.wide",
                               "months", gnu.ldml.Constants.monthsOrder[i], 0, 1);
-        addOrderedListContent(calendarLeaf,
+        addContextualContent(calendarLeaf,
                               "calendar.days.dayContext.dayWidth.abbreviated",
                               "shortWeekdays", gnu.ldml.Constants.daysOrder, 1,
                               0);
-        addOrderedListContent(calendarLeaf,
+        addContextualContent(calendarLeaf,
                               "calendar.days.dayContext.dayWidth.wide",
                               "weekdays", gnu.ldml.Constants.daysOrder, 1, 0);
         /* WEEKS */
-        Element minDays = calendarLeaf.get("calendar.week.minDays");
+        List<Element> minDays = calendarLeaf.get("calendar.week.minDays");
         if(minDays != null)
           localeContents
-            .add(new StringContent("minNumberOfDaysInFirstWeek", minDays.defaultType));
-
-        Element firstDay = calendarLeaf.get("calendar.week.firstDay");
+            .add(new StringContent("minNumberOfDaysInFirstWeek",
+                                   Analyzer.getSingleElement(minDays).defaultType));
+        List<Element> firstDay = calendarLeaf.get("calendar.week.firstDay");
         if(firstDay != null)
           localeContents
-            .add(new StringContent("firstDayOfWeek", firstDay.defaultType));
+            .add(new StringContent("firstDayOfWeek",
+                                   Analyzer.getSingleElement(firstDay).defaultType));
 
         /* ERAS */
-        ListDataElement eraElement = (ListDataElement) calendarLeaf
-          .get("calendar.eras.eraAbbr");
+        ListDataElement eraElement = (ListDataElement)
+          Analyzer.getSingleElement(calendarLeaf.get("calendar.eras.eraAbbr"));
         if (eraElement != null)
           {
             SortedSet<Leaf> ac = eraElement.getData("0");
@@ -562,22 +584,21 @@
           }
         DataElement amElement, pmElement;
         /* AM-PM */
-        amElement = (DataElement) calendarLeaf.get("calendar.am");
-        pmElement = (DataElement) calendarLeaf.get("calendar.pm");
+        amElement = (DataElement)
+          Analyzer.getSingleElement(calendarLeaf.get("calendar.am"));
+        pmElement = (DataElement)
+          Analyzer.getSingleElement(calendarLeaf.get("calendar.pm"));
         if (amElement != null && pmElement != null)
-          {
-            localeContents
-              .add(new ManualListContent("ampms", amElement.data,
-                                         pmElement.data));
-          }
+          localeContents.add(new ManualListContent("ampms", amElement.data,
+                                                   pmElement.data));
         /* Compute all date formats */
-        ListDataElement dateFormats = (ListDataElement) calendarLeaf
-          .get("calendar.dateFormats");
+        ListDataElement dateFormats = (ListDataElement)
+          Analyzer.getSingleElement(calendarLeaf.get("calendar.dateFormats"));
         if (dateFormats != null)
           {
             for (int j = 0; j < gnu.ldml.Constants.dateFormats.length; j++)
               {
-                Map<String,Element> dateFormat = dateFormats
+                Map<String,List<Element>> dateFormat = dateFormats
                   .flattenLeaf(gnu.ldml.Constants.dateFormats[j]);
                 if (dateFormat == null)
                   continue;
@@ -587,13 +608,13 @@
               }
           }
         /* Compute all time formats */
-        ListDataElement timeFormats = (ListDataElement) calendarLeaf
-          .get("calendar.timeFormats");
+        ListDataElement timeFormats = (ListDataElement)
+          Analyzer.getSingleElement(calendarLeaf.get("calendar.timeFormats"));
         if (timeFormats != null)
           {
             for (int j = 0; j < gnu.ldml.Constants.timeFormats.length; j++)
               {
-                Map<String,Element> timeFormat = timeFormats
+                Map<String,List<Element>> timeFormat = timeFormats
                   .flattenLeaf(gnu.ldml.Constants.timeFormats[j]);
                 if (timeFormat == null)
                   continue;
@@ -605,18 +626,18 @@
       }
   }
 
-  private void computeCollations(Map<String,Element> flattree)
+  private void computeCollations(Map<String,List<Element>> flattree)
   {
-    ListDataElement collations = (ListDataElement) flattree
-      .get("ldml.collations");
+    ListDataElement collations = (ListDataElement)
+      Analyzer.getSingleElement(flattree.get("ldml.collations"));
     if (collations == null)
       return;
-    Map<String,Element> table = collations.flattenLeaf("standard");
+    Map<String,List<Element>> table = collations.flattenLeaf("standard");
     if (table == null)
       return;
     System.err.println("Found UCA table for collation rules");
-    OrderedListElement listElt = (OrderedListElement) table
-      .get("collation.rules");
+    OrderedListElement listElt = (OrderedListElement)
+      Analyzer.getSingleElement(table.get("collation.rules"));
     if (listElt == null)
       return;
     System.err.println("Found rules");
@@ -626,31 +647,33 @@
       .toCollationRule()));
   }
 
-  private void computeTimeZones(Map<String,Element> flattree)
+  private void computeTimeZones(Map<String,List<Element>> flattree)
   {
-    Element elt = flattree.get("ldml.dates.timeZoneNames");
+    Element elt = Analyzer.getSingleElement(flattree.get("ldml.dates.timeZoneNames"));
     if (elt != null)
       localeContents.add(new TimeZoneContent((ListDataElement) elt));
   }
 
-  private void computeLocalNames(Map<String,Element> flattree)
+  private void computeLocalNames(Map<String,List<Element>> flattree)
   {
-    ListDataElement elt = (ListDataElement) flattree
-      .get("ldml.localeDisplayNames.territories");
+    ListDataElement elt = (ListDataElement)
+      Analyzer.getSingleElement(flattree.get("ldml.localeDisplayNames.territories"));
     if (elt != null)
       localeContents.add(new HashtableContent("territories", elt.getData()));
-    elt = (ListDataElement) flattree.get("ldml.localeDisplayNames.languages");
+    elt = (ListDataElement)
+      Analyzer.getSingleElement(flattree.get("ldml.localeDisplayNames.languages"));
     if (elt != null)
       localeContents.add(new HashtableContent("languages", elt.getData()));
-    elt = (ListDataElement) flattree.get("ldml.localeDisplayNames.variants");
+    elt = (ListDataElement)
+      Analyzer.getSingleElement(flattree.get("ldml.localeDisplayNames.variants"));
     if (elt != null)
       localeContents.add(new HashtableContent("variants", elt.getData()));
   }
 
-  private void computeCurrencies(Map<String,Element> flattree)
+  private void computeCurrencies(Map<String,List<Element>> flattree)
   {
-    ListDataElement elt = (ListDataElement) flattree
-      .get("ldml.numbers.currencies");
+    ListDataElement elt = (ListDataElement)
+      Analyzer.getSingleElement(flattree.get("ldml.numbers.currencies"));
     if (elt == null)
       return;
     Iterator<String> currencyKeys = elt.elmKeys();
@@ -659,10 +682,11 @@
     while (currencyKeys.hasNext())
       {
         String code = currencyKeys.next();
-        Map<String,Element> currencyTable = elt.flattenLeaf(code);
-        DataElement displayName = (DataElement) currencyTable
-          .get("currency.displayName");
-        DataElement symbol = (DataElement) currencyTable.get("currency.symbol");
+        Map<String,List<Element>> currencyTable = elt.flattenLeaf(code);
+        DataElement displayName = (DataElement)
+          Analyzer.getSingleElement(currencyTable.get("currency.displayName"));
+        DataElement symbol = (DataElement)
+          Analyzer.getSingleElement(currencyTable.get("currency.symbol"));
         if (displayName != null)
           currencyName.put(code, displayName.data);
         if (symbol != null)
@@ -677,7 +701,7 @@
     for (Iterator<Analyzer> i = analyzers.iterator(); i.hasNext();)
       {
         Analyzer analyzer = i.next();
-        Map<String,Element> flattree = analyzer.flattenTree();
+        Map<String,List<Element>> flattree = analyzer.flattenTree();
         addStringContent(flattree, "ldml.numbers.symbols.percentSign",
                          "percent");
         addStringContent(flattree, "ldml.numbers.symbols.perMille", "perMill");
-------------- next part --------------
Index: src/gnu/localegen/PropertiesGenerator.java
===================================================================
RCS file: /sources/classpath/cp-tools/src/gnu/localegen/PropertiesGenerator.java,v
retrieving revision 1.13
diff -u -u -r1.13 PropertiesGenerator.java
--- src/gnu/localegen/PropertiesGenerator.java	2 Feb 2012 02:21:12 -0000	1.13
+++ src/gnu/localegen/PropertiesGenerator.java	15 Feb 2012 22:48:56 -0000
@@ -288,7 +288,6 @@
 
     public void generateContent(PrintWriter o)
     {
-      // FIXME: Don't print "\u00ae" after last entry.
       o.print(name + "=");
       for (int i = 0; i < prependNull; i++)
         o.print("\\u00ae");
@@ -297,7 +296,8 @@
           SortedSet<Leaf> contentElement = data.get(order[i]);
           if (contentElement != null)
             o.print(convertToJavaString(contentElement.first().getData()));
-          o.print("\\u00ae");
+          if (i != order.length - 1)
+            o.print("\\u00ae");
         }
       for (int i = 0; i < appendNull; i++)
         o.print("\\u00ae");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20120215/f2fc1d3c/attachment-0001.pgp 


More information about the Classpath-patches mailing list