PatchSet 4316 
Date: 2004/01/11 17:48:57
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
java.text fixes and small improvements.

Members: 
        ChangeLog:1.1903->1.1904 
        libraries/javalib/gnu/java/locale/LocaleInformation_en.java:1.1->1.2 
        libraries/javalib/gnu/java/locale/LocaleInformation_nl.java:1.1->1.2 
        libraries/javalib/java/text/DateFormatSymbols.java:1.10->1.11 
        libraries/javalib/java/text/DecimalFormat.java:1.23->1.24 
        libraries/javalib/java/text/FormatCharacterIterator.java:1.4->1.5 
        libraries/javalib/java/text/MessageFormat.java:1.20->1.21 
        libraries/javalib/java/text/SimpleDateFormat.java:1.28->1.29 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1903 kaffe/ChangeLog:1.1904
--- kaffe/ChangeLog:1.1903      Sat Jan 10 23:34:27 2004
+++ kaffe/ChangeLog     Sun Jan 11 17:48:57 2004
@@ -1,3 +1,28 @@
+2004-01-11  Guilhem Lavaux <[EMAIL PROTECTED]>
+
+       * libraries/javalib/java/text/FormatCharacterIterator.java
+       (addAttributes): Added a new helper function.
+       (debug, dumpTable): Added debug functions.
+
+       * libraries/javalib/java/text/MessageFormat.java
+       (format): Changed ignore to fp as the parameter is not ignored.
+       (formatInternal): Likewise. Fixed attributed string output. Use the
+       new helper function 'addAttributes'.
+
+       * libraries/javalib/java/text/SimpleDateFormat.java
+       (standardChars): Added a new non documented date symbol (checked
+       against JDK 1.4).
+       (formatToCharacterIterator): Fixed error reporting.
+       (formatWithAttribute): Report the pattern character in the exception
+       message.
+
+       * libraries/javalib/java/text/DateFormatSymbols.java: Fixed copyright
+       notice.
+
+       * libraries/javalib/gnu/java/locale/LocaleInformation_en.java,
+       libraries/javalib/gnu/java/locales/LocaleInformation_nl.java: Updated
+       date symbols.
+       
 2004-01-11  Dalibor Topic <[EMAIL PROTECTED]>
 
        Resynced with Tritonus.org.
Index: kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_en.java
diff -u kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_en.java:1.1 
kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_en.java:1.2
--- kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_en.java:1.1       Sat 
Aug 16 11:03:46 2003
+++ kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_en.java   Sun Jan 11 
17:48:59 2004
@@ -161,7 +161,7 @@
     { "shortWeekdays", shortWeekdays },
     { "ampms", ampms },
     { "eras", eras },
-    { "localPatternChars", "GyMdkHmsSEDFwWahKz" },
+    { "localPatternChars", "GyMdkHmsSEDFwWahKzZ" },
     { "zoneStrings", zoneStrings },
 
     { "shortDateFormat", "M/d/yy" },         // Java's Y2K bug.
Index: kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_nl.java
diff -u kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_nl.java:1.1 
kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_nl.java:1.2
--- kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_nl.java:1.1       Sat 
Aug 16 11:03:46 2003
+++ kaffe/libraries/javalib/gnu/java/locale/LocaleInformation_nl.java   Sun Jan 11 
17:48:59 2004
@@ -126,10 +126,10 @@
   * month (d), hour from 1-12 (h), hour 0-23 (H), minute (m), second (s),
   * millisecond (S), date of week (E), date of year (D),
   * day of week in month (F), week in year (w), week in month (W), am/pm (a),
-  * hour from 1-24 (k), hour from 0-11 (K), time zone (z).
+  * hour from 1-24 (k), hour from 0-11 (K), time zone (z), RFC822 time zone (Z).
   * Why would you use others?
   */
