public class SimpleAttributeSet extends Object implements MutableAttributeSet, Serializable, Cloneable
A straightforward implementation of MutableAttributeSet using a hash table.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans
package. Please see XMLEncoder
.
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
public static final AttributeSet EMPTY
An empty attribute set.
public SimpleAttributeSet()
Creates a new attribute set.
public SimpleAttributeSet(AttributeSet source)
Creates a new attribute set based on a supplied set of attributes.
source
- the set of attributespublic boolean isEmpty()
Checks whether the set of attributes is empty.
public int getAttributeCount()
Gets a count of the number of attributes.
getAttributeCount
in interface AttributeSet
public boolean isDefined(Object attrName)
Tells whether a given attribute is defined.
isDefined
in interface AttributeSet
attrName
- the attribute namepublic boolean isEqual(AttributeSet attr)
Compares two attribute sets.
isEqual
in interface AttributeSet
attr
- the second attribute setpublic AttributeSet copyAttributes()
Makes a copy of the attributes.
copyAttributes
in interface AttributeSet
public Enumeration<?> getAttributeNames()
Gets the names of the attributes in the set.
getAttributeNames
in interface AttributeSet
Enumeration
public Object getAttribute(Object name)
Gets the value of an attribute.
getAttribute
in interface AttributeSet
name
- the attribute namepublic boolean containsAttribute(Object name, Object value)
Checks whether the attribute list contains a specified attribute name/value pair.
containsAttribute
in interface AttributeSet
name
- the namevalue
- the valuepublic boolean containsAttributes(AttributeSet attributes)
Checks whether the attribute list contains all the specified name/value pairs.
containsAttributes
in interface AttributeSet
attributes
- the attribute listpublic void addAttribute(Object name, Object value)
Adds an attribute to the list.
addAttribute
in interface MutableAttributeSet
name
- the attribute namevalue
- the attribute valuepublic void addAttributes(AttributeSet attributes)
Adds a set of attributes to the list.
addAttributes
in interface MutableAttributeSet
attributes
- the set of attributes to addpublic void removeAttribute(Object name)
Removes an attribute from the list.
removeAttribute
in interface MutableAttributeSet
name
- the attribute namepublic void removeAttributes(Enumeration<?> names)
Removes a set of attributes from the list.
removeAttributes
in interface MutableAttributeSet
names
- the set of names to removepublic void removeAttributes(AttributeSet attributes)
Removes a set of attributes from the list.
removeAttributes
in interface MutableAttributeSet
attributes
- the set of attributes to removepublic 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.
getResolveParent
in interface AttributeSet
public void setResolveParent(AttributeSet parent)
Sets the resolving parent.
setResolveParent
in interface MutableAttributeSet
parent
- the parentpublic Object clone()
Clones a set of attributes.
public int hashCode()
Returns a hashcode for this set of attributes.
hashCode
in class Object
Object.equals(java.lang.Object)
, System.identityHashCode(java.lang.Object)
public boolean equals(Object obj)
Compares this object to the specified object. The result is true
if the object is an equivalent set of attributes.
equals
in class Object
obj
- the object to compare this attribute set withtrue
if the objects are equal; false
otherwiseObject.hashCode()
, HashMap
public String toString()
Converts the attribute set to a String.
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.