KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > print > attribute > standard > CopiesSupported


1 /*
2  * @(#)CopiesSupported.java 1.7 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.print.attribute.standard;
8
9 import javax.print.attribute.Attribute JavaDoc;
10 import javax.print.attribute.SetOfIntegerSyntax JavaDoc;
11 import javax.print.attribute.SupportedValuesAttribute JavaDoc;
12
13 /**
14  * Class CopiesSupported is a printing attribute class, a set of integers, that
15  * gives the supported values for a {@link Copies Copies} attribute. It is
16  * restricted to a single contiguous range of integers; multiple non-overlapping
17  * ranges are not allowed.
18  * <P>
19  * <B>IPP Compatibility:</B> The CopiesSupported attribute's canonical array
20  * form gives the lower and upper bound for the range of copies to be included
21  * in an IPP "copies-supported" attribute. See class {@link
22  * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
23  * explanation of canonical array form. The category name returned by
24  * <CODE>getName()</CODE> gives the IPP attribute name.
25  * <P>
26  *
27  * @author Alan Kaminsky
28  */

29 public final class CopiesSupported extends SetOfIntegerSyntax JavaDoc
30     implements SupportedValuesAttribute JavaDoc {
31
32     private static final long serialVersionUID = 6927711687034846001L;
33
34     /**
35      * Construct a new copies supported attribute containing a single integer.
36      * That is, only the one value of Copies is supported.
37      *
38      * @param member Set member.
39      *
40      * @exception IllegalArgumentException
41      * (Unchecked exception) Thrown if <CODE>member</CODE> is less than 1.
42      */

43     public CopiesSupported(int member) {
44     super (member);
45     if (member < 1) {
46         throw new IllegalArgumentException JavaDoc("Copies value < 1 specified");
47     }
48     }
49
50     /**
51      * Construct a new copies supported attribute containing a single range of
52      * integers. That is, only those values of Copies in the one range are
53      * supported.
54      *
55      * @param lowerBound Lower bound of the range.
56      * @param upperBound Upper bound of the range.
57      *
58      * @exception IllegalArgumentException
59      * (Unchecked exception) Thrown if a null range is specified or if a
60      * non-null range is specified with <CODE>lowerBound</CODE> less than
61      * 1.
62      */

63     public CopiesSupported(int lowerBound, int upperBound) {
64     super(lowerBound, upperBound);
65     
66     if (lowerBound > upperBound) {
67         throw new IllegalArgumentException JavaDoc("Null range specified");
68     } else if (lowerBound < 1) {
69         throw new IllegalArgumentException JavaDoc("Copies value < 1 specified");
70     }
71     }
72
73     /**
74      * Returns whether this copies supported attribute is equivalent to the
75      * passed in object. To be equivalent, all of the following conditions must
76      * be true:
77      * <OL TYPE=1>
78      * <LI>
79      * <CODE>object</CODE> is not null.
80      * <LI>
81      * <CODE>object</CODE> is an instance of class CopiesSupported.
82      * <LI>
83      * This copies supported attribute's members and <CODE>object</CODE>'s
84      * members are the same.
85      * </OL>
86      *
87      * @param object Object to compare to.
88      *
89      * @return True if <CODE>object</CODE> is equivalent to this copies
90      * supported attribute, false otherwise.
91      */

92     public boolean equals(Object JavaDoc object) {
93     return super.equals (object) && object instanceof CopiesSupported JavaDoc;
94     }
95
96     /**
97      * Get the printing attribute class which is to be used as the "category"
98      * for this printing attribute value.
99      * <P>
100      * For class CopiesSupported, the category
101      * is class CopiesSupported itself.
102      *
103      * @return Printing attribute class (category), an instance of class
104      * {@link java.lang.Class java.lang.Class}.
105      */

106     public final Class JavaDoc<? extends Attribute JavaDoc> getCategory() {
107     return CopiesSupported JavaDoc.class;
108     }
109
110     /**
111      * Get the name of the category of which this attribute value is an
112      * instance.
113      * <P>
114      * For class CopiesSupported, the category
115      * name is <CODE>"copies-supported"</CODE>.
116      *
117      * @return Attribute category name.
118      */

119     public final String JavaDoc getName() {
120     return "copies-supported";
121     }
122     
123 }
124
Popular Tags