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