diff options
author | Michael Koch <konqueror@gmx.de> | 2004-04-20 21:04:35 +0000 |
---|---|---|
committer | Michael Koch <konqueror@gmx.de> | 2004-04-20 21:04:35 +0000 |
commit | a61490a4705f3ad79d974d8c4f041a90708cf9b6 (patch) | |
tree | 1ad11f1c68a4a96852e1c0a475fd78dc85308aa3 /java/text/AttributedString.java | |
parent | e93cb62b497fd0da5a9d39b23257871963094f8c (diff) | |
download | classpath-a61490a4705f3ad79d974d8c4f041a90708cf9b6.tar.gz |
2004-04-20 Graydon Hoare <graydon@redhat.com>
* java/text/AttributedString.java
(addAttribute): Fix off-by-one.
(getIterator): Likewise.
* java/text/AttributedStringIterator.java
(getRunLimit): Correct logic.
(getRunStart): Likewise.
(getAttribute): Fix inequality.
(getAttributes): Likewise.
Diffstat (limited to 'java/text/AttributedString.java')
-rw-r--r-- | java/text/AttributedString.java | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/java/text/AttributedString.java b/java/text/AttributedString.java index a8eede813..46cbf92d5 100644 --- a/java/text/AttributedString.java +++ b/java/text/AttributedString.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.text; +import java.util.Arrays; import java.util.Iterator; import java.util.HashMap; import java.util.Hashtable; @@ -219,26 +220,7 @@ AttributedString(AttributedCharacterIterator aci, int begin_index, // Get the valid attribute list Set all_attribs = aci.getAllAttributeKeys(); if (attributes != null) - { - Set valid_attribs = new HashSet(); - Iterator iter = all_attribs.iterator(); - while (iter.hasNext()) - { - Object obj = iter.next(); - - int i; - for (i = 0; i < attributes.length; i++) - if (obj.equals(attributes[0])) - break; - - if (i == attributes.length) - continue; - - valid_attribs.add(obj); - } - - all_attribs = valid_attribs; - } + all_attribs.retainAll(Arrays.asList(attributes)); // Loop through and extract the attributes char c = aci.setIndex(begin_index); @@ -320,7 +302,7 @@ AttributedString(AttributedCharacterIterator aci, int begin_index, public void addAttribute(AttributedCharacterIterator.Attribute attrib, Object value) { - addAttribute(attrib, value, 0, sci.getEndIndex() - 1); + addAttribute(attrib, value, 0, sci.getEndIndex()); } /*************************************************************************/ @@ -389,8 +371,7 @@ addAttributes(Map attributes, int begin_index, int end_index) public AttributedCharacterIterator getIterator() { - return(new AttributedStringIterator(sci, attribs, 0, sci.getEndIndex() - 1, - null)); + return(new AttributedStringIterator(sci, attribs, 0, sci.getEndIndex(), null)); } /*************************************************************************/ @@ -409,7 +390,7 @@ getIterator() public AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[] attributes) { - return(getIterator(attributes, 0, sci.getEndIndex() - 1)); + return(getIterator(attributes, 0, sci.getEndIndex())); } /*************************************************************************/ |