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