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