-private static final String localPatternChars = "GyMdhHmsSEDFwWakKz"; // Not a 
mistake!
+private static final String localPatternChars = "GyMdhHmsSEDFwWakKzZ"; // Not a 
mistake!
 
 /**
   * This is the DateFormat.SHORT date format
Index: kaffe/libraries/javalib/java/text/DateFormatSymbols.java
diff -u kaffe/libraries/javalib/java/text/DateFormatSymbols.java:1.10 
kaffe/libraries/javalib/java/text/DateFormatSymbols.java:1.11
--- kaffe/libraries/javalib/java/text/DateFormatSymbols.java:1.10       Wed Oct 22 
10:34:59 2003
+++ kaffe/libraries/javalib/java/text/DateFormatSymbols.java    Sun Jan 11 17:48:59 
2004
@@ -1,4 +1,4 @@
-/* ChoiceFormat.java -- Format over a range of numbers
+/* DateFormatSymbols.java -- Format over a range of numbers
    Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
Index: kaffe/libraries/javalib/java/text/DecimalFormat.java
diff -u kaffe/libraries/javalib/java/text/DecimalFormat.java:1.23 
kaffe/libraries/javalib/java/text/DecimalFormat.java:1.24
--- kaffe/libraries/javalib/java/text/DecimalFormat.java:1.23   Sat Jan  3 03:42:27 
2004
+++ kaffe/libraries/javalib/java/text/DecimalFormat.java        Sun Jan 11 17:48:59 
2004
@@ -411,6 +411,17 @@
            && useExponentialNotation == dup.useExponentialNotation);
   }
 
+
+  /**
+   * This method is a helper function for formatters. Given a set of ranges
+   * and attributes it adds exactly one attribute for the range of characters
+   * comprised between the last entry in 'ranges' and the specified new range.
+   *
+   * @param ranges Vector containing a list of previously entered ranges for 
attributes.
+   * @param attributes Vector containing a list of previously entered attributes
+   * @param new_range A new range to insert in the list.
+   * @param new_attribute A new attribute to insert in the list.
+   */  
   private final void addAttribute(Vector ranges, Vector attributes,
                                  int new_range, Format.Field new_attribute)
   {
Index: kaffe/libraries/javalib/java/text/FormatCharacterIterator.java
diff -u kaffe/libraries/javalib/java/text/FormatCharacterIterator.java:1.4 
kaffe/libraries/javalib/java/text/FormatCharacterIterator.java:1.5
--- kaffe/libraries/javalib/java/text/FormatCharacterIterator.java:1.4  Thu Dec  4 
03:27:49 2003
+++ kaffe/libraries/javalib/java/text/FormatCharacterIterator.java      Sun Jan 11 
17:48:59 2004
@@ -37,12 +37,13 @@
 exception statement from your version. */
 package java.text;
 
+import gnu.classpath.Configuration;
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Vector;
-
+import java.util.Iterator;
 
 /**
  * This class should not be put public and it is only intended to the
@@ -331,6 +332,8 @@
     Vector new_attributes = new Vector();
     int i = 0, j = 0;
 
+    debug("merging " + attributes.length + " attrs");
+    
     while (i < this.ranges.length && j < ranges.length)
       {
        if (this.attributes[i] != null)
@@ -388,6 +391,7 @@
        this.ranges[i] = ((Integer)new_ranges.elementAt (i)).intValue();
       }
     
+    dumpTable();
   }
 
   /**
@@ -466,4 +470,63 @@
   {
     append (text, null);
   }  
+
+  /**
+   * This method adds a set of attributes to a range of character. The
+   * bounds are always inclusive. In the case many attributes have to
+   * be added it is advised to directly use [EMAIL PROTECTED] 
#mergeAttributes([Ljava.util.HashMap;[I}
+   *
+   * @param attributes Attributes to merge into the iterator.
+   * @param range_start Lower bound of the range of characters which will receive the
+   * attribute.
+   * @param range_end Upper bound of the range of characters which will receive the
+   * attribute. 
+   *
+   * @throws IllegalArgumentException if ranges are out of bounds.
+   */
+  protected void addAttributes(HashMap attributes, int range_start, int range_end)
+  {
+    if (range_start == 0)
+      mergeAttributes(new HashMap[] { attributes }, new int[] { range_end });
+    else
+      mergeAttributes(new HashMap[] { null, attributes }, new int[] { range_start, 
range_end });
+  }
+
+  final private void debug(String s)
+  {
+    if (Configuration.DEBUG)
+      System.out.println(s);
+  }
+
+  final private void dumpTable()
+  {
+    int start_range = 0;
+    
+    if (!Configuration.DEBUG)
+      return;
+
+    System.out.println("Dumping internal table:");
+    for (int i = 0; i < ranges.length; i++)
+      {
+       System.out.print("\t" + start_range + " => " + ranges[i] + ":");
+       if (attributes[i] == null)
+         System.out.println("null");
+       else
+         {
+           Set keyset = attributes[i].keySet();
+           if (keyset != null)
+             {
+               Iterator keys = keyset.iterator();
+               
+               while (keys.hasNext())
+                 System.out.print(" " + keys.next());
+             }
+           else
+             System.out.println("keySet null");
+           System.out.println();
+         }
+      }
+    System.out.println();
+    System.out.flush();
+  }
 }
