This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: java.text
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Thu, 11 Mar 2004 16:51:33 +0100
- Subject: FYI: Patch: java.text
Hi list,
I just merged two patches from classpath to trunk to fix more java.text
stuff.
Michael
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.
Index: java/text/AttributedString.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/AttributedString.java,v
retrieving revision 1.2
diff -u -b -B -r1.2 AttributedString.java
--- java/text/AttributedString.java 22 Jan 2002 22:40:37 -0000 1.2
+++ java/text/AttributedString.java 11 Mar 2004 15:49:29 -0000
@@ -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 @@
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 @@
* 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 @@
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: java/text/AttributedStringIterator.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/AttributedStringIterator.java,v
retrieving revision 1.2
diff -u -b -B -r1.2 AttributedStringIterator.java
--- java/text/AttributedStringIterator.java 22 Jan 2002 22:40:37 -0000 1.2
+++ java/text/AttributedStringIterator.java 11 Mar 2004 15:49:29 -0000
@@ -181,6 +181,10 @@
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 @@
// 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 @@
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);
}