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