diff options
author | Michael Koch <mkoch@gcc.gnu.org> | 2004-03-11 15:50:34 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2004-03-11 15:50:34 +0000 |
commit | 1ce9c63d502d0a3f68d71c05a9186b84664905f5 (patch) | |
tree | 5ffe3337a96b462774d05d08e29a368e25801fa4 /libjava/java | |
parent | c21a266bf28b4171bae0c953e2eb51b0012eb4f6 (diff) | |
download | gcc-1ce9c63d502d0a3f68d71c05a9186b84664905f5.zip gcc-1ce9c63d502d0a3f68d71c05a9186b84664905f5.tar.gz gcc-1ce9c63d502d0a3f68d71c05a9186b84664905f5.tar.bz2 |
[multiple changes]
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
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/text/AttributedString.java | 11 | ||||
-rw-r--r-- | libjava/java/text/AttributedStringIterator.java | 10 |
2 files changed, 13 insertions, 8 deletions
diff --git a/libjava/java/text/AttributedString.java b/libjava/java/text/AttributedString.java index d689d87..a8eede8 100644 --- a/libjava/java/text/AttributedString.java +++ b/libjava/java/text/AttributedString.java @@ -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); } /*************************************************************************/ diff --git a/libjava/java/text/AttributedStringIterator.java b/libjava/java/text/AttributedStringIterator.java index d319338..77c5981 100644 --- a/libjava/java/text/AttributedStringIterator.java +++ b/libjava/java/text/AttributedStringIterator.java @@ -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); } |