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

public Interface AttributeSet

Known Direct Subinterfaces
javax.swing.text.MutableAttributeSet
Known Direct Implementers
javax.swing.text.SimpleAttributeSet.EmptyAttributeSet, javax.swing.text.StyleContext.SmallAttributeSet, javax.swing.text.html.MuxingAttributeSet, javax.swing.text.rtf.MockAttributeSet
Imports
java.util.Enumeration

A collection of unique attributes. This is a read-only, immutable interface. An attribute is basically a key and a value assigned to the key. The collection may represent something like a style run, a logical style, etc. These are generally used to describe features that will contribute to some graphical representation such as a font. The set of possible keys is unbounded and can be anything. Typically View implementations will respond to attribute definitions and render something to represent the attributes.

Attributes can potentially resolve in a hierarchy. If a key doesn't resolve locally, and a resolving parent exists, the key will be resolved through the parent.

Author
Timothy Prinzing
See Also
MutableAttributeSet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
AttributeSet.CharacterAttribute

This interface is the type signature that is expected to be present on any attribute key that contributes to character level presentation.

public static interface
AttributeSet.ColorAttribute

This interface is the type signature that is expected to be present on any attribute key that contributes to presentation of color.

public static interface
AttributeSet.FontAttribute

This interface is the type signature that is expected to be present on any attribute key that contributes to the determination of what font to use to render some text.

public static interface
AttributeSet.ParagraphAttribute

This interface is the type signature that is expected to be present on any attribute key that contributes to the paragraph level presentation.

Field Summary

Modifier and TypeField and Description
public static final Object
NameAttribute

Attribute name used to name the collection of attributes.

public static final Object
ResolveAttribute

Attribute name used to identify the resolving parent set of attributes, if one is defined.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the set defines the attribute with an equal value, either locally or through its resolving parent
containsAttribute
(Object
the non-null attribute name
name
,
Object
the value
value
)

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

public boolean

Returns:

true if this set defines all the attributes with equal values, either locally or through its resolving parent
containsAttributes
(AttributeSet
the set of attributes to check against
attributes
)

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

public AttributeSet

Returns:

a copy of the attribute set
copyAttributes
()

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

public Object

Returns:

the value of the attribute, or null if not found
getAttribute
(Object
the non-null key of the attribute binding
key
)

Fetches the value of the given attribute.

public int

Returns:

the number of attributes >= 0
getAttributeCount
()

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

public Enumeration<?>

Returns:

the names
getAttributeNames
()

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

public AttributeSet

Returns:

the parent
getResolveParent
()

Gets the resolving parent.

public boolean

Returns:

true if the attribute has a value specified
isDefined
(Object
the attribute name
attrName
)

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

public boolean

Returns:

true if the sets are equivalent
isEqual
(AttributeSet
an attribute set
attr
)

Determines if the two attribute sets are equivalent.

Field Detail

NameAttributeback to summary
public static final Object NameAttribute

Attribute name used to name the collection of attributes.

ResolveAttributeback to summary
public static final Object ResolveAttribute

Attribute name used to identify the resolving parent set of attributes, if one is defined.

Method Detail

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

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.

Parameters
name:Object

the non-null attribute name

value:Object

the value

Returns:boolean

true if the set defines the attribute with an equal value, either locally or through its resolving parent

Exceptions
NullPointerException:
if either name or value is null
containsAttributesback to summary
public boolean containsAttributes(AttributeSet attributes)

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.

Parameters
attributes:AttributeSet

the set of attributes to check against

Returns:boolean

true if this set defines all the attributes with equal values, either locally or through its resolving parent

Exceptions
NullPointerException:
if attributes is null
copyAttributesback to summary
public AttributeSet copyAttributes()

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

Returns:AttributeSet

a copy of the attribute set

getAttributeback to summary
public Object getAttribute(Object key)

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.

Parameters
key:Object

the non-null key of the attribute binding

Returns:Object

the value of the attribute, or null if not found

getAttributeCountback to summary
public int getAttributeCount()

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

Returns:int

the number of attributes >= 0

getAttributeNamesback to summary
public Enumeration<?> 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.

Returns:Enumeration<?>

the names

getResolveParentback to summary
public AttributeSet getResolveParent()

Gets the resolving parent.

Returns:AttributeSet

the parent

isDefinedback to summary
public boolean isDefined(Object attrName)

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

Parameters
attrName:Object

the attribute name

Returns:boolean

true if the attribute has a value specified

isEqualback to summary
public boolean isEqual(AttributeSet attr)

Determines if the two attribute sets are equivalent.

Parameters
attr:AttributeSet

an attribute set

Returns:boolean

true if the sets are equivalent

javax.swing.text back to summary

public Interface AttributeSet.CharacterAttribute

Known Direct Implementers
javax.swing.text.StyleConstants.CharacterConstants, javax.swing.text.StyleConstants.ColorConstants, javax.swing.text.StyleConstants.FontConstants

This interface is the type signature that is expected to be present on any attribute key that contributes to character level presentation. This would be any attribute that applies to a so-called run of style.
javax.swing.text back to summary

public Interface AttributeSet.ColorAttribute

Known Direct Implementers
javax.swing.text.StyleConstants.ColorConstants

This interface is the type signature that is expected to be present on any attribute key that contributes to presentation of color.
javax.swing.text back to summary

public Interface AttributeSet.FontAttribute

Known Direct Implementers
javax.swing.text.StyleConstants.FontConstants

This interface is the type signature that is expected to be present on any attribute key that contributes to the determination of what font to use to render some text. This is not considered to be a closed set, the definition can change across version of the platform and can be amended by additional user added entries that correspond to logical settings that are specific to some type of content.
javax.swing.text back to summary

public Interface AttributeSet.ParagraphAttribute

Known Direct Implementers
javax.swing.text.StyleConstants.ParagraphConstants

This interface is the type signature that is expected to be present on any attribute key that contributes to the paragraph level presentation.