java.lang.Object
javax.swing.text.SimpleAttributeSet
- All Implemented Interfaces:
Serializable
,Cloneable
,AttributeSet
,MutableAttributeSet
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
.
-
Nested Class Summary
Nested classes/interfaces declared in interface javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
-
Field Summary
Fields declared in interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
-
Constructor Summary
ConstructorDescriptionCreates a new attribute set.SimpleAttributeSet
(AttributeSet source) Creates a new attribute set based on a supplied set of attributes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(Object name, Object value) Adds an attribute to the list.void
addAttributes
(AttributeSet attributes) Adds a set of attributes to the list.clone()
Clones a set of attributes.boolean
containsAttribute
(Object name, Object value) Checks whether the attribute list contains a specified attribute name/value pair.boolean
containsAttributes
(AttributeSet attributes) Checks whether the attribute list contains all the specified name/value pairs.Makes a copy of the attributes.boolean
Compares this object to the specified object.getAttribute
(Object name) Gets the value of an attribute.int
Gets a count of the number of attributes.Enumeration
<?> Gets the names of the attributes in the set.Gets the resolving parent.int
hashCode()
Returns a hashcode for this set of attributes.boolean
Tells whether a given attribute is defined.boolean
isEmpty()
Checks whether the set of attributes is empty.boolean
isEqual
(AttributeSet attr) Compares two attribute sets.void
removeAttribute
(Object name) Removes an attribute from the list.void
removeAttributes
(Enumeration<?> names) Removes a set of attributes from the list.void
removeAttributes
(AttributeSet attributes) Removes a set of attributes from the list.void
setResolveParent
(AttributeSet parent) Sets the resolving parent.toString()
Converts the attribute set to a String.
-
Field Details
-
EMPTY
An empty attribute set.
-
-
Constructor Details
-
SimpleAttributeSet
public SimpleAttributeSet()Creates a new attribute set. -
SimpleAttributeSet
Creates a new attribute set based on a supplied set of attributes.- Parameters:
source
- the set of attributes
-
-
Method Details
-
isEmpty
public boolean isEmpty()Checks whether the set of attributes is empty.- Returns:
- true if the set is empty else false
-
getAttributeCount
public int getAttributeCount()Gets a count of the number of attributes.- Specified by:
getAttributeCount
in interfaceAttributeSet
- Returns:
- the count
-
isDefined
Tells whether a given attribute is defined.- Specified by:
isDefined
in interfaceAttributeSet
- Parameters:
attrName
- the attribute name- Returns:
- true if the attribute is defined
-
isEqual
Compares two attribute sets.- Specified by:
isEqual
in interfaceAttributeSet
- Parameters:
attr
- the second attribute set- Returns:
- true if the sets are equal, false otherwise
-
copyAttributes
Makes a copy of the attributes.- Specified by:
copyAttributes
in interfaceAttributeSet
- Returns:
- the copy
-
getAttributeNames
Gets the names of the attributes in the set.- Specified by:
getAttributeNames
in interfaceAttributeSet
- Returns:
- the names as an
Enumeration
-
getAttribute
Gets the value of an attribute.- Specified by:
getAttribute
in interfaceAttributeSet
- Parameters:
name
- the attribute name- Returns:
- the value
-
containsAttribute
Checks whether the attribute list contains a specified attribute name/value pair.- Specified by:
containsAttribute
in interfaceAttributeSet
- Parameters:
name
- the namevalue
- the value- Returns:
- true if the name/value pair is in the list
-
containsAttributes
Checks whether the attribute list contains all the specified name/value pairs.- Specified by:
containsAttributes
in interfaceAttributeSet
- Parameters:
attributes
- the attribute list- Returns:
- true if the list contains all the name/value pairs
-
addAttribute
Adds an attribute to the list.- Specified by:
addAttribute
in interfaceMutableAttributeSet
- Parameters:
name
- the attribute namevalue
- the attribute value
-
addAttributes
Adds a set of attributes to the list.- Specified by:
addAttributes
in interfaceMutableAttributeSet
- Parameters:
attributes
- the set of attributes to add
-
removeAttribute
Removes an attribute from the list.- Specified by:
removeAttribute
in interfaceMutableAttributeSet
- Parameters:
name
- the attribute name
-
removeAttributes
Removes a set of attributes from the list.- Specified by:
removeAttributes
in interfaceMutableAttributeSet
- Parameters:
names
- the set of names to remove
-
removeAttributes
Removes a set of attributes from the list.- Specified by:
removeAttributes
in interfaceMutableAttributeSet
- Parameters:
attributes
- the set of attributes to remove
-
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.- Specified by:
getResolveParent
in interfaceAttributeSet
- Returns:
- the parent
-
setResolveParent
Sets the resolving parent.- Specified by:
setResolveParent
in interfaceMutableAttributeSet
- Parameters:
parent
- the parent
-
clone
Clones a set of attributes. -
hashCode
public int hashCode()Returns a hashcode for this set of attributes. -
equals
Compares this object to the specified object. The result istrue
if the object is an equivalent set of attributes. -
toString
Converts the attribute set to a String.
-