JobState.java revision 17757:ad37f4ce2062
1/*
2 * Copyright (c) 2000, 2017, 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
26package javax.print.attribute.standard;
27
28import javax.print.attribute.Attribute;
29import javax.print.attribute.EnumSyntax;
30import javax.print.attribute.PrintJobAttribute;
31
32/**
33 * {@code JobState} is a printing attribute class, an enumeration, that
34 * identifies the current state of a print job. Class {@code JobState} defines
35 * standard job state values. A Print Service implementation only needs to
36 * report those job states which are appropriate for the particular
37 * implementation; it does not have to report every defined job state. The
38 * {@link JobStateReasons JobStateReasons} attribute augments the
39 * {@code JobState} attribute to give more detailed information about the job in
40 * the given job state.
41 * <p>
42 * <b>IPP Compatibility:</b> The category name returned by {@code getName()} is
43 * the IPP attribute name. The enumeration's integer value is the IPP enum
44 * value. The {@code toString()} method returns the IPP string representation of
45 * the attribute value.
46 *
47 * @author Alan Kaminsky
48 */
49public class JobState extends EnumSyntax implements PrintJobAttribute {
50
51    /**
52     * Use serialVersionUID from JDK 1.4 for interoperability.
53     */
54    private static final long serialVersionUID = 400465010094018920L;
55
56    /**
57     * The job state is unknown.
58     */
59    public static final JobState UNKNOWN = new JobState(0);
60
61    /**
62     * The job is a candidate to start processing, but is not yet processing.
63     */
64    public static final JobState PENDING = new JobState(3);
65
66    /**
67     * The job is not a candidate for processing for any number of reasons but
68     * will return to the {@code PENDING} state as soon as the reasons are no
69     * longer present. The job's {@link JobStateReasons JobStateReasons}
70     * attribute must indicate why the job is no longer a candidate for
71     * processing.
72     */
73    public static final JobState PENDING_HELD = new JobState(4);
74
75    /**
76     * The job is processing. One or more of the following activities is
77     * occurring:
78     * <ol type=1>
79     *   <li>The job is using, or is attempting to use, one or more purely
80     *   software processes that are analyzing, creating, or interpreting a PDL,
81     *   etc.
82     *   <li>The job is using, or is attempting to use, one or more hardware
83     *   devices that are interpreting a PDL, making marks on a medium, and/or
84     *   performing finishing, such as stapling, etc.
85     *   <li>The printer has made the job ready for printing, but the output
86     *   device is not yet printing it, either because the job hasn't reached
87     *   the output device or because the job is queued in the output device or
88     *   some other spooler, awaiting the output device to print it.
89     * </ol>
90     * When the job is in the {@code PROCESSING} state, the entire job state
91     * includes the detailed status represented in the printer's
92     * {@link PrinterState PrinterState} and
93     * {@link PrinterStateReasons PrinterStateReasons} attributes.
94     * <p>
95     * Implementations may, though they need not, include additional values in
96     * the job's {@link JobStateReasons JobStateReasons} attribute to indicate
97     * the progress of the job, such as adding the {@code JOB_PRINTING} value to
98     * indicate when the output device is actually making marks on paper and/or
99     * the {@code PROCESSING_TO_STOP_POINT} value to indicate that the printer
100     * is in the process of canceling or aborting the job.
101     */
102    public static final JobState PROCESSING = new JobState (5);
103
104    /**
105     * The job has stopped while processing for any number of reasons and will
106     * return to the {@code PROCESSING} state as soon as the reasons are no
107     * longer present.
108     * <p>
109     * The job's {@link JobStateReasons JobStateReasons} attribute may indicate
110     * why the job has stopped processing. For example, if the output device is
111     * stopped, the {@code PRINTER_STOPPED} value may be included in the job's
112     * {@link JobStateReasons JobStateReasons} attribute.
113     * <p>
114     * <i>Note:</i> When an output device is stopped, the device usually
115     * indicates its condition in human readable form locally at the device. A
116     * client can obtain more complete device status remotely by querying the
117     * printer's {@link PrinterState PrinterState} and
118     * {@link PrinterStateReasons PrinterStateReasons} attributes.
119     */
120    public static final JobState PROCESSING_STOPPED = new JobState (6);
121
122    /**
123     * The job has been canceled by some human agency, the printer has completed
124     * canceling the job, and all job status attributes have reached their final
125     * values for the job. While the printer is canceling the job, the job
126     * remains in its current state, but the job's {@link JobStateReasons
127     * JobStateReasons} attribute should contain the
128     * {@code PROCESSING_TO_STOP_POINT} value and one of the
129     * {@code CANCELED_BY_USER}, {@code CANCELED_BY_OPERATOR}, or
130     * {@code CANCELED_AT_DEVICE} values. When the job moves to the
131     * {@code CANCELED} state, the {@code PROCESSING_TO_STOP_POINT} value, if
132     * present, must be removed, but the CANCELED_BY_<i>xxx</i> value, if
133     * present, must remain.
134     */
135    public static final JobState CANCELED = new JobState (7);
136
137    /**
138     * The job has been aborted by the system (usually while the job was in the
139     * {@code PROCESSING} or {@code PROCESSING_STOPPED} state), the printer has
140     * completed aborting the job, and all job status attributes have reached
141     * their final values for the job. While the printer is aborting the job,
142     * the job remains in its current state, but the job's
143     * {@link JobStateReasons JobStateReasons} attribute should contain the
144     * {@code PROCESSING_TO_STOP_POINT} and {@code ABORTED_BY_SYSTEM} values.
145     * When the job moves to the {@code ABORTED} state, the
146     * {@code PROCESSING_TO_STOP_POINT} value, if present, must be removed, but
147     * the {@code ABORTED_BY_SYSTEM} value, if present, must remain.
148     */
149    public static final JobState ABORTED = new JobState (8);
150
151    /**
152     * The job has completed successfully or with warnings or errors after
153     * processing, all of the job media sheets have been successfully stacked in
154     * the appropriate output bin(s), and all job status attributes have reached
155     * their final values for the job. The job's
156     * {@link JobStateReasons JobStateReasons} attribute should contain one of
157     * these values: {@code COMPLETED_SUCCESSFULLY},
158     * {@code COMPLETED_WITH_WARNINGS}, or {@code COMPLETED_WITH_ERRORS}.
159     */
160    public static final JobState COMPLETED = new JobState (9);
161
162    // Hidden constructors.
163
164    /**
165     * Construct a new job state enumeration value with the given integer value.
166     *
167     * @param  value Integer value
168     */
169    protected JobState(int value) {
170        super (value);
171    }
172
173    /**
174     * The string table for class {@code JobState}.
175     */
176    private static final String[] myStringTable =
177    {"unknown",
178     null,
179     null,
180     "pending",
181     "pending-held",
182     "processing",
183     "processing-stopped",
184     "canceled",
185     "aborted",
186     "completed"};
187
188    /**
189     * The enumeration value table for class {@code JobState}.
190     */
191    private static final JobState[] myEnumValueTable =
192    {UNKNOWN,
193     null,
194     null,
195     PENDING,
196     PENDING_HELD,
197     PROCESSING,
198     PROCESSING_STOPPED,
199     CANCELED,
200     ABORTED,
201     COMPLETED};
202
203    /**
204     * Returns the string table for class {@code JobState}.
205     */
206    protected String[] getStringTable() {
207        return myStringTable;
208    }
209
210    /**
211     * Returns the enumeration value table for class {@code JobState}.
212     */
213    protected EnumSyntax[] getEnumValueTable() {
214        return myEnumValueTable;
215    }
216
217    /**
218     * Get the printing attribute class which is to be used as the "category"
219     * for this printing attribute value.
220     * <p>
221     * For class {@code JobState} and any vendor-defined subclasses, the
222     * category is class {@code JobState} itself.
223     *
224     * @return printing attribute class (category), an instance of class
225     *         {@link Class java.lang.Class}
226     */
227    public final Class<? extends Attribute> getCategory() {
228        return JobState.class;
229    }
230
231    /**
232     * Get the name of the category of which this attribute value is an
233     * instance.
234     * <p>
235     * For class {@code JobState} and any vendor-defined subclasses, the
236     * category name is {@code "job-state"}.
237     *
238     * @return attribute category name
239     */
240    public final String getName() {
241        return "job-state";
242    }
243}
244