Method from javax.swing.text.SimpleAttributeSet Detail: |
public void addAttribute(Object name,
Object value) {
table.put(name, value);
}
Adds an attribute to the list. |
public void addAttributes(AttributeSet attributes) {
Enumeration names = attributes.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
addAttribute(name, attributes.getAttribute(name));
}
}
Adds a set of attributes to the list. |
public Object clone() {
SimpleAttributeSet attr;
try {
attr = (SimpleAttributeSet) super.clone();
attr.table = (Hashtable) table.clone();
} catch (CloneNotSupportedException cnse) {
attr = null;
}
return attr;
}
Clones a set of attributes. |
public boolean containsAttribute(Object name,
Object value) {
return value.equals(getAttribute(name));
}
Checks whether the attribute list contains a
specified attribute name/value pair. |
public boolean containsAttributes(AttributeSet attributes) {
boolean result = true;
Enumeration names = attributes.getAttributeNames();
while (result && names.hasMoreElements()) {
Object name = names.nextElement();
result = attributes.getAttribute(name).equals(getAttribute(name));
}
return result;
}
Checks whether the attribute list contains all the
specified name/value pairs. |
public AttributeSet copyAttributes() {
return (AttributeSet) clone();
}
Makes a copy of the attributes. |
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof AttributeSet) {
AttributeSet attrs = (AttributeSet) obj;
return isEqual(attrs);
}
return false;
}
Compares this object to the specified object.
The result is true if the object is an equivalent
set of attributes. |
public Object getAttribute(Object name) {
Object value = table.get(name);
if (value == null) {
AttributeSet parent = getResolveParent();
if (parent != null) {
value = parent.getAttribute(name);
}
}
return value;
}
Gets the value of an attribute. |
public int getAttributeCount() {
return table.size();
}
Gets a count of the number of attributes. |
public Enumeration<?> getAttributeNames() {
return table.keys();
}
Gets the names of the attributes in the set. |
public AttributeSet getResolveParent() {
return (AttributeSet) table.get(StyleConstants.ResolveAttribute);
}
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. |
public int hashCode() {
return table.hashCode();
}
Returns a hashcode for this set of attributes. |
public boolean isDefined(Object attrName) {
return table.containsKey(attrName);
}
Tells whether a given attribute is defined. |
public boolean isEmpty() {
return table.isEmpty();
}
Checks whether the set of attributes is empty. |
public boolean isEqual(AttributeSet attr) {
return ((getAttributeCount() == attr.getAttributeCount()) &&
containsAttributes(attr));
}
Compares two attribute sets. |
public void removeAttribute(Object name) {
table.remove(name);
}
Removes an attribute from the list. |
public void removeAttributes(Enumeration<?> names) {
while (names.hasMoreElements())
removeAttribute(names.nextElement());
}
Removes a set of attributes from the list. |
public void removeAttributes(AttributeSet attributes) {
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);
}
}
}
Removes a set of attributes from the list. |
public void setResolveParent(AttributeSet parent) {
addAttribute(StyleConstants.ResolveAttribute, parent);
}
Sets the resolving parent. |
public String toString() {
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;
}
Converts the attribute set to a String. |