[multiple changes]
authorMichael Koch <mkoch@gcc.gnu.org>
Thu, 11 Mar 2004 15:50:34 +0000 (15:50 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Thu, 11 Mar 2004 15:50:34 +0000 (15:50 +0000)
2004-03-11  Dalibor Topic  <robilad@kaffe.org>

* java/text/AttributedString.java
(addAttribute(AttributedCharacterIterator.Attribute,Object,int,int)):
Use HashMap instead of Hashtable since value can be null, and
you can not store a null value in a Hashtable.

2004-03-11  Guilhem Lavaux <guilhem@kaffe.org>

* java/text/AttributedStringIterator.java
(getAllAttributesKey): Return only keys concerned
by the current iterator.
(getAttributes): Use strict inequality for
end_index.

From-SVN: r79329

libjava/ChangeLog
libjava/java/text/AttributedString.java
libjava/java/text/AttributedStringIterator.java

index 2ed64719e0fdebc764aaedcd3b7307f2f367e677..2d741cf4468c87bf7c875b0e1d1dc9c851881cff 100644 (file)
@@ -1,3 +1,18 @@
+2004-03-11  Dalibor Topic  <robilad@kaffe.org>
+
+       * java/text/AttributedString.java
+       (addAttribute(AttributedCharacterIterator.Attribute,Object,int,int)):
+       Use HashMap instead of Hashtable since value can be null, and
+       you can not store a null value in a Hashtable.
+
+2004-03-11  Guilhem Lavaux <guilhem@kaffe.org>
+
+       * java/text/AttributedStringIterator.java
+       (getAllAttributesKey): Return only keys concerned
+       by the current iterator.
+       (getAttributes): Use strict inequality for
+       end_index. 
+
 2004-03-11  Michael Koch  <konqueror@gmx.de>
 
        * java/net/HttpURLConnection.java:
index d689d87ac58d4fc7fd3ca6d6622315d1e1131e61..a8eede813fc83286021a7f1faa5305599c1d44fa 100644 (file)
@@ -1,5 +1,5 @@
 /* AttributedString.java -- Models text with attributes
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -39,6 +39,7 @@ exception statement from your version. */
 package java.text;
 
 import java.util.Iterator;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.HashSet;
 import java.util.Map;
@@ -329,7 +330,7 @@ addAttribute(AttributedCharacterIterator.Attribute attrib, Object value)
   * of the string.
   *
   * @param attrib The attribute to add.
-  * @param value The value of the attribute.
+  * @param value The value of the attribute, which may be null.
   * @param begin_index The beginning index of the subrange.
   * @param end_index The ending index of the subrange.
   *
@@ -342,10 +343,10 @@ addAttribute(AttributedCharacterIterator.Attribute attrib, Object value,
   if (attrib == null)
     throw new IllegalArgumentException("null attribute");
 
-  Hashtable ht = new Hashtable();
-  ht.put(attrib, value);
+  HashMap hm = new HashMap();
+  hm.put(attrib, value);
 
-  addAttributes(ht, begin_index, end_index);
+  addAttributes(hm, begin_index, end_index);
 }
 
 /*************************************************************************/
index d3193382bfdea77a1661251884e3898d735481c1..77c5981703d6ba99db35bdfa928312346c2de22c 100644 (file)
@@ -179,8 +179,12 @@ getAllAttributeKeys()
   if (attribs == null)
     return(s);
 
-  for (int i = 0; i < attribs.length; i++)
+    for (int i = 0; i < attribs.length; i++)
     {
+      if (attribs[i].begin_index > getEndIndex()
+         || attribs[i].end_index <= getBeginIndex())
+       continue;
+
       Set key_set = attribs[i].attribs.keySet();
       Iterator iter = key_set.iterator();
       while (iter.hasNext())
@@ -327,7 +331,7 @@ getAttribute(AttributedCharacterIterator.Attribute attrib)
           // Check for attribute match and range match
           if (obj.equals(attrib))
             if ((ci.getIndex() >= attribs[i].begin_index) &&
-                (ci.getIndex() <= attribs[i].end_index))
+                (ci.getIndex() < attribs[i].end_index))
               return(attribs[i].attribs.get(obj));
         }
     }
@@ -351,7 +355,7 @@ getAttributes()
   for (int i = 0; i < attribs.length; i++)
     {
        if ((ci.getIndex() >= attribs[i].begin_index) &&
-           (ci.getIndex() <= attribs[i].end_index))
+           (ci.getIndex() < attribs[i].end_index))
          m.putAll(attribs[i].attribs);
     }