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 package javax.print.attribute.standard;
  26 
  27 import javax.print.attribute.EnumSyntax;
  28 import javax.print.attribute.Attribute;
  29 
  30 /**
  31  * Class JobStateReason is a printing attribute class, an enumeration, that
  32  * provides additional information about the job's current state, i.e.,
  33  * information that augments the value of the job's {@link JobState JobState}
  34  * attribute. Class JobStateReason defines standard job state reason values. A
  35  * Print Service implementation only needs to report those job state
  36  * reasons which are appropriate for the particular implementation; it does not
  37  * have to report every defined job state reason.
  38  * <P>
  39  * Instances of JobStateReason do not appear in a Print Job's attribute set
  40  * directly. Rather, a {@link JobStateReasons JobStateReasons} attribute appears
  41  * in the Print Job's attribute set. The {@link JobStateReasons JobStateReasons}
  42  * attribute contains zero, one, or more than one JobStateReason objects which
  43  * pertain to the Print Job's status. The printer adds a JobStateReason object
  44  * to the Print Job's {@link JobStateReasons JobStateReasons} attribute when the
  45  * corresponding condition becomes true of the Print Job, and the printer
  46  * removes the JobStateReason object again when the corresponding condition
  47  * becomes false, regardless of whether the Print Job's overall {@link JobState
  48  * JobState} also changed.
  49  * <P>
  50  * <B>IPP Compatibility:</B> The category name returned by
  51  * {@code getName()} is the IPP attribute name.  The enumeration's
  52  * integer value is the IPP enum value.  The {@code toString()} method
  53  * returns the IPP string representation of the attribute value.
  54  *
  55  * @author  Alan Kaminsky
  56  */
  57 public class JobStateReason extends EnumSyntax implements Attribute {
  58 
  59     private static final long serialVersionUID = -8765894420449009168L;
  60 
  61     /**
  62      * The printer has created the Print Job, but the printer has not finished
  63      * accessing or accepting all the print data yet.
  64      */
  65     public static final JobStateReason
  66         JOB_INCOMING = new JobStateReason(0);
  67 
  68     /**
  69      * The printer has created the Print Job, but the printer is expecting
  70      * additional print data before it can move the job into the PROCESSING
  71      * state. If a printer starts processing before it has received all data,
  72      * the printer removes the JOB_DATA_INSUFFICIENT reason, but the
  73      * JOB_INCOMING reason remains. If a printer starts processing after it
  74      * has received all data, the printer removes the JOB_DATA_INSUFFICIENT
  75      * and JOB_INCOMING reasons at the same time.
  76      */
  77     public static final JobStateReason
  78         JOB_DATA_INSUFFICIENT = new JobStateReason(1);
  79 
  80     /**
  81      * The Printer could not access one or more documents passed by reference
  82      * (i.e., the print data representation object is a URL). This reason is
  83      * intended to cover any file access problem,including file does not exist
  84      * and access denied because of an access control problem. Whether the
  85      * printer aborts the job and moves the job to the ABORTED job state or
  86      * prints all documents that are accessible and moves the job to the
  87      * COMPLETED job state and adds the COMPLETED_WITH_ERRORS reason to the
  88      * job's {@link JobStateReasons JobStateReasons} attribute depends on
  89      * implementation and/or site policy. This value should be supported if
  90      * the printer supports doc flavors with URL print data representation
  91      * objects.
  92      */
  93     public static final JobStateReason
  94         DOCUMENT_ACCESS_ERROR = new JobStateReason(2);
  95 
  96     /**
  97      * The job was not completely submitted for some unforeseen reason.
  98      * Possibilities include (1) the printer has crashed before the job was
  99      * fully submitted by the client, (2) the printer or the document transfer
 100      * method has crashed in some non-recoverable way before the document data
 101      * was entirely transferred to the printer, (3) the client crashed before
 102      * the job was fully submitted.
 103      */
 104     public static final JobStateReason
 105         SUBMISSION_INTERRUPTED = new JobStateReason(3);
 106 
 107     /**
 108      * The printer is transmitting the job to the output device.
 109      */
 110     public static final JobStateReason
 111         JOB_OUTGOING = new JobStateReason(4);
 112 
 113     /**
 114      * The value of the job's {@link JobHoldUntil JobHoldUntil} attribute was
 115      * specified with a date-time that is still in the future. The job must
 116      * not be a candidate for processing until this reason is removed and
 117      * there are
 118      * no other reasons to hold the job. This value should be supported if the
 119      * {@link JobHoldUntil JobHoldUntil} job template attribute is supported.
 120      */
 121     public static final JobStateReason
 122         JOB_HOLD_UNTIL_SPECIFIED = new JobStateReason(5);
 123 
 124     /**
 125      * At least one of the resources needed by the job, such as media, fonts,
 126      * resource objects, etc., is not ready on any of the physical printers
 127      * for which the job is a candidate. This condition may be detected
 128      * when the job is accepted, or subsequently while the job is pending
 129      * or processing, depending on implementation.
 130      * The job may remain in its current state or
 131      * be moved to the PENDING_HELD state, depending on implementation and/or
 132      * job scheduling policy.
 133      */
 134     public static final JobStateReason
 135         RESOURCES_ARE_NOT_READY = new JobStateReason(6);
 136 
 137     /**
 138      * The value of the printer's {@link PrinterStateReasons
 139      * PrinterStateReasons} attribute contains a {@link PrinterStateReason
 140      * PrinterStateReason} value of STOPPED_PARTLY.
 141      */
 142     public static final JobStateReason
 143         PRINTER_STOPPED_PARTLY = new JobStateReason(7);
 144 
 145     /**
 146      * The value of the printer's {@link PrinterState PrinterState} attribute
 147      * ia STOPPED.
 148      */
 149     public static final JobStateReason
 150         PRINTER_STOPPED = new JobStateReason(8);
 151 
 152     /**
 153      * The job is in the PROCESSING state, but more specifically, the printer
 154      * ia interpreting the document data.
 155      */
 156     public static final JobStateReason
 157         JOB_INTERPRETING = new JobStateReason(9);
 158 
 159     /**
 160      * The job is in the PROCESSING state, but more specifically, the printer
 161      * has queued the document data.
 162      */
 163     public static final JobStateReason JOB_QUEUED = new JobStateReason(10);
 164 
 165     /**
 166      * The job is in the PROCESSING state, but more specifically, the printer
 167      * is interpreting document data and producing another electronic
 168      * representation.
 169      */
 170     public static final JobStateReason
 171         JOB_TRANSFORMING = new JobStateReason(11);
 172 
 173     /**
 174      * The job is in the PENDING_HELD, PENDING, or PROCESSING state, but more
 175      * specifically, the printer has completed enough processing of the document
 176      * to be able to start marking and the job is waiting for the marker.
 177      * Systems that require human intervention to release jobs put the job into
 178      * the PENDING_HELD job state. Systems that automatically select a job to
 179      * use the marker put the job into the PENDING job state or keep the job
 180      * in the PROCESSING job state while waiting for the marker, depending on
 181      * implementation. All implementations put the job into (or back into) the
 182      * PROCESSING state when marking does begin.
 183      */
 184     public static final JobStateReason
 185         JOB_QUEUED_FOR_MARKER = new JobStateReason(12);
 186 
 187     /**
 188      * The output device is marking media. This value is useful for printers
 189      * which spend a great deal of time processing (1) when no marking is
 190      * happening and then want to show that marking is now happening or (2) when
 191      * the job is in the process of being canceled or aborted while the job
 192      * remains in the PROCESSING state, but the marking has not yet stopped so
 193      * that impression or sheet counts are still increasing for the job.
 194      */
 195     public static final JobStateReason
 196         JOB_PRINTING = new JobStateReason(13);
 197 
 198     /**
 199      * The job was canceled by the owner of the job, i.e., by a user whose
 200      * authenticated identity is the same as the value of the originating user
 201      * that created the Print Job, or by some other authorized end-user, such as
 202      * a member of the job owner's security group. This value should be
 203      * supported.
 204      */
 205     public static final JobStateReason
 206         JOB_CANCELED_BY_USER = new JobStateReason(14);
 207 
 208     /**
 209      * The job was canceled by the operator, i.e., by a user who has been
 210      * authenticated as having operator privileges (whether local or remote). If
 211      * the security policy is to allow anyone to cancel anyone's job, then this
 212      * value may be used when the job is canceled by someone other than the
 213      * owner of the job. For such a security policy, in effect, everyone is an
 214      * operator as far as canceling jobs is concerned. This value should be
 215      * supported if the implementation permits canceling by someone other than
 216      * the owner of the job.
 217      */
 218     public static final JobStateReason
 219         JOB_CANCELED_BY_OPERATOR = new JobStateReason(15);
 220 
 221     /**
 222      * The job was canceled by an unidentified local user, i.e., a user at a
 223      * console at the device. This value should be supported if the
 224      * implementation supports canceling jobs at the console.
 225      */
 226     public static final JobStateReason
 227         JOB_CANCELED_AT_DEVICE = new JobStateReason(16);
 228 
 229     /**
 230      * The job was aborted by the system. Either the job (1) is in the process
 231      * of being aborted, (2) has been aborted by the system and placed in the
 232      * ABORTED state, or (3) has been aborted by the system and placed in the
 233      * PENDING_HELD state, so that a user or operator can manually try the job
 234      * again. This value should be supported.
 235      */
 236     public static final JobStateReason
 237         ABORTED_BY_SYSTEM = new JobStateReason(17);
 238 
 239     /**
 240      * The job was aborted by the system because the printer determined while
 241      * attempting to decompress the document's data that the compression is
 242      * actually not among those supported by the printer. This value must be
 243      * supported, since {@link Compression Compression} is a required doc
 244      * description attribute.
 245      */
 246     public static final JobStateReason
 247         UNSUPPORTED_COMPRESSION = new JobStateReason(18);
 248 
 249     /**
 250      * The job was aborted by the system because the printer encountered an
 251      * error in the document data while decompressing it. If the printer posts
 252      * this reason, the document data has already passed any tests that would
 253      * have led to the UNSUPPORTED_COMPRESSION job state reason.
 254      */
 255     public static final JobStateReason
 256         COMPRESSION_ERROR = new JobStateReason(19);
 257 
 258     /**
 259      * The job was aborted by the system because the document data's document
 260      * format (doc flavor) is not among those supported by the printer. If the
 261      * client specifies a doc flavor with a MIME type of
 262      * {@code "application/octet-stream"}, the printer may abort the job if
 263      * the printer cannot determine the document data's actual format through
 264      * auto-sensing (even if the printer supports the document format if
 265      * specified explicitly). This value must be supported, since a doc flavor
 266      * is required to be specified for each doc.
 267      */
 268     public static final JobStateReason
 269         UNSUPPORTED_DOCUMENT_FORMAT = new JobStateReason(20);
 270 
 271     /**
 272      * The job was aborted by the system because the printer encountered an
 273      * error in the document data while processing it. If the printer posts this
 274      * reason, the document data has already passed any tests that would have
 275      * led to the UNSUPPORTED_DOCUMENT_FORMAT job state reason.
 276      */
 277     public static final JobStateReason
 278         DOCUMENT_FORMAT_ERROR = new JobStateReason(21);
 279 
 280     /**
 281      * The requester has canceled the job or the printer has aborted the job,
 282      * but the printer is still performing some actions on the job until a
 283      * specified stop point occurs or job termination/cleanup is completed.
 284      * <P>
 285      * If the implementation requires some measurable time to cancel the job in
 286      * the PROCESSING or PROCESSING_STOPPED job states, the printer must use
 287      * this reason to indicate that the printer is still performing some actions
 288      * on the job while the job remains in the PROCESSING or PROCESSING_STOPPED
 289      * state. After all the job's job description attributes have stopped
 290      * incrementing, the printer moves the job from the PROCESSING state to the
 291      * CANCELED or ABORTED job states.
 292      */
 293     public static final JobStateReason
 294         PROCESSING_TO_STOP_POINT = new JobStateReason(22);
 295 
 296     /**
 297      * The printer is off-line and accepting no jobs. All PENDING jobs are put
 298      * into the PENDING_HELD state. This situation could be true if the
 299      * service's or document transform's input is impaired or broken.
 300      */
 301     public static final JobStateReason
 302         SERVICE_OFF_LINE = new JobStateReason(23);
 303 
 304     /**
 305      * The job completed successfully. This value should be supported.
 306      */
 307     public static final JobStateReason
 308         JOB_COMPLETED_SUCCESSFULLY = new JobStateReason(24);
 309 
 310     /**
 311      * The job completed with warnings. This value should be supported if the
 312      * implementation detects warnings.
 313      */
 314     public static final JobStateReason
 315         JOB_COMPLETED_WITH_WARNINGS = new JobStateReason(25);
 316 
 317     /**
 318      * The job completed with errors (and possibly warnings too). This value
 319      * should be supported if the implementation detects errors.
 320      */
 321     public static final JobStateReason
 322         JOB_COMPLETED_WITH_ERRORS = new JobStateReason(26);
 323 
 324     /**
 325      * This job is retained and is currently able to be restarted. If
 326      * JOB_RESTARTABLE is contained in the job's {@link JobStateReasons
 327      * JobStateReasons} attribute, then the printer must accept a request to
 328      * restart that job. This value should be supported if restarting jobs is
 329      * supported. <I>[The capability for restarting jobs is not in the Java
 330      * Print Service API at present.]</I>
 331      */
 332     public static final JobStateReason
 333         JOB_RESTARTABLE = new JobStateReason(27);
 334 
 335     /**
 336      * The job has been forwarded to a device or print system that is unable to
 337      * send back status. The printer sets the job's {@link JobState JobState}
 338      * attribute to COMPLETED and adds the QUEUED_IN_DEVICE reason to the job's
 339      * {@link JobStateReasons JobStateReasons} attribute to indicate that the
 340      * printer has no additional information about the job and never will have
 341      * any better information.
 342      */
 343     public static final JobStateReason
 344         QUEUED_IN_DEVICE = new JobStateReason(28);
 345 
 346     /**
 347      * Construct a new job state reason enumeration value with the given
 348      * integer  value.
 349      *
 350      * @param  value  Integer value.
 351      */
 352     protected JobStateReason(int value) {
 353         super (value);
 354     }
 355 
 356     private static final String[] myStringTable = {
 357         "job-incoming",
 358         "job-data-insufficient",
 359         "document-access-error",
 360         "submission-interrupted",
 361         "job-outgoing",
 362         "job-hold-until-specified",
 363         "resources-are-not-ready",
 364         "printer-stopped-partly",
 365         "printer-stopped",
 366         "job-interpreting",
 367         "job-queued",
 368         "job-transforming",
 369         "job-queued-for-marker",
 370         "job-printing",
 371         "job-canceled-by-user",
 372         "job-canceled-by-operator",
 373         "job-canceled-at-device",
 374         "aborted-by-system",
 375         "unsupported-compression",
 376         "compression-error",
 377         "unsupported-document-format",
 378         "document-format-error",
 379         "processing-to-stop-point",
 380         "service-off-line",
 381         "job-completed-successfully",
 382         "job-completed-with-warnings",
 383         "job-completed-with-errors",
 384         "job-restartable",
 385         "queued-in-device"};
 386 
 387     private static final JobStateReason[] myEnumValueTable = {
 388         JOB_INCOMING,
 389         JOB_DATA_INSUFFICIENT,
 390         DOCUMENT_ACCESS_ERROR,
 391         SUBMISSION_INTERRUPTED,
 392         JOB_OUTGOING,
 393         JOB_HOLD_UNTIL_SPECIFIED,
 394         RESOURCES_ARE_NOT_READY,
 395         PRINTER_STOPPED_PARTLY,
 396         PRINTER_STOPPED,
 397         JOB_INTERPRETING,
 398         JOB_QUEUED,
 399         JOB_TRANSFORMING,
 400         JOB_QUEUED_FOR_MARKER,
 401         JOB_PRINTING,
 402         JOB_CANCELED_BY_USER,
 403         JOB_CANCELED_BY_OPERATOR,
 404         JOB_CANCELED_AT_DEVICE,
 405         ABORTED_BY_SYSTEM,
 406         UNSUPPORTED_COMPRESSION,
 407         COMPRESSION_ERROR,
 408         UNSUPPORTED_DOCUMENT_FORMAT,
 409         DOCUMENT_FORMAT_ERROR,
 410         PROCESSING_TO_STOP_POINT,
 411         SERVICE_OFF_LINE,
 412         JOB_COMPLETED_SUCCESSFULLY,
 413         JOB_COMPLETED_WITH_WARNINGS,
 414         JOB_COMPLETED_WITH_ERRORS,
 415         JOB_RESTARTABLE,
 416         QUEUED_IN_DEVICE};
 417 
 418     /**
 419      * Returns the string table for class JobStateReason.
 420      */
 421     protected String[] getStringTable() {
 422         return myStringTable.clone();
 423     }
 424 
 425     /**
 426      * Returns the enumeration value table for class JobStateReason.
 427      */
 428     protected EnumSyntax[] getEnumValueTable() {
 429         return (EnumSyntax[])myEnumValueTable.clone();
 430     }
 431 
 432 
 433     /**
 434      * Get the printing attribute class which is to be used as the "category"
 435      * for this printing attribute value.
 436      * <P>
 437      * For class JobStateReason and any vendor-defined subclasses, the
 438      * category  is class JobStateReason itself.
 439      *
 440      * @return  Printing attribute class (category), an instance of class
 441      *          {@link java.lang.Class java.lang.Class}.
 442      */
 443     public final Class<? extends Attribute> getCategory() {
 444         return JobStateReason.class;
 445     }
 446 
 447     /**
 448      * Get the name of the category of which this attribute value is an
 449      * instance.
 450      * <P>
 451      * For class JobStateReason and any vendor-defined subclasses, the
 452      * category name is {@code "job-state-reason"}.
 453      *
 454      * @return  Attribute category name.
 455      */
 456     public final String getName() {
 457         return "job-state-reason";
 458     }
 459 
 460 }