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 |
} |
} |
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 |
|
|
211 |
{ |
{ |
212 |
Object name = e.nextElement(); |
Object name = e.nextElement(); |
213 |
Object val = attributes.getAttribute(name); |
Object val = attributes.getAttribute(name); |
214 |
if (containsAttribute(name, val)) |
if (containsAttributeLocally(name, val)) |
215 |
removeAttribute(name); |
removeAttribute(name); |
216 |
} |
} |
217 |
} |
} |