KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > text > AttributeSet


1 /*
2  * @(#)AttributeSet.java 1.40 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.swing.text;
8
9 import java.util.Enumeration JavaDoc;
10
11 /**
12  * A collection of unique attributes. This is a read-only,
13  * immutable interface. An attribute is basically a key and
14  * a value assigned to the key. The collection may represent
15  * something like a style run, a logical style, etc. These
16  * are generally used to describe features that will contribute
17  * to some graphical representation such as a font. The
18  * set of possible keys is unbounded and can be anything.
19  * Typically View implementations will respond to attribute
20  * definitions and render something to represent the attributes.
21  * <p>
22  * Attributes can potentially resolve in a hierarchy. If a
23  * key doesn't resolve locally, and a resolving parent
24  * exists, the key will be resolved through the parent.
25  *
26  * @author Timothy Prinzing
27  * @version 1.40 05/05/04
28  * @see MutableAttributeSet
29  */

30 public interface AttributeSet {
31
32     /**
33      * This interface is the type signature that is expected
34      * to be present on any attribute key that contributes to
35      * the determination of what font to use to render some
36      * text. This is not considered to be a closed set, the
37      * definition can change across version of the platform and can
38      * be amended by additional user added entries that
39      * correspond to logical settings that are specific to
40      * some type of content.
41      */

42     public interface FontAttribute {
43     }
44
45     /**
46      * This interface is the type signature that is expected
47      * to be present on any attribute key that contributes to
48      * presentation of color.
49      */

50     public interface ColorAttribute {
51     }
52
53     /**
54      * This interface is the type signature that is expected
55      * to be present on any attribute key that contributes to
56      * character level presentation. This would be any attribute
57      * that applies to a so-called <term>run</term> of
58      * style.
59      */

60     public interface CharacterAttribute {
61     }
62
63     /**
64      * This interface is the type signature that is expected
65      * to be present on any attribute key that contributes to
66      * the paragraph level presentation.
67      */

68     public interface ParagraphAttribute {
69     }
70
71     /**
72      * Returns the number of attributes contained in this set.
73      *
74      * @return the number of attributes >= 0
75      */

76     public int getAttributeCount();
77
78     /**
79      * Checks whether the named attribute has a value specified in
80      * the set without resolving through another attribute
81      * set.
82      *
83      * @param attrName the attribute name
84      * @return true if the attribute has a value specified
85      */

86     public boolean isDefined(Object JavaDoc attrName);
87
88     /**
89      * Determines if the two attribute sets are equivalent.
90      *
91      * @param attr an attribute set
92      * @return true if the sets are equivalent
93      */

94     public boolean isEqual(AttributeSet JavaDoc attr);
95
96     /**
97      * Returns an attribute set that is guaranteed not
98      * to change over time.
99      *
100      * @return a copy of the attribute set
101      */

102     public AttributeSet JavaDoc copyAttributes();
103
104     /**
105      * Fetches the value of the given attribute. If the value is not found
106      * locally, the search is continued upward through the resolving
107      * parent (if one exists) until the value is either
108      * found or there are no more parents. If the value is not found,
109      * null is returned.
110      *
111      * @param key the non-null key of the attribute binding
112      * @return the value
113      */

114     public Object JavaDoc getAttribute(Object JavaDoc key);
115
116     /**
117      * Returns an enumeration over the names of the attributes in the set.
118      * The values of the <code>Enumeration</code> may be anything
119      * and are not constrained to a particular <code>Object</code> type.
120      * The set does not include the resolving parent, if one is defined.
121      *
122      * @return the names
123      */

124     public Enumeration JavaDoc<?> getAttributeNames();
125
126     /**
127      * Returns true if this set contains this attribute with an equal value.
128      *
129      * @param name the non-null attribute name
130      * @param value the value
131      * @return true if the set contains the attribute with an equal value
132      */

133     public boolean containsAttribute(Object JavaDoc name, Object JavaDoc value);
134
135     /**
136      * Returns true if this set contains all the attributes with equal values.
137      *
138      * @param attributes the set of attributes to check against
139      * @return true if this set contains all the attributes with equal values
140      */

141     public boolean containsAttributes(AttributeSet JavaDoc attributes);
142
143     /**
144      * Gets the resolving parent.
145      *
146      * @return the parent
147      */

148     public AttributeSet JavaDoc getResolveParent();
149
150     /**
151      * Attribute name used to name the collection of
152      * attributes.
153      */

154     public static final Object JavaDoc NameAttribute = StyleConstants.NameAttribute;
155
156     /**
157      * Attribute name used to identify the resolving parent
158      * set of attributes, if one is defined.
159      */

160     public static final Object JavaDoc ResolveAttribute = StyleConstants.ResolveAttribute;
161
162 }
163
Popular Tags