1. /*
  2. * @(#)PrintServiceAttributeSet.java 1.4 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.print.attribute;
  8. /**
  9. * Interface PrintServiceAttributeSet specifies the interface for a set of
  10. * print job attributes, i.e. printing attributes that implement interface
  11. * {@link
  12. * PrintServiceAttribute PrintServiceAttribute}. In the Print Service API,
  13. * the Print Service instance uses a PrintServiceAttributeSet to report the
  14. * status of the print service.
  15. * <P>
  16. * A PrintServiceAttributeSet is just an {@link AttributeSet AttributeSet}
  17. * whose constructors and mutating operations guarantee an additional
  18. * invariant,
  19. * namely that all attribute values in the PrintServiceAttributeSet must be
  20. * instances of interface {@link PrintServiceAttribute PrintServiceAttribute}.
  21. * The {@link #add(Attribute) <CODE>add(Attribute)</CODE>}, and
  22. * {@link #addAll(AttributeSet) <CODE>addAll(AttributeSet)</CODE>} operations
  23. * are respecified below to guarantee this additional invariant.
  24. * <P>
  25. *
  26. * @author Alan Kaminsky
  27. */
  28. public interface PrintServiceAttributeSet extends AttributeSet {
  29. /**
  30. * Adds the specified attribute value to this attribute set if it is not
  31. * already present, first removing any existing value in the same
  32. * attribute category as the specified attribute value (optional
  33. * operation).
  34. *
  35. * @param attribute Attribute value to be added to this attribute set.
  36. *
  37. * @return <tt>true</tt> if this attribute set changed as a result of
  38. * the call, i.e., the given attribute value was not already a
  39. * member of this attribute set.
  40. *
  41. * @throws UnmodifiableSetException
  42. * (unchecked exception) Thrown if this attribute set does not
  43. * support the <CODE>add()</CODE> operation.
  44. * @throws ClassCastException
  45. * (unchecked exception) Thrown if the <CODE>attribute</CODE> is
  46. * not an instance of interface
  47. * {@link PrintServiceAttribute PrintServiceAttribute}.
  48. * @throws NullPointerException
  49. * (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
  50. */
  51. public boolean add(Attribute attribute);
  52. /**
  53. * Adds all of the elements in the specified set to this attribute.
  54. * The outcome is the same as if the
  55. * {@link #add(Attribute) <CODE>add(Attribute)</CODE>}
  56. * operation had been applied to this attribute set successively with
  57. * each element from the specified set. If none of the categories in the
  58. * specified set are the same as any categories in this attribute set,
  59. * the <tt>addAll()</tt> operation effectively modifies this attribute
  60. * set so that its value is the <i>union</i> of the two sets.
  61. * <P>
  62. * The behavior of the <CODE>addAll()</CODE> operation is unspecified if
  63. * the specified set is modified while the operation is in progress.
  64. * <P>
  65. * If the <CODE>addAll()</CODE> operation throws an exception, the effect
  66. * on this attribute set's state is implementation dependent; elements
  67. * from the specified set before the point of the exception may or
  68. * may not have been added to this attribute set.
  69. *
  70. * @param attributes whose elements are to be added to this attribute
  71. * set.
  72. *
  73. * @return <tt>true</tt> if this attribute set changed as a result of
  74. * the call.
  75. *
  76. * @throws UnmodifiableSetException
  77. * (Unchecked exception) Thrown if this attribute set does not
  78. * support the <tt>addAll()</tt> method.
  79. * @throws ClassCastException
  80. * (Unchecked exception) Thrown if some element in the specified
  81. * set is not an instance of interface {@link PrintServiceAttribute
  82. * PrintServiceAttribute}.
  83. * @throws NullPointerException
  84. * (Unchecked exception) Thrown if the specified set is null.
  85. *
  86. * @see #add(Attribute)
  87. */
  88. public boolean addAll(AttributeSet attributes);
  89. }