SimpleAttributeSet (Java 2 Platform SE 5.0) (original) (raw)
javax.swing.text
Class SimpleAttributeSet
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 JavaBeansTM has been added to the java.beans
package. Please see XMLEncoder.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface 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](../../../javax/swing/text/SimpleAttributeSet.html#addAttribute%28java.lang.Object, java.lang.Object%29)(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](../../../javax/swing/text/SimpleAttributeSet.html#containsAttribute%28java.lang.Object, java.lang.Object%29)(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 specified 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](../../../java/lang/Object.html#wait%28long, int%29) |
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.
Specified by:
[getAttributeCount](../../../javax/swing/text/AttributeSet.html#getAttributeCount%28%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
Returns:
the count
isDefined
public boolean isDefined(Object attrName)
Tells whether a given attribute is defined.
Specified by:
[isDefined](../../../javax/swing/text/AttributeSet.html#isDefined%28java.lang.Object%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
Parameters:
attrName
- the attribute name
Returns:
true if the attribute is defined
isEqual
public boolean isEqual(AttributeSet attr)
Compares two attribute sets.
Specified by:
[isEqual](../../../javax/swing/text/AttributeSet.html#isEqual%28javax.swing.text.AttributeSet%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
Parameters:
attr
- the second attribute set
Returns:
true if the sets are equal, false otherwise
copyAttributes
public AttributeSet copyAttributes()
Makes a copy of the attributes.
Specified by:
[copyAttributes](../../../javax/swing/text/AttributeSet.html#copyAttributes%28%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
Returns:
the copy
getAttributeNames
public Enumeration<?> getAttributeNames()
Gets the names of the attributes in the set.
Specified by:
[getAttributeNames](../../../javax/swing/text/AttributeSet.html#getAttributeNames%28%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
Returns:
the names as an Enumeration
getAttribute
public Object getAttribute(Object name)
Gets the value of an attribute.
Specified by:
[getAttribute](../../../javax/swing/text/AttributeSet.html#getAttribute%28java.lang.Object%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
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.
Specified by:
[containsAttribute](../../../javax/swing/text/AttributeSet.html#containsAttribute%28java.lang.Object, java.lang.Object%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
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.
Specified by:
[containsAttributes](../../../javax/swing/text/AttributeSet.html#containsAttributes%28javax.swing.text.AttributeSet%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
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](../../../javax/swing/text/MutableAttributeSet.html#addAttribute%28java.lang.Object, java.lang.Object%29)
in interface [MutableAttributeSet](../../../javax/swing/text/MutableAttributeSet.html "interface in javax.swing.text")
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](../../../javax/swing/text/MutableAttributeSet.html#addAttributes%28javax.swing.text.AttributeSet%29)
in interface [MutableAttributeSet](../../../javax/swing/text/MutableAttributeSet.html "interface in javax.swing.text")
Parameters:
attributes
- the set of attributes to add
removeAttribute
public void removeAttribute(Object name)
Removes an attribute from the list.
Specified by:
[removeAttribute](../../../javax/swing/text/MutableAttributeSet.html#removeAttribute%28java.lang.Object%29)
in interface [MutableAttributeSet](../../../javax/swing/text/MutableAttributeSet.html "interface in javax.swing.text")
Parameters:
name
- the attribute name
removeAttributes
public void removeAttributes(Enumeration<?> names)
Removes a set of attributes from the list.
Specified by:
[removeAttributes](../../../javax/swing/text/MutableAttributeSet.html#removeAttributes%28java.util.Enumeration%29)
in interface [MutableAttributeSet](../../../javax/swing/text/MutableAttributeSet.html "interface in javax.swing.text")
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](../../../javax/swing/text/MutableAttributeSet.html#removeAttributes%28javax.swing.text.AttributeSet%29)
in interface [MutableAttributeSet](../../../javax/swing/text/MutableAttributeSet.html "interface in javax.swing.text")
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.
Specified by:
[getResolveParent](../../../javax/swing/text/AttributeSet.html#getResolveParent%28%29)
in interface [AttributeSet](../../../javax/swing/text/AttributeSet.html "interface in javax.swing.text")
Returns:
the parent
setResolveParent
public void setResolveParent(AttributeSet parent)
Sets the resolving parent.
Specified by:
[setResolveParent](../../../javax/swing/text/MutableAttributeSet.html#setResolveParent%28javax.swing.text.AttributeSet%29)
in interface [MutableAttributeSet](../../../javax/swing/text/MutableAttributeSet.html "interface in javax.swing.text")
Parameters:
parent
- the parent
clone
public Object clone()
Clones a set of attributes.
Overrides:
[clone](../../../java/lang/Object.html#clone%28%29)
in class [Object](../../../java/lang/Object.html "class in java.lang")
Returns:
the new set of attributes
See Also:
hashCode
public int hashCode()
Returns a hashcode for this set of attributes.
Overrides:
[hashCode](../../../java/lang/Object.html#hashCode%28%29)
in class [Object](../../../java/lang/Object.html "class in java.lang")
Returns:
a hashcode value for this set of attributes.
See Also:
Object.equals(java.lang.Object), Hashtable
equals
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.
Overrides:
[equals](../../../java/lang/Object.html#equals%28java.lang.Object%29)
in class [Object](../../../java/lang/Object.html "class in java.lang")
Parameters:
obj
- the object to compare this attribute set with
Returns:
true
if the objects are equal; false
otherwise
See Also:
toString
public String toString()
Converts the attribute set to a String.
Overrides:
[toString](../../../java/lang/Object.html#toString%28%29)
in class [Object](../../../java/lang/Object.html "class in java.lang")
Returns:
the string
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.