View Javadoc
1   /*
2    * Copyright (c) 2000, 2013, Oracle and/or its affiliates. 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.  Oracle designates this
8    * particular file as subject to the "Classpath" exception as provided
9    * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22   * or visit www.oracle.com if you need additional information or have any
23   * questions.
24   */
25  
26  
27  package javax.print.attribute;
28  
29  /**
30   * Interface DocAttributeSet specifies the interface for a set of doc
31   * attributes, i.e. printing attributes that implement interface {@link
32   * DocAttribute DocAttribute}. In the Print Service API, the client uses a
33   * DocAttributeSet to specify the characteristics of an individual doc and
34   * the print job settings to be applied to an individual doc.
35   * <P>
36   * A DocAttributeSet is just an {@link AttributeSet AttributeSet} whose
37   * constructors and mutating operations guarantee an additional invariant,
38   * namely that all attribute values in the DocAttributeSet must be instances
39   * of interface {@link DocAttribute DocAttribute}.
40   * The {@link #add(Attribute) add(Attribute)}, and
41   * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations
42   * are respecified below to guarantee this additional invariant.
43   * <P>
44   *
45   * @author  Alan Kaminsky
46   */
47  public interface DocAttributeSet extends AttributeSet {
48  
49  
50      /**
51       * Adds the specified attribute value to this attribute set if it is not
52       * already present, first removing any existing value in the same
53       * attribute category as the specified attribute value (optional
54       * operation).
55       *
56       * @param  attribute  Attribute value to be added to this attribute set.
57       *
58       * @return  <tt>true</tt> if this attribute set changed as a result of
59       *          the call, i.e., the given attribute value was not already a
60       *          member of this attribute set.
61       *
62       * @throws  UnmodifiableSetException
63       *     (unchecked exception) Thrown if this attribute set does not
64       *     support the <CODE>add()</CODE> operation.
65       * @throws  ClassCastException
66       *     (unchecked exception) Thrown if the <CODE>attribute</CODE> is
67       *     not an instance of interface
68       *     {@link DocAttribute DocAttribute}.
69       * @throws  NullPointerException
70       *    (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
71       */
72      public boolean add(Attribute attribute);
73  
74      /**
75       * Adds all of the elements in the specified set to this attribute.
76       * The outcome is  the same as if the
77       * {@link #add(Attribute) add(Attribute)}
78       * operation had been applied to this attribute set successively with
79       * each element from the specified set. If none of the categories in the
80       * specified set  are the same as any categories in this attribute set,
81       * the <tt>addAll()</tt> operation effectively modifies this attribute
82       * set so that its value is the <i>union</i> of the two sets.
83       * <P>
84       * The behavior of the <CODE>addAll()</CODE> operation is unspecified if
85       * the specified set is modified while the operation is in progress.
86       * <P>
87       * If the <CODE>addAll()</CODE> operation throws an exception, the effect
88       * on this attribute set's state is implementation dependent; elements
89       * from the specified set before the point of the exception may or
90       * may not have been added to this attribute set.
91       *
92       * @param  attributes  whose elements are to be added to this attribute
93       *            set.
94       *
95       * @return  <tt>true</tt> if this attribute set changed as a result of
96       *          the call.
97       *
98       * @throws  UnmodifiableSetException
99       *     (Unchecked exception) Thrown if this attribute set does not
100      *     support the <tt>addAll()</tt> method.
101      * @throws  ClassCastException
102      *     (Unchecked exception) Thrown if some element in the specified
103      *     set is not an instance of interface {@link DocAttribute
104      *     DocAttribute}.
105      * @throws  NullPointerException
106      *     (Unchecked exception) Thrown if the specified  set is null.
107      *
108      * @see #add(Attribute)
109      */
110    public boolean addAll(AttributeSet attributes);
111 }