1 /*
2 * Copyright 2000-2004 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 package javax.print.attribute.standard;
26
27 import javax.print.attribute.Attribute;
28 import javax.print.attribute.SetOfIntegerSyntax;
29 import javax.print.attribute.SupportedValuesAttribute;
30
31 /**
32 * Class CopiesSupported is a printing attribute class, a set of integers, that
33 * gives the supported values for a {@link Copies Copies} attribute. It is
34 * restricted to a single contiguous range of integers; multiple non-overlapping
35 * ranges are not allowed.
36 * <P>
37 * <B>IPP Compatibility:</B> The CopiesSupported attribute's canonical array
38 * form gives the lower and upper bound for the range of copies to be included
39 * in an IPP "copies-supported" attribute. See class {@link
40 * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
41 * explanation of canonical array form. The category name returned by
42 * <CODE>getName()</CODE> gives the IPP attribute name.
43 * <P>
44 *
45 * @author Alan Kaminsky
46 */
47 public final class CopiesSupported extends SetOfIntegerSyntax
48 implements SupportedValuesAttribute {
49
50 private static final long serialVersionUID = 6927711687034846001L;
51
52 /**
53 * Construct a new copies supported attribute containing a single integer.
54 * That is, only the one value of Copies is supported.
55 *
56 * @param member Set member.
57 *
58 * @exception IllegalArgumentException
59 * (Unchecked exception) Thrown if <CODE>member</CODE> is less than 1.
60 */
61 public CopiesSupported(int member) {
62 super (member);
63 if (member < 1) {
64 throw new IllegalArgumentException("Copies value < 1 specified");
65 }
66 }
67
68 /**
69 * Construct a new copies supported attribute containing a single range of
70 * integers. That is, only those values of Copies in the one range are
71 * supported.
72 *
73 * @param lowerBound Lower bound of the range.
74 * @param upperBound Upper bound of the range.
75 *
76 * @exception IllegalArgumentException
77 * (Unchecked exception) Thrown if a null range is specified or if a
78 * non-null range is specified with <CODE>lowerBound</CODE> less than
79 * 1.
80 */
81 public CopiesSupported(int lowerBound, int upperBound) {
82 super(lowerBound, upperBound);
83
84 if (lowerBound > upperBound) {
85 throw new IllegalArgumentException("Null range specified");
86 } else if (lowerBound < 1) {
87 throw new IllegalArgumentException("Copies value < 1 specified");
88 }
89 }
90
91 /**
92 * Returns whether this copies supported attribute is equivalent to the
93 * passed in object. To be equivalent, all of the following conditions must
94 * be true:
95 * <OL TYPE=1>
96 * <LI>
97 * <CODE>object</CODE> is not null.
98 * <LI>
99 * <CODE>object</CODE> is an instance of class CopiesSupported.
100 * <LI>
101 * This copies supported attribute's members and <CODE>object</CODE>'s
102 * members are the same.
103 * </OL>
104 *
105 * @param object Object to compare to.
106 *
107 * @return True if <CODE>object</CODE> is equivalent to this copies
108 * supported attribute, false otherwise.
109 */
110 public boolean equals(Object object) {
111 return super.equals (object) && object instanceof CopiesSupported;
112 }
113
114 /**
115 * Get the printing attribute class which is to be used as the "category"
116 * for this printing attribute value.
117 * <P>
118 * For class CopiesSupported, the category
119 * is class CopiesSupported itself.
120 *
121 * @return Printing attribute class (category), an instance of class
122 * {@link java.lang.Class java.lang.Class}.
123 */
124 public final Class<? extends Attribute> getCategory() {
125 return CopiesSupported.class;
126 }
127
128 /**
129 * Get the name of the category of which this attribute value is an
130 * instance.
131 * <P>
132 * For class CopiesSupported, the category
133 * name is <CODE>"copies-supported"</CODE>.
134 *
135 * @return Attribute category name.
136 */
137 public final String getName() {
138 return "copies-supported";
139 }
140
141 }