Index: kaffe/libraries/javalib/java/text/MessageFormat.java
diff -u kaffe/libraries/javalib/java/text/MessageFormat.java:1.20 
kaffe/libraries/javalib/java/text/MessageFormat.java:1.21
--- kaffe/libraries/javalib/java/text/MessageFormat.java:1.20   Wed Aug 27 14:32:10 
2003
+++ kaffe/libraries/javalib/java/text/MessageFormat.java        Sun Jan 11 17:48:59 
2004
@@ -397,16 +397,18 @@
    * @param fp A FieldPosition object (it is ignored).
    */
   public final StringBuffer format (Object arguments[], StringBuffer appendBuf,
-                                   FieldPosition ignore)
+                                   FieldPosition fp)
   {
-    return formatInternal(arguments, appendBuf, ignore, null);
+    return formatInternal(arguments, appendBuf, fp, null);
   }
 
   protected final StringBuffer formatInternal (Object arguments[], StringBuffer 
appendBuf,
-                                              FieldPosition ignore,
+                                              FieldPosition fp,
                                               FormatCharacterIterator output_iterator)
   {
     appendBuf.append(leader);
+    if (output_iterator != null)
+      output_iterator.append(leader);
 
     for (int i = 0; i < elements.length; ++i)
       {
@@ -416,6 +418,10 @@
        AttributedCharacterIterator iterator = null;
 
        Format formatter = null;
+
+       if (i == 0 && fp != null && fp.getFieldAttribute() == Field.ARGUMENT)
+         fp.setBeginIndex(appendBuf.length());
+
        if (elements[i].setFormat != null)
          formatter = elements[i].setFormat;
        else if (elements[i].format != null)
@@ -432,26 +438,27 @@
        else
          appendBuf.append(thisArg);
 
+       if (i == 0 && fp != null && fp.getFieldAttribute() == Field.ARGUMENT)
+         fp.setEndIndex(appendBuf.length());
+
        if (formatter != null)
          {
            // Special-case ChoiceFormat.
            if (formatter instanceof ChoiceFormat)
              {
                StringBuffer buf = new StringBuffer ();
-               formatter.format(thisArg, buf, ignore);
+               formatter.format(thisArg, buf, fp);
                MessageFormat mf = new MessageFormat ();
                mf.setLocale(locale);
                mf.applyPattern(buf.toString());
-               mf.format(arguments, appendBuf, ignore);
+               mf.format(arguments, appendBuf, fp);
              }
            else
              {
                if (output_iterator != null)
-                 {
-                   iterator = formatter.formatToCharacterIterator(thisArg);
-                 }
+                 iterator = formatter.formatToCharacterIterator(thisArg);
                else
-                 formatter.format(thisArg, appendBuf, ignore);
+                 formatter.format(thisArg, appendBuf, fp);
              }
 
            elements[i].format = formatter;
@@ -464,24 +471,20 @@
            
            hash_argument.put (MessageFormat.Field.ARGUMENT,
                               new Integer(elements[i].argNumber));
+
            
            if (iterator != null)
              {
                output_iterator.append(iterator);
-               if (position == 0)
-                 output_iterator.mergeAttributes
-                   (new HashMap[] { hash_argument},
-                    new int[] { output_iterator.getEndIndex() });
-               else 
-                 output_iterator.mergeAttributes
-                   (new HashMap[] {null, hash_argument},
-                    new int[] { position, output_iterator.getEndIndex()});
-             } else
-              output_iterator.append(thisArg.toString(), hash_argument);
-
+               output_iterator.addAttributes(hash_argument, position, 
+                                             output_iterator.getEndIndex());
+             } 
+           else
+             output_iterator.append(thisArg.toString(), hash_argument);
+           
            output_iterator.append(elements[i].trailer);
          }
-
+       
        appendBuf.append(elements[i].trailer);
       }
     
Index: kaffe/libraries/javalib/java/text/SimpleDateFormat.java
diff -u kaffe/libraries/javalib/java/text/SimpleDateFormat.java:1.28 
kaffe/libraries/javalib/java/text/SimpleDateFormat.java:1.29
--- kaffe/libraries/javalib/java/text/SimpleDateFormat.java:1.28        Sat Jan  3 
04:14:34 2004
+++ kaffe/libraries/javalib/java/text/SimpleDateFormat.java     Sun Jan 11 17:48:59 
2004
@@ -84,7 +84,7 @@
   // This string is specified in the JCL.  We set it here rather than
   // do a DateFormatSymbols(Locale.US).getLocalPatternChars() since
   // someone could theoretically change those values (though unlikely).
-  private static final String standardChars = "GyMdkHmsSEDFwWahKz";
+  private static final String standardChars = "GyMdkHmsSEDFwWahKzZ";
 
   private void readObject(ObjectInputStream stream)
     throws IOException, ClassNotFoundException
@@ -521,7 +521,7 @@
          buffer.append(zoneID);
          break;
        default:
-         throw new IllegalArgumentException("Illegal pattern character");
+         throw new IllegalArgumentException("Illegal pattern character " + p.field);
        }
        if (pos != null && p.field == pos.getField())
          {
@@ -556,6 +556,11 @@
   public AttributedCharacterIterator formatToCharacterIterator(Object date)
     throws IllegalArgumentException
   {
+    if (date == null)
+      throw new NullPointerException("null argument");
+    if (!(date instanceof Date))
+      throw new IllegalArgumentException("argument should be an instance of 
java.util.Date");
+
     Vector attributes = new Vector();
     Vector ranges = new Vector();
     String s = formatWithAttribute((Date)date, new StringBuffer(),

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to