/[classpath]/classpath/javax/swing/text/SimpleAttributeSet.java
ViewVC logotype

Diff of /classpath/javax/swing/text/SimpleAttributeSet.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5.2.6 by gnu_andrew, Tue Sep 20 18:46:35 2005 UTC revision 1.5.2.7 by gnu_andrew, Wed Nov 2 00:44:03 2005 UTC
# Line 87  public class SimpleAttributeSet Line 87  public class SimpleAttributeSet
87      return s;      return s;
88    }    }
89    
90      /**
91       * Returns true if the given name and value represent an attribute
92       * found either in this AttributeSet or in its resolve parent hierarchy.
93       * @param name the key for the attribute
94       * @param value the value for the attribute
95       * @return true if the attribute is found here or in this set's resolve
96       * parent hierarchy
97       */
98    public boolean containsAttribute(Object name, Object value)    public boolean containsAttribute(Object name, Object value)
99    {    {
100        return (tab.containsKey(name) && tab.get(name).equals(value)) ||
101          (getResolveParent() != null && getResolveParent().
102           containsAttribute(name, value));
103      }
104      
105      /**
106       * Returns true if the given name and value are found in this AttributeSet.
107       * Does not check the resolve parent.
108       * @param name the key for the attribute
109       * @param value the value for the attribute
110       * @return true if the attribute is found in this AttributeSet
111       */
112      boolean containsAttributeLocally(Object name, Object value)
113      {
114      return tab.containsKey(name)      return tab.containsKey(name)
115        && tab.get(name).equals(value);        && tab.get(name).equals(value);
116    }    }
# Line 160  public class SimpleAttributeSet Line 182  public class SimpleAttributeSet
182    {    {
183      return tab.isEmpty();            return tab.isEmpty();      
184    }    }
185            
186      /**
187       * Returns true if the given set has the same number of attributes
188       * as this set and <code>containsAttributes(attr)</code> returns
189       * true.
190       */
191    public boolean isEqual(AttributeSet attr)    public boolean isEqual(AttributeSet attr)
192    {    {
193      return attr != null      return getAttributeCount() == attr.getAttributeCount()
       && attr.containsAttributes(this)  
194        && this.containsAttributes(attr);        && this.containsAttributes(attr);
195    }    }
196            
# Line 173  public class SimpleAttributeSet Line 199  public class SimpleAttributeSet
199      tab.remove(name);      tab.remove(name);
200    }    }
201    
202      /**
203       * Removes attributes from this set if they are found in the
204       * given set.  Only attributes whose key AND value are removed.
205       * Removes attributes only from this set, not from the resolving parent.
206       */
207    public void removeAttributes(AttributeSet attributes)    public void removeAttributes(AttributeSet attributes)
208    {    {
209      removeAttributes(attributes.getAttributeNames());      Enumeration e = attributes.getAttributeNames();
210        while (e.hasMoreElements())
211          {
212            Object name = e.nextElement();
213            Object val = attributes.getAttribute(name);
214            if (containsAttributeLocally(name, val))
215              removeAttribute(name);    
216          }
217    }    }
218    
219    public void removeAttributes(Enumeration names)    public void removeAttributes(Enumeration names)

Legend:
Removed from v.1.5.2.6  
changed lines
  Added in v.1.5.2.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26