Index: javax/swing/text/SimpleAttributeSet.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/SimpleAttributeSet.java,v retrieving revision 1.11 diff -u -r1.11 SimpleAttributeSet.java --- javax/swing/text/SimpleAttributeSet.java 27 Sep 2005 19:37:41 -0000 1.11 +++ javax/swing/text/SimpleAttributeSet.java 27 Sep 2005 21:19:17 -0000 @@ -87,8 +87,30 @@ return s; } + /** + * Returns true if the given name and value represent an attribute + * found either in this AttributeSet or in its resolve parent hierarchy. + * @param name the key for the attribute + * @param value the value for the attribute + * @return true if the attribute is found here or in this set's resolve + * parent hierarchy + */ public boolean containsAttribute(Object name, Object value) { + return (tab.containsKey(name) && tab.get(name).equals(value)) || + (getResolveParent() != null && getResolveParent(). + containsAttribute(name, value)); + } + + /** + * Returns true if the given name and value are found in this AttributeSet. + * Does not check the resolve parent. + * @param name the key for the attribute + * @param value the value for the attribute + * @return true if the attribute is found in this AttributeSet + */ + boolean containsAttributeLocally(Object name, Object value) + { return tab.containsKey(name) && tab.get(name).equals(value); } @@ -160,11 +182,15 @@ { return tab.isEmpty(); } - + + /** + * Returns true if the given set has the same number of attributes + * as this set and containsAttributes(attr) returns + * true. + */ public boolean isEqual(AttributeSet attr) { - return attr != null - && attr.containsAttributes(this) + return getAttributeCount() == attr.getAttributeCount() && this.containsAttributes(attr); } @@ -185,7 +211,7 @@ { Object name = e.nextElement(); Object val = attributes.getAttribute(name); - if (containsAttribute(name, val)) + if (containsAttributeLocally(name, val)) removeAttribute(name); } }