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 
26 package javax.print.attribute.standard;
27 
28 import javax.print.attribute.Attribute;
29 import javax.print.attribute.EnumSyntax;
30 
31 /**
32  * Class {@code PrinterStateReason} is a printing attribute class, an
33  * enumeration, that provides additional information about the printer's current
34  * state, i.e., information that augments the value of the printer's
35  * {@link PrinterState PrinterState} attribute. Class PrinterStateReason defines
36  * standard printer state reason values. A Print Service implementation only
37  * needs to report those printer state reasons which are appropriate for the
38  * particular implementation; it does not have to report every defined printer
39  * state reason.
40  * <p>
41  * Instances of {@code PrinterStateReason} do not appear in a Print Service's
42  * attribute set directly. Rather, a
43  * {@link PrinterStateReasons PrinterStateReasons} attribute appears in the
44  * Print Service's attribute set. The
45  * {@link PrinterStateReasons PrinterStateReasons} attribute contains zero, one,
46  * or more than one {@code PrinterStateReason} objects which pertain to the
47  * Print Service's status, and each PrinterStateReason object is associated with
48  * a {@link Severity Severity} level of {@code REPORT} (least severe),
49  * {@code WARNING}, or {@code ERROR} (most severe). The printer adds a
50  * {@code PrinterStateReason} object to the Print Service's
51  * {@link PrinterStateReasons PrinterStateReasons} attribute when the
52  * corresponding condition becomes true of the printer, and the printer removes
53  * the {@code PrinterStateReason} object again when the corresponding condition
54  * becomes false, regardless of whether the Print Service's overall
55  * {@link PrinterState PrinterState} also changed.
56  * <p>
57  * <b>IPP Compatibility:</b> The string values returned by each individual
58  * {@link PrinterStateReason} and associated {@link Severity} object's
59  * {@code toString()} methods, concatenated together with a hyphen ({@code "-"})
60  * in between, gives the IPP keyword value for a {@link PrinterStateReasons}.
61  * The category name returned by {@code getName()} gives the IPP attribute name.
62  *
63  * @author Alan Kaminsky
64  */
65 public class PrinterStateReason extends EnumSyntax implements Attribute {
66 
67     /**
68      * Use serialVersionUID from JDK 1.4 for interoperability.
69      */
70     private static final long serialVersionUID = -1623720656201472593L;
71 
72     /**
73      * The printer has detected an error other than ones listed below.
74      */
75     public static final PrinterStateReason OTHER = new PrinterStateReason(0);
76 
77     /**
78      * A tray has run out of media.
79      */
80     public static final PrinterStateReason
81         MEDIA_NEEDED = new PrinterStateReason(1);
82 
83     /**
84      * The device has a media jam.
85      */
86     public static final PrinterStateReason
87         MEDIA_JAM = new PrinterStateReason(2);
88 
89     /**
90      * Someone has paused the printer, but the device(s) are taking an
91      * appreciable time to stop. Later, when all output has stopped, the
92      * {@link PrinterState PrinterState} becomes {@code STOPPED}, and the
93      * {@code PAUSED} value replaces the {@code MOVING_TO_PAUSED} value in the
94      * {@link PrinterStateReasons PrinterStateReasons} attribute. This value
95      * must be supported if the printer can be paused and the implementation
96      * takes significant time to pause a device in certain circumstances.
97      */
98     public static final PrinterStateReason
99         MOVING_TO_PAUSED = new PrinterStateReason(3);
100 
101     /**
102      * Someone has paused the printer and the printer's
103      * {@link PrinterState PrinterState} is {@code STOPPED}. In this state, a
104      * printer must not produce printed output, but it must perform other
105      * operations requested by a client. If a printer had been printing a job
106      * when the printer was paused, the {@code Printer} must resume printing
107      * that job when the printer is no longer paused and leave no evidence in
108      * the printed output of such a pause. This value must be supported if the
109      * printer can be paused.
110      */
111     public static final PrinterStateReason
112         PAUSED = new PrinterStateReason(4);
113 
114     /**
115      * Someone has removed a printer from service, and the device may be powered
116      * down or physically removed. In this state, a printer must not produce
117      * printed output, and unless the printer is realized by a print server that
118      * is still active, the printer must perform no other operations requested
119      * by a client. If a printer had been printing a job when it was shut down,
120      * the printer need not resume printing that job when the printer is no
121      * longer shut down. If the printer resumes printing such a job, it may
122      * leave evidence in the printed output of such a shutdown, e.g. the part
123      * printed before the shutdown may be printed a second time after the
124      * shutdown.
125      */
126     public static final PrinterStateReason
127         SHUTDOWN = new PrinterStateReason(5);
128 
129     /**
130      * The printer has scheduled a job on the output device and is in the
131      * process of connecting to a shared network output device (and might not be
132      * able to actually start printing the job for an arbitrarily long time
133      * depending on the usage of the output device by other servers on the
134      * network).
135      */
136     public static final PrinterStateReason
137         CONNECTING_TO_DEVICE = new PrinterStateReason(6);
138 
139     /**
140      * The server was able to connect to the output device (or is always
141      * connected), but was unable to get a response from the output device.
142      */
143     public static final PrinterStateReason
144         TIMED_OUT = new PrinterStateReason(7);
145 
146     /**
147      * The printer is in the process of stopping the device and will be stopped
148      * in a while. When the device is stopped, the printer will change the
149      * {@link PrinterState PrinterState} to {@code STOPPED}. The
150      * {@code STOPPING} reason is never an error, even for a printer with a
151      * single output device. When an output device ceases accepting jobs, the
152      * printer's {@link PrinterStateReasons PrinterStateReasons} will have this
153      * reason while the output device completes printing.
154      */
155     public static final PrinterStateReason
156         STOPPING = new PrinterStateReason(8);
157 
158     /**
159      * When a printer controls more than one output device, this reason
160      * indicates that one or more output devices are stopped. If the reason's
161      * severity is a report, fewer than half of the output devices are stopped.
162      * If the reason's severity is a warning, half or more but fewer than all of
163      * the output devices are stopped.
164      */
165     public static final PrinterStateReason
166         STOPPED_PARTLY = new PrinterStateReason(9);
167 
168     /**
169      * The device is low on toner.
170      */
171     public static final PrinterStateReason
172         TONER_LOW = new PrinterStateReason(10);
173 
174     /**
175      * The device is out of toner.
176      */
177     public static final PrinterStateReason
178         TONER_EMPTY = new PrinterStateReason(11);
179 
180     /**
181      * The limit of persistent storage allocated for spooling has been reached.
182      * The printer is temporarily unable to accept more jobs. The printer will
183      * remove this reason when it is able to accept more jobs. This value should
184      * be used by a non-spooling printer that only accepts one or a small number
185      * jobs at a time or a spooling printer that has filled the spool space.
186      */
187     public static final PrinterStateReason
188         SPOOL_AREA_FULL = new PrinterStateReason(12);
189 
190     /**
191      * One or more covers on the device are open.
192      */
193     public static final PrinterStateReason
194         COVER_OPEN = new PrinterStateReason(13);
195 
196     /**
197      * One or more interlock devices on the printer are unlocked.
198      */
199     public static final PrinterStateReason
200         INTERLOCK_OPEN = new PrinterStateReason(14);
201 
202     /**
203      * One or more doors on the device are open.
204      */
205     public static final PrinterStateReason
206         DOOR_OPEN = new PrinterStateReason(15);
207 
208     /**
209      * One or more input trays are not in the device.
210      */
211     public static final PrinterStateReason
212         INPUT_TRAY_MISSING = new PrinterStateReason(16);
213 
214     /**
215      * At least one input tray is low on media.
216      */
217     public static final PrinterStateReason
218         MEDIA_LOW = new PrinterStateReason(17);
219 
220     /**
221      * At least one input tray is empty.
222      */
223     public static final PrinterStateReason
224         MEDIA_EMPTY = new PrinterStateReason(18);
225 
226     /**
227      * One or more output trays are not in the device.
228      */
229     public static final PrinterStateReason
230         OUTPUT_TRAY_MISSING = new PrinterStateReason(19);
231 
232     /**
233      * One or more output areas are almost full (e.g. tray, stacker, collator).
234      */
235     public static final PrinterStateReason
236         OUTPUT_AREA_ALMOST_FULL = new PrinterStateReason(20);
237 
238     /**
239      * One or more output areas are full (e.g. tray, stacker, collator).
240      */
241     public static final PrinterStateReason
242         OUTPUT_AREA_FULL = new PrinterStateReason(21);
243 
244     /**
245      * The device is low on at least one marker supply (e.g. toner, ink,
246      * ribbon).
247      */
248     public static final PrinterStateReason
249         MARKER_SUPPLY_LOW = new PrinterStateReason(22);
250 
251     /**
252      * The device is out of at least one marker supply (e.g. toner, ink,
253      * ribbon).
254      */
255     public static final PrinterStateReason
256         MARKER_SUPPLY_EMPTY = new PrinterStateReason(23);
257 
258     /**
259      * The device marker supply waste receptacle is almost full.
260      */
261     public static final PrinterStateReason
262         MARKER_WASTE_ALMOST_FULL = new PrinterStateReason(24);
263 
264     /**
265      * The device marker supply waste receptacle is full.
266      */
267     public static final PrinterStateReason
268         MARKER_WASTE_FULL = new PrinterStateReason(25);
269 
270     /**
271      * The fuser temperature is above normal.
272      */
273     public static final PrinterStateReason
274         FUSER_OVER_TEMP = new PrinterStateReason(26);
275 
276     /**
277      * The fuser temperature is below normal.
278      */
279     public static final PrinterStateReason
280         FUSER_UNDER_TEMP = new PrinterStateReason(27);
281 
282     /**
283      * The optical photo conductor is near end of life.
284      */
285     public static final PrinterStateReason
286         OPC_NEAR_EOL = new PrinterStateReason(28);
287 
288     /**
289      * The optical photo conductor is no longer functioning.
290      */
291     public static final PrinterStateReason
292         OPC_LIFE_OVER = new PrinterStateReason(29);
293 
294     /**
295      * The device is low on developer.
296      */
297     public static final PrinterStateReason
298         DEVELOPER_LOW = new PrinterStateReason(30);
299 
300     /**
301      * The device is out of developer.
302      */
303     public static final PrinterStateReason
304         DEVELOPER_EMPTY = new PrinterStateReason(31);
305 
306     /**
307      * An interpreter resource is unavailable (e.g., font, form).
308      */
309     public static final PrinterStateReason
310         INTERPRETER_RESOURCE_UNAVAILABLE = new PrinterStateReason(32);
311 
312     /**
313      * Construct a new printer state reason enumeration value with the given
314      * integer value.
315      *
316      * @param  value Integer value
317      */
PrinterStateReason(int value)318     protected PrinterStateReason(int value) {
319         super (value);
320     }
321 
322     /**
323      * The string table for class {@code PrinterStateReason}.
324      */
325     private static final String[] myStringTable = {
326         "other",
327         "media-needed",
328         "media-jam",
329         "moving-to-paused",
330         "paused",
331         "shutdown",
332         "connecting-to-device",
333         "timed-out",
334         "stopping",
335         "stopped-partly",
336         "toner-low",
337         "toner-empty",
338         "spool-area-full",
339         "cover-open",
340         "interlock-open",
341         "door-open",
342         "input-tray-missing",
343         "media-low",
344         "media-empty",
345         "output-tray-missing",
346         "output-area-almost-full",
347         "output-area-full",
348         "marker-supply-low",
349         "marker-supply-empty",
350         "marker-waste-almost-full",
351         "marker-waste-full",
352         "fuser-over-temp",
353         "fuser-under-temp",
354         "opc-near-eol",
355         "opc-life-over",
356         "developer-low",
357         "developer-empty",
358         "interpreter-resource-unavailable"
359     };
360 
361     /**
362      * The enumeration value table for class {@code PrinterStateReason}.
363      */
364     private static final PrinterStateReason[] myEnumValueTable = {
365         OTHER,
366         MEDIA_NEEDED,
367         MEDIA_JAM,
368         MOVING_TO_PAUSED,
369         PAUSED,
370         SHUTDOWN,
371         CONNECTING_TO_DEVICE,
372         TIMED_OUT,
373         STOPPING,
374         STOPPED_PARTLY,
375         TONER_LOW,
376         TONER_EMPTY,
377         SPOOL_AREA_FULL,
378         COVER_OPEN,
379         INTERLOCK_OPEN,
380         DOOR_OPEN,
381         INPUT_TRAY_MISSING,
382         MEDIA_LOW,
383         MEDIA_EMPTY,
384         OUTPUT_TRAY_MISSING,
385         OUTPUT_AREA_ALMOST_FULL,
386         OUTPUT_AREA_FULL,
387         MARKER_SUPPLY_LOW,
388         MARKER_SUPPLY_EMPTY,
389         MARKER_WASTE_ALMOST_FULL,
390         MARKER_WASTE_FULL,
391         FUSER_OVER_TEMP,
392         FUSER_UNDER_TEMP,
393         OPC_NEAR_EOL,
394         OPC_LIFE_OVER,
395         DEVELOPER_LOW,
396         DEVELOPER_EMPTY,
397         INTERPRETER_RESOURCE_UNAVAILABLE
398     };
399 
400     /**
401      * Returns the string table for class {@code PrinterStateReason}.
402      */
getStringTable()403     protected String[] getStringTable() {
404         return myStringTable.clone();
405     }
406 
407     /**
408      * Returns the enumeration value table for class {@code PrinterStateReason}.
409      */
getEnumValueTable()410     protected EnumSyntax[] getEnumValueTable() {
411         return (EnumSyntax[])myEnumValueTable.clone();
412     }
413 
414     /**
415      * Get the printing attribute class which is to be used as the "category"
416      * for this printing attribute value.
417      * <p>
418      * For class {@code PrinterStateReason} and any vendor-defined subclasses,
419      * the category is class {@code PrinterStateReason} itself.
420      *
421      * @return printing attribute class (category), an instance of class
422      *         {@link Class java.lang.Class}
423      */
getCategory()424     public final Class<? extends Attribute> getCategory() {
425         return PrinterStateReason.class;
426     }
427 
428     /**
429      * Get the name of the category of which this attribute value is an
430      * instance.
431      * <p>
432      * For class {@code PrinterStateReason} and any vendor-defined subclasses,
433      * the category name is {@code "printer-state-reason"}.
434      *
435      * @return attribute category name
436      */
getName()437     public final String getName() {
438         return "printer-state-reason";
439     }
440 }
441