1 /*
2 * Copyright 2000-2001 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26
27 package javax.print.attribute;
28
29 /**
30 * Interface PrintServiceAttributeSet specifies the interface for a set of
31 * print job attributes, i.e. printing attributes that implement interface
32 * {@link
33 * PrintServiceAttribute PrintServiceAttribute}. In the Print Service API,
34 * the Print Service instance uses a PrintServiceAttributeSet to report the
35 * status of the print service.
36 * <P>
37 * A PrintServiceAttributeSet is just an {@link AttributeSet AttributeSet}
38 * whose constructors and mutating operations guarantee an additional
39 * invariant,
40 * namely that all attribute values in the PrintServiceAttributeSet must be
41 * instances of interface {@link PrintServiceAttribute PrintServiceAttribute}.
42 * The {@link #add(Attribute) <CODE>add(Attribute)</CODE>}, and
43 * {@link #addAll(AttributeSet) <CODE>addAll(AttributeSet)</CODE>} operations
44 * are respecified below to guarantee this additional invariant.
45 * <P>
46 *
47 * @author Alan Kaminsky
48 */
49 public interface PrintServiceAttributeSet extends AttributeSet {
50
51
52
53 /**
54 * Adds the specified attribute value to this attribute set if it is not
55 * already present, first removing any existing value in the same
56 * attribute category as the specified attribute value (optional
57 * operation).
58 *
59 * @param attribute Attribute value to be added to this attribute set.
60 *
61 * @return <tt>true</tt> if this attribute set changed as a result of
62 * the call, i.e., the given attribute value was not already a
63 * member of this attribute set.
64 *
65 * @throws UnmodifiableSetException
66 * (unchecked exception) Thrown if this attribute set does not
67 * support the <CODE>add()</CODE> operation.
68 * @throws ClassCastException
69 * (unchecked exception) Thrown if the <CODE>attribute</CODE> is
70 * not an instance of interface
71 * {@link PrintServiceAttribute PrintServiceAttribute}.
72 * @throws NullPointerException
73 * (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
74 */
75 public boolean add(Attribute attribute);
76
77 /**
78 * Adds all of the elements in the specified set to this attribute.
79 * The outcome is the same as if the
80 * {@link #add(Attribute) <CODE>add(Attribute)</CODE>}
81 * operation had been applied to this attribute set successively with
82 * each element from the specified set. If none of the categories in the
83 * specified set are the same as any categories in this attribute set,
84 * the <tt>addAll()</tt> operation effectively modifies this attribute
85 * set so that its value is the <i>union</i> of the two sets.
86 * <P>
87 * The behavior of the <CODE>addAll()</CODE> operation is unspecified if
88 * the specified set is modified while the operation is in progress.
89 * <P>
90 * If the <CODE>addAll()</CODE> operation throws an exception, the effect
91 * on this attribute set's state is implementation dependent; elements
92 * from the specified set before the point of the exception may or
93 * may not have been added to this attribute set.
94 *
95 * @param attributes whose elements are to be added to this attribute
96 * set.
97 *
98 * @return <tt>true</tt> if this attribute set changed as a result of
99 * the call.
100 *
101 * @throws UnmodifiableSetException
102 * (Unchecked exception) Thrown if this attribute set does not
103 * support the <tt>addAll()</tt> method.
104 * @throws ClassCastException
105 * (Unchecked exception) Thrown if some element in the specified
106 * set is not an instance of interface {@link PrintServiceAttribute
107 * PrintServiceAttribute}.
108 * @throws NullPointerException
109 * (Unchecked exception) Thrown if the specified set is null.
110 *
111 * @see #add(Attribute)
112 */
113 public boolean addAll(AttributeSet attributes);
114 }