APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.text

public Class SimpleAttributeSet

extends Object
implements MutableAttributeSet, Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable, javax.swing.text.MutableAttributeSet, javax.swing.text.AttributeSet
Known Direct Subclasses
javax.swing.text.html.HTMLDocument.TaggedAttributeSet, javax.swing.text.html.StyleSheet.LargeConversionSet
Imports
java.io.IOException, .ObjectInputStream, .Serial, .Serializable, java.util.Collections, .Enumeration, .LinkedHashMap

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 java.beans.XMLEncoder.

Author
Tim Prinzing

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
SimpleAttributeSet.EmptyAttributeSet

An AttributeSet that is always empty.

Field Summary

Modifier and TypeField and Description
public static final AttributeSet
EMPTY

An empty attribute set.

private static final long
serialVersionUID

Use serialVersionUID from JDK 1.7 for interoperability.

private transient LinkedHashMap<Object, Object>

Constructor Summary

AccessConstructor and Description
public
SimpleAttributeSet()

Creates a new attribute set.

public
SimpleAttributeSet(AttributeSet
the set of attributes
source
)

Creates a new attribute set based on a supplied set of attributes.

Method Summary

Modifier and TypeMethod and Description
public void
addAttribute(Object
the attribute name
name
,
Object
the attribute value
value
)

Implements javax.swing.text.MutableAttributeSet.addAttribute.

Adds an attribute to the list.

public void
addAttributes(AttributeSet
the set of attributes to add
attributes
)

Implements javax.swing.text.MutableAttributeSet.addAttributes.

Adds a set of attributes to the list.

public Object

Returns:

the new set of attributes
clone
()

Overrides java.lang.Object.clone.

Clones a set of attributes.

public boolean

Returns:

true if the name/value pair is in the list
containsAttribute
(Object
the name
name
,
Object
the value
value
)

Implements javax.swing.text.AttributeSet.containsAttribute.

Checks whether the attribute list contains a specified attribute name/value pair.

public boolean

Returns:

true if the list contains all the name/value pairs
containsAttributes
(AttributeSet
the attribute list
attributes
)

Implements javax.swing.text.AttributeSet.containsAttributes.

Checks whether the attribute list contains all the specified name/value pairs.

public AttributeSet

Returns:

the copy
copyAttributes
()

Implements javax.swing.text.AttributeSet.copyAttributes.

Makes a copy of the attributes.

public boolean

Returns:

true if the objects are equal; false otherwise
equals
(Object
the object to compare this attribute set with
obj
)

Overrides java.lang.Object.equals.

Compares this object to the specified object.

public Object

Returns:

the value
getAttribute
(Object
the attribute name
name
)

Implements javax.swing.text.AttributeSet.getAttribute.

Gets the value of an attribute.

public int

Returns:

the count
getAttributeCount
()

Implements javax.swing.text.AttributeSet.getAttributeCount.

Gets a count of the number of attributes.

public Enumeration<?>

Returns:

the names as an Enumeration
getAttributeNames
()

Implements javax.swing.text.AttributeSet.getAttributeNames.

Gets the names of the attributes in the set.

public AttributeSet

Returns:

the parent
getResolveParent
()

Implements javax.swing.text.AttributeSet.getResolveParent.

Gets the resolving parent.

public int

Returns:

a hashcode value for this set of attributes.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this set of attributes.

public boolean

Returns:

true if the attribute is defined
isDefined
(Object
the attribute name
attrName
)

Implements javax.swing.text.AttributeSet.isDefined.

Tells whether a given attribute is defined.

public boolean

Returns:

true if the set is empty else false
isEmpty
()

Checks whether the set of attributes is empty.

public boolean

Returns:

true if the sets are equal, false otherwise
isEqual
(AttributeSet
the second attribute set
attr
)

Implements javax.swing.text.AttributeSet.isEqual.

Compares two attribute sets.

private void
public void
removeAttribute(Object
the attribute name
name
)

Implements javax.swing.text.MutableAttributeSet.removeAttribute.

Removes an attribute from the list.

public void
removeAttributes(Enumeration<?>
the set of names to remove
names
)

Implements javax.swing.text.MutableAttributeSet.removeAttributes.

Removes a set of attributes from the list.

public void
removeAttributes(AttributeSet
the set of attributes to remove
attributes
)

Implements javax.swing.text.MutableAttributeSet.removeAttributes.

Removes a set of attributes from the list.

public void
setResolveParent(AttributeSet
the parent
parent
)

Implements javax.swing.text.MutableAttributeSet.setResolveParent.

Sets the resolving parent.

public String

Returns:

the string
toString
()

Overrides java.lang.Object.toString.

Converts the attribute set to a String.

private void
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

