Methods Summary |
---|
public void | addAttribute(java.lang.Object name, java.lang.Object value)Adds an attribute to the list.
table.put(name, value);
|
public void | addAttributes(javax.swing.text.AttributeSet attributes)Adds a set of attributes to the list.
Enumeration names = attributes.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
addAttribute(name, attributes.getAttribute(name));
}
|
public java.lang.Object | clone()Clones a set of attributes.
SimpleAttributeSet attr;
try {
attr = (SimpleAttributeSet) super.clone();
attr.table = (Hashtable) table.clone();
} catch (CloneNotSupportedException cnse) {
attr = null;
}
return attr;
|
public boolean | containsAttribute(java.lang.Object name, java.lang.Object value)Checks whether the attribute list contains a
specified attribute name/value pair.
return value.equals(getAttribute(name));
|
public boolean | containsAttributes(javax.swing.text.AttributeSet attributes)Checks whether the attribute list contains all the
specified name/value pairs.
boolean result = true;
Enumeration names = attributes.getAttributeNames();
while (result && names.hasMoreElements()) {
Object name = names.nextElement();
result = attributes.getAttribute(name).equals(getAttribute(name));
}
return result;
|
public javax.swing.text.AttributeSet | copyAttributes()Makes a copy of the attributes.
return (AttributeSet) clone();
|
public boolean | equals(java.lang.Object obj)Compares this object to the specified object.
The result is true if the object is an equivalent
set of attributes.
if (this == obj) {
return true;
}
if (obj instanceof AttributeSet) {
AttributeSet attrs = (AttributeSet) obj;
return isEqual(attrs);
}
return false;
|
public java.lang.Object | getAttribute(java.lang.Object name)Gets the value of an attribute.
Object value = table.get(name);
if (value == null) {
AttributeSet parent = getResolveParent();
if (parent != null) {
value = parent.getAttribute(name);
}
}
return value;
|
public int | getAttributeCount()Gets a count of the number of attributes.
return table.size();
|
public java.util.Enumeration | getAttributeNames()Gets the names of the attributes in the set.
return table.keys();
|
private static java.util.Enumeration | getEmptyEnumeration()
if (emptyEnumeration == null) {
emptyEnumeration = new Enumeration() {
public boolean hasMoreElements() {
return false;
}
public Object nextElement() {
throw new NoSuchElementException("No more elements");
}
};
}
return emptyEnumeration;
|
public javax.swing.text.AttributeSet | getResolveParent()Gets the resolving parent. This is the set
of attributes to resolve through if an attribute
isn't defined locally. This is null if there
are no other sets of attributes to resolve
through.
return (AttributeSet) table.get(StyleConstants.ResolveAttribute);
|
public int | hashCode()Returns a hashcode for this set of attributes.
return table.hashCode();
|
public boolean | isDefined(java.lang.Object attrName)Tells whether a given attribute is defined.
return table.containsKey(attrName);
|
public boolean | isEmpty()Checks whether the set of attributes is empty.
return table.isEmpty();
|
public boolean | isEqual(javax.swing.text.AttributeSet attr)Compares two attribute sets.
return ((getAttributeCount() == attr.getAttributeCount()) &&
containsAttributes(attr));
|
private void | readObject(java.io.ObjectInputStream s)
s.defaultReadObject();
table = new Hashtable(3);
StyleContext.readAttributeSet(s, this);
|
public void | removeAttribute(java.lang.Object name)Removes an attribute from the list.
table.remove(name);
|
public void | removeAttributes(java.util.Enumeration names)Removes a set of attributes from the list.
while (names.hasMoreElements())
removeAttribute(names.nextElement());
|
public void | removeAttributes(javax.swing.text.AttributeSet attributes)Removes a set of attributes from the list.
if (attributes == this) {
table.clear();
}
else {
Enumeration names = attributes.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
Object value = attributes.getAttribute(name);
if (value.equals(getAttribute(name)))
removeAttribute(name);
}
}
|
public void | setResolveParent(javax.swing.text.AttributeSet parent)Sets the resolving parent.
addAttribute(StyleConstants.ResolveAttribute, parent);
|
public java.lang.String | toString()Converts the attribute set to a String.
String s = "";
Enumeration names = getAttributeNames();
while (names.hasMoreElements()) {
Object key = names.nextElement();
Object value = getAttribute(key);
if (value instanceof AttributeSet) {
// don't go recursive
s = s + key + "=**AttributeSet** ";
} else {
s = s + key + "=" + value + " ";
}
}
return s;
|
private void | writeObject(java.io.ObjectOutputStream s)
s.defaultWriteObject();
StyleContext.writeAttributeSet(s, this);
|