JavaTM 2 Platform
Standard Edition

javax.swing.text
Class SimpleAttributeSet

java.lang.Object
  |
  +--javax.swing.text.SimpleAttributeSet

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. A future release of Swing will provide support for long term persistence.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.text.AttributeSet
AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute, AttributeSet.FontAttribute, AttributeSet.ParagraphAttribute
 
Field Summary
static AttributeSet EMPTY
          An empty attribute set.
 
Fields inherited from interface javax.swing.text.AttributeSet
NameAttribute, ResolveAttribute
 
Constructor Summary
SimpleAttributeSet()
          Creates a new attribute set.
SimpleAttributeSet(AttributeSet source)
          Creates a new attribute set based on a supplied set of attributes.
 
Method Summary
 void addAttribute(Object name, Object value)
          Adds an attribute to the list.
 void addAttributes(AttributeSet attributes)
          Adds a set of attributes to the list.
 Object 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.
 AttributeSet copyAttributes()
          Makes a copy of the attributes.
 boolean equals(Object obj)
          Compares this object to the specifed object.
 Object getAttribute(Object name)
          Gets the value of an attribute.
 int getAttributeCount()
          Gets a count of the number of attributes.
 Enumeration getAttributeNames()
          Gets the names of the attributes in the set.
 AttributeSet getResolveParent()
          Gets the resolving parent.
 int hashCode()
          Returns a hashcode for this set of attributes.
 boolean isDefined(Object attrName)
          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(AttributeSet attributes)
          Removes a set of attributes from the list.
 void removeAttributes(Enumeration names)
          Removes a set of attributes from the list.
 void setResolveParent(AttributeSet parent)
          Sets the resolving parent.
 String toString()
          Converts the attribute set to a String.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final AttributeSet EMPTY
An empty attribute set.
Constructor Detail

SimpleAttributeSet

public SimpleAttributeSet()
Creates a new attribute set.

SimpleAttributeSet

public SimpleAttributeSet(AttributeSet source)
Creates a new attribute set based on a supplied set of attributes.
Parameters:
source - the set of attributes
Method Detail

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.
Returns:
the count

isDefined

public boolean isDefined(Object attrName)
Tells whether a given attribute is defined.
Parameters:
attrName - the attribute name
Returns:
true if the attribute is defined

isEqual

public boolean isEqual(AttributeSet attr)
Compares two attribute sets.
Parameters:
attr - the second attribute set
Returns:
true if equathe listl

copyAttributes

public AttributeSet copyAttributes()
Makes a copy of the attributes.
Returns:
the copy

getAttributeNames

public Enumeration getAttributeNames()
Gets the names of the attributes in the set.
Returns:
the names as an Enumeration

getAttribute

public Object getAttribute(Object name)
Gets the value of an attribute.
Parameters:
name - the attribute name
Returns:
the value

containsAttribute

public boolean containsAttribute(Object name,
                                 Object value)
Checks whether the attribute list contains a specified attribute name/value pair.
Parameters:
name - the name
value - the value
Returns:
true if the name/value pair is in the list

containsAttributes

public boolean containsAttributes(AttributeSet attributes)
Checks whether the attribute list contains all the specified name/value pairs.
Parameters:
attributes - the attribute list
Returns:
true if the list contains all the name/value pairs

addAttribute

public void addAttribute(Object name,
                         Object value)
Adds an attribute to the list.
Specified by:
addAttribute in interface MutableAttributeSet
Parameters:
name - the attribute name
value - the attribute value

addAttributes

public void addAttributes(AttributeSet attributes)
Adds a set of attributes to the list.
Specified by:
addAttributes in interface MutableAttributeSet
Parameters:
attributes - the set of attributes to add

removeAttribute

public void removeAttribute(Object name)
Removes an attribute from the list.
Specified by:
removeAttribute in interface MutableAttributeSet
Parameters:
name - the attribute name

removeAttributes

public void removeAttributes(Enumeration names)
Removes a set of attributes from the list.
Specified by:
removeAttributes in interface MutableAttributeSet
Parameters:
names - the set of names to remove

removeAttributes

public void removeAttributes(AttributeSet attributes)
Removes a set of attributes from the list.
Specified by:
removeAttributes in interface MutableAttributeSet
Parameters:
attributes - the set of attributes to remove

getResolveParent

public 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.
Returns:
the parent

setResolveParent

public void setResolveParent(AttributeSet parent)
Sets the resolving parent.
Specified by:
setResolveParent in interface MutableAttributeSet
Parameters:
parent - the parent

clone

public Object clone()
Clones a set of attributes.
Overrides:
clone in class Object
Returns:
the new set of attributes

hashCode

public int hashCode()
Returns a hashcode for this set of attributes.
Overrides:
hashCode in class Object
Returns:
a hashcode value for this set of attributes.

equals

public boolean equals(Object obj)
Compares this object to the specifed object. The result is true if and only if the argument is not null and is a Font object with the same name, style, and point size as this font.
Overrides:
equals in class Object
Parameters:
obj - the object to compare this font with.
Returns:
true if the objects are equal; false otherwise.

toString

public String toString()
Converts the attribute set to a String.
Overrides:
toString in class Object
Returns:
the string

JavaTM 2 Platform
Standard Edition

Submit a bug or feature
Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.