1. /*
  2. * @(#)AttributeSet.java 1.33 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing.text;
  11. import java.util.Enumeration;
  12. /**
  13. * A collection of unique attributes. This is a read-only,
  14. * immutable interface. An attribute is basically a key and
  15. * a value assigned to the key. The collection may represent
  16. * something like a style run, a logical style, etc. These
  17. * are generally used to describe features that will contribute
  18. * to some graphical representation such as a font. The
  19. * set of possible keys is unbounded and can be anything.
  20. * Typically View implementations will respond to attribute
  21. * definitions and render something to represent the attributes.
  22. * <p>
  23. * Attributes can potentially resolve in a hierarchy. If a
  24. * key doesn't resolve locally, and a resolving parent
  25. * exists, the key will be resolved through the parent.
  26. *
  27. * @author Timothy Prinzing
  28. * @version 1.33 02/02/00
  29. * @see MutableAttributeSet
  30. */
  31. public interface AttributeSet {
  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 ammended 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. * This interface is the type signature that is expected
  46. * to be present on any attribute key that contributes to
  47. * presentation of color.
  48. */
  49. public interface ColorAttribute {
  50. }
  51. /**
  52. * This interface is the type signature that is expected
  53. * to be present on any attribute key that contributes to
  54. * character level presentation. This would be any attribute
  55. * that applies to a so-called <term>run</term> of
  56. * style.
  57. */
  58. public interface CharacterAttribute {
  59. }
  60. /**
  61. * This interface is the type signature that is expected
  62. * to be present on any attribute key that contributes to
  63. * the paragraph level presentation.
  64. */
  65. public interface ParagraphAttribute {
  66. }
  67. /**
  68. * Returns the number of attributes contained in this set.
  69. *
  70. * @return the number of attributes >= 0
  71. */
  72. public int getAttributeCount();
  73. /**
  74. * Checks whether the named attribute has a value specified in
  75. * the set without resolving through another attribute
  76. * set.
  77. *
  78. * @param attrName the attribute name
  79. * @return true if the attribute has a value specified
  80. */
  81. public boolean isDefined(Object attrName);
  82. /**
  83. * Determines if the two attribute sets are equivalent.
  84. *
  85. * @param attr an attribute set
  86. * @return true if the sets are equivalent
  87. */
  88. public boolean isEqual(AttributeSet attr);
  89. /**
  90. * Returns an attribute set that is guaranteed not
  91. * to change over time.
  92. *
  93. * @return a copy of the attribute set
  94. */
  95. public AttributeSet copyAttributes();
  96. /**
  97. * Fetches the value of the given attribute. If the value is not found
  98. * locally, the search is continued upward through the resolving
  99. * parent (if one exists) until the value is either
  100. * found or there are no more parents. If the value is not found,
  101. * null is returned.
  102. *
  103. * @param key the non-null key of the attribute binding
  104. * @return the value
  105. */
  106. public Object getAttribute(Object key);
  107. /**
  108. * Returns an enumeration over the names of the attributes in the set.
  109. * The elements of the enumeration are all Strings. The set does
  110. * not include the resolving parent, if one is defined.
  111. *
  112. * @return the names
  113. */
  114. public Enumeration getAttributeNames();
  115. /**
  116. * Returns true if this set contains this attribute with an equal value.
  117. *
  118. * @param name the non-null attribute name
  119. * @param value the value
  120. * @return true if the set contains the attribute with an equal value
  121. */
  122. public boolean containsAttribute(Object name, Object value);
  123. /**
  124. * Returns true if this set contains all the attributes with equal values.
  125. *
  126. * @param attributes the set of attributes to check against
  127. * @return true if this set contains all the attributes with equal values
  128. */
  129. public boolean containsAttributes(AttributeSet attributes);
  130. /**
  131. * Gets the resolving parent.
  132. *
  133. * @return the parent
  134. */
  135. public AttributeSet getResolveParent();
  136. /**
  137. * Attribute name used to name the collection of
  138. * attributes.
  139. */
  140. public static final Object NameAttribute = StyleConstants.NameAttribute;
  141. /**
  142. * Attribute name used to identifiy the resolving parent
  143. * set of attributes, if one is defined.
  144. */
  145. public static final Object ResolveAttribute = StyleConstants.ResolveAttribute;
  146. }