EMPTYback to summary
public static final AttributeSet EMPTY

An empty attribute set.

serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.7 for interoperability.

Annotations
@Serial
tableback to summary
private transient LinkedHashMap<Object, Object> table

Constructor Detail

SimpleAttributeSetback to summary
public SimpleAttributeSet()

Creates a new attribute set.

SimpleAttributeSetback to summary
public SimpleAttributeSet(AttributeSet source)

Creates a new attribute set based on a supplied set of attributes.

Parameters
source:AttributeSet

the set of attributes

Method Detail

addAttributeback to summary
public void addAttribute(Object name, Object value)

Implements javax.swing.text.MutableAttributeSet.addAttribute.

Adds an attribute to the list.

Parameters
name:Object

the attribute name

value:Object

the attribute value

addAttributesback to summary
public void addAttributes(AttributeSet attributes)

Implements javax.swing.text.MutableAttributeSet.addAttributes.

Adds a set of attributes to the list.

Parameters
attributes:AttributeSet

the set of attributes to add

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Clones a set of attributes.

Returns:Object

the new set of attributes

Annotations
@SuppressWarnings:unchecked
containsAttributeback to summary
public boolean containsAttribute(Object name, Object value)

Implements javax.swing.text.AttributeSet.containsAttribute.

Checks whether the attribute list contains a specified attribute name/value pair.

Parameters
name:Object

the name

value:Object

the value

Returns:boolean

true if the name/value pair is in the list

containsAttributesback to summary
public boolean containsAttributes(AttributeSet attributes)

Implements javax.swing.text.AttributeSet.containsAttributes.

Checks whether the attribute list contains all the specified name/value pairs.

Parameters
attributes:AttributeSet

the attribute list

Returns:boolean

true if the list contains all the name/value pairs

copyAttributesback to summary
public AttributeSet copyAttributes()

Implements javax.swing.text.AttributeSet.copyAttributes.

Makes a copy of the attributes.

Returns:AttributeSet

the copy

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this object to the specified object. The result is true if the object is an equivalent set of attributes.

Parameters
obj:Object

the object to compare this attribute set with

Returns:boolean

true if the objects are equal; false otherwise

getAttributeback to summary
public Object getAttribute(Object name)

Implements javax.swing.text.AttributeSet.getAttribute.

Gets the value of an attribute.

Parameters
name:Object

the attribute name

Returns:Object

the value

getAttributeCountback to summary
public int getAttributeCount()

Implements javax.swing.text.AttributeSet.getAttributeCount.

Gets a count of the number of attributes.

Returns:int

the count

getAttributeNamesback to summary
public Enumeration<?> getAttributeNames()

Implements javax.swing.text.AttributeSet.getAttributeNames.

Gets the names of the attributes in the set.

Returns:Enumeration<?>

the names as an Enumeration

getResolveParentback to summary
public AttributeSet getResolveParent()

Implements javax.swing.text.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:AttributeSet

the parent

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hashcode for this set of attributes.

Returns:int

a hashcode value for this set of attributes.

isDefinedback to summary
public boolean isDefined(Object attrName)

Implements javax.swing.text.AttributeSet.isDefined.

Tells whether a given attribute is defined.

Parameters
attrName:Object

the attribute name

Returns:boolean

true if the attribute is defined

isEmptyback to summary
public boolean isEmpty()

Checks whether the set of attributes is empty.

Returns:boolean

true if the set is empty else false

isEqualback to summary
public boolean isEqual(AttributeSet attr)

Implements javax.swing.text.AttributeSet.isEqual.

Compares two attribute sets.

Parameters
attr:AttributeSet

the second attribute set

Returns:boolean

true if the sets are equal, false otherwise

readObjectback to summary
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
Annotations
@Serial
removeAttributeback to summary
public void removeAttribute(Object name)

Implements javax.swing.text.MutableAttributeSet.removeAttribute.

Removes an attribute from the list.

Parameters
name:Object

the attribute name

removeAttributesback to summary
public void removeAttributes(Enumeration<?> names)

Implements javax.swing.text.MutableAttributeSet.removeAttributes.

Removes a set of attributes from the list.

Parameters
names:Enumeration<?>

the set of names to remove

removeAttributesback to summary
public void removeAttributes(AttributeSet attributes)

Implements javax.swing.text.MutableAttributeSet.removeAttributes.

Removes a set of attributes from the list.

Parameters
attributes:AttributeSet

the set of attributes to remove

setResolveParentback to summary
public void setResolveParent(AttributeSet parent)

Implements javax.swing.text.MutableAttributeSet.setResolveParent.

Sets the resolving parent.

Parameters
parent:AttributeSet

the parent

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Converts the attribute set to a String.

Returns:String

the string

writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException
Annotations
@Serial
javax.swing.text back to summary

pack-priv Class SimpleAttributeSet.EmptyAttributeSet

extends Object
implements AttributeSet, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.swing.text.AttributeSet

An AttributeSet that is always empty.

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

Use serialVersionUID from JDK 1.7 for interoperability.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
containsAttribute(Object name, Object value)

Implements javax.swing.text.AttributeSet.containsAttribute.

Returns true if this set defines an attribute with the same name and an equal value.

public boolean
containsAttributes(AttributeSet attributes)

Implements javax.swing.text.AttributeSet.containsAttributes.

Returns true if this set defines all the attributes from the given set with equal values.

public AttributeSet
copyAttributes()

Implements javax.swing.text.AttributeSet.copyAttributes.

Returns an attribute set that is guaranteed not to change over time.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Object
getAttribute(Object key)

Implements javax.swing.text.AttributeSet.getAttribute.

Fetches the value of the given attribute.

public int
getAttributeCount()

Implements javax.swing.text.AttributeSet.getAttributeCount.

Returns the number of attributes that are defined locally in this set.

public Enumeration<?>
getAttributeNames()

Implements javax.swing.text.AttributeSet.getAttributeNames.

Returns an enumeration over the names of the attributes that are defined locally in the set.

public AttributeSet
getResolveParent()

Implements javax.swing.text.AttributeSet.getResolveParent.

Gets the resolving parent.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
isDefined(Object attrName)

Implements javax.swing.text.AttributeSet.isDefined.

Checks whether the named attribute has a value specified in the set without resolving through another attribute set.

public boolean
isEqual(AttributeSet attr)

Implements javax.swing.text.AttributeSet.isEqual.

Determines if the two attribute sets are equivalent.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.7 for interoperability.

Annotations
@Serial

Constructor Detail

EmptyAttributeSetback to summary
pack-priv EmptyAttributeSet()

Method Detail

containsAttributeback to summary
public boolean containsAttribute(Object name, Object value)

Implements javax.swing.text.AttributeSet.containsAttribute.

Doc from javax.swing.text.AttributeSet.containsAttribute.

Returns true if this set defines an attribute with the same name and an equal value. If such an attribute is not found locally, it is searched through in the resolving parent hierarchy.

containsAttributesback to summary
public boolean containsAttributes(AttributeSet attributes)

Implements javax.swing.text.AttributeSet.containsAttributes.

Doc from javax.swing.text.AttributeSet.containsAttributes.

Returns true if this set defines all the attributes from the given set with equal values. If an attribute is not found locally, it is searched through in the resolving parent hierarchy.

copyAttributesback to summary
public AttributeSet copyAttributes()

Implements javax.swing.text.AttributeSet.copyAttributes.

Doc from javax.swing.text.AttributeSet.copyAttributes.

Returns an attribute set that is guaranteed not to change over time.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

getAttributeback to summary
public Object getAttribute(Object key)

Implements javax.swing.text.AttributeSet.getAttribute.

Doc from javax.swing.text.AttributeSet.getAttribute.

Fetches the value of the given attribute. If the value is not found locally, the search is continued upward through the resolving parent (if one exists) until the value is either found or there are no more parents. If the value is not found, null is returned.

getAttributeCountback to summary
public int getAttributeCount()

Implements javax.swing.text.AttributeSet.getAttributeCount.

Doc from javax.swing.text.AttributeSet.getAttributeCount.

Returns the number of attributes that are defined locally in this set. Attributes that are defined in the parent set are not included.

getAttributeNamesback to summary
public Enumeration<?> getAttributeNames()

Implements javax.swing.text.AttributeSet.getAttributeNames.

Doc from javax.swing.text.AttributeSet.getAttributeNames.

Returns an enumeration over the names of the attributes that are defined locally in the set. Names of attributes defined in the resolving parent, if any, are not included. The values of the Enumeration may be anything and are not constrained to a particular Object type.

This method never returns null. For a set with no attributes, it returns an empty Enumeration.

getResolveParentback to summary
public AttributeSet getResolveParent()

Implements javax.swing.text.AttributeSet.getResolveParent.

Doc from javax.swing.text.AttributeSet.getResolveParent.

Gets the resolving parent.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
isDefinedback to summary
public boolean isDefined(Object attrName)

Implements javax.swing.text.AttributeSet.isDefined.

Doc from javax.swing.text.AttributeSet.isDefined.

Checks whether the named attribute has a value specified in the set without resolving through another attribute set.

isEqualback to summary
public boolean isEqual(AttributeSet attr)

Implements javax.swing.text.AttributeSet.isEqual.

Doc from javax.swing.text.AttributeSet.isEqual.

Determines if the two attribute sets are equivalent.