KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)JobStateReasons.java 1.8 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 java.util.Collection JavaDoc;
10 import java.util.HashSet JavaDoc;
11
12 import javax.print.attribute.Attribute JavaDoc;
13 import javax.print.attribute.PrintJobAttribute JavaDoc;
14
15 /**
16  * Class JobStateReasons is a printing attribute class, a set of enumeration
17  * values, that provides additional information about the job's current state,
18  * i.e., information that augments the value of the job's {@link JobState
19  * JobState} attribute.
20  * <P>
21  * Instances of {@link JobStateReason JobStateReason} do not appear in a Print
22  * Job's attribute set directly. Rather, a JobStateReasons attribute appears in
23  * the Print Job's attribute set. The JobStateReasons attribute contains zero,
24  * one, or more than one {@link JobStateReason JobStateReason} objects which
25  * pertain to the Print Job's status. The printer adds a {@link JobStateReason
26  * JobStateReason} object to the Print Job's JobStateReasons attribute when the
27  * corresponding condition becomes true of the Print Job, and the printer
28  * removes the {@link JobStateReason JobStateReason} object again when the
29  * corresponding condition becomes false, regardless of whether the Print Job's
30  * overall {@link JobState JobState} also changed.
31  * <P>
32  * Class JobStateReasons inherits its implementation from class {@link
33  * java.util.HashSet java.util.HashSet}. Unlike most printing attributes which
34  * are immutable once constructed, class JobStateReasons is designed to be
35  * mutable; you can add {@link JobStateReason JobStateReason} objects to an
36  * existing JobStateReasons object and remove them again. However, like class
37  * {@link java.util.HashSet java.util.HashSet}, class JobStateReasons is not
38  * multiple thread safe. If a JobStateReasons object will be used by multiple
39  * threads, be sure to synchronize its operations (e.g., using a synchronized
40  * set view obtained from class {@link java.util.Collections
41  * java.util.Collections}).
42  * <P>
43  * <B>IPP Compatibility:</B> The string value returned by each individual {@link
44  * JobStateReason JobStateReason} object's <CODE>toString()</CODE> method gives
45  * the IPP keyword value. The category name returned by <CODE>getName()</CODE>
46  * gives the IPP attribute name.
47  * <P>
48  *
49  * @author Alan Kaminsky
50  */

51 public final class JobStateReasons
52     extends HashSet JavaDoc<JobStateReason JavaDoc> implements PrintJobAttribute JavaDoc {
53
54     private static final long serialVersionUID = 8849088261264331812L;
55
56     /**
57      * Construct a new, empty job state reasons attribute; the underlying hash
58      * set has the default initial capacity and load factor.
59      */

60     public JobStateReasons() {
61     super();
62     }
63
64     /**
65      * Construct a new, empty job state reasons attribute; the underlying hash
66      * set has the given initial capacity and the default load factor.
67      *
68      * @param initialCapacity Initial capacity.
69      * @throws IllegalArgumentException if the initial capacity is less
70      * than zero.
71      */

72     public JobStateReasons(int initialCapacity) {
73     super (initialCapacity);
74     }
75
76     /**
77      * Construct a new, empty job state reasons attribute; the underlying hash
78      * set has the given initial capacity and load factor.
79      *
80      * @param initialCapacity Initial capacity.
81      * @param loadFactor Load factor.
82      * @throws IllegalArgumentException if the initial capacity is less
83      * than zero.
84      */

85     public JobStateReasons(int initialCapacity, float loadFactor) {
86     super (initialCapacity, loadFactor);
87     }
88
89     /**
90      * Construct a new job state reasons attribute that contains the same
91      * {@link JobStateReason JobStateReason} objects as the given collection.
92      * The underlying hash set's initial capacity and load factor are as
93      * specified in the superclass constructor {@link
94      * java.util.HashSet#HashSet(java.util.Collection)
95      * <CODE>HashSet(Collection)</CODE>}.
96      *
97      * @param collection Collection to copy.
98      *
99      * @exception NullPointerException
100      * (unchecked exception) Thrown if <CODE>collection</CODE> is null or
101      * if any element in <CODE>collection</CODE> is null.
102      * @throws ClassCastException
103      * (unchecked exception) Thrown if any element in
104      * <CODE>collection</CODE> is not an instance of class {@link
105      * JobStateReason JobStateReason}.
106      */

107    public JobStateReasons(Collection JavaDoc<JobStateReason JavaDoc> collection) {
108        super (collection);
109    }
110     
111     /**
112      * Adds the specified element to this job state reasons attribute if it is
113      * not already present. The element to be added must be an instance of class
114      * {@link JobStateReason JobStateReason}. If this job state reasons
115      * attribute already contains the specified element, the call leaves this
116      * job state reasons attribute unchanged and returns <tt>false</tt>.
117      *
118      * @param o Element to be added to this job state reasons attribute.
119      *
120      * @return <tt>true</tt> if this job state reasons attribute did not
121      * already contain the specified element.
122      *
123      * @throws NullPointerException
124      * (unchecked exception) Thrown if the specified element is null.
125      * @throws ClassCastException
126      * (unchecked exception) Thrown if the specified element is not an
127      * instance of class {@link JobStateReason JobStateReason}.
128      */

129     public boolean add(JobStateReason JavaDoc o) {
130     if (o == null) {
131         throw new NullPointerException JavaDoc();
132     }
133     return super.add ((JobStateReason JavaDoc) o);
134     }
135
136     /**
137      * Get the printing attribute class which is to be used as the "category"
138      * for this printing attribute value.
139      * <P>
140      * For class JobStateReasons, the category is class JobStateReasons itself.
141      *
142      * @return Printing attribute class (category), an instance of class
143      * {@link java.lang.Class java.lang.Class}.
144      */

145     public final Class JavaDoc<? extends Attribute JavaDoc> getCategory() {
146     return JobStateReasons JavaDoc.class;
147     }
148
149     /**
150      * Get the name of the category of which this attribute value is an
151      * instance.
152      * <P>
153      * For class JobStateReasons, the category
154      * name is <CODE>"job-state-reasons"</CODE>.
155      *
156      * @return Attribute category name.
157      */

158     public final String JavaDoc getName() {
159     return "job-state-reasons";
160     }
161     
162 }
163
Popular Tags