1. /*
  2. * @(#)PrintJobEvent.java 1.9 03/12/19
  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.event;
  8. import javax.print.DocPrintJob;
  9. /**
  10. *
  11. * Class <code>PrintJobEvent</code> encapsulates common events a print job
  12. * reports to let a listener know of progress in the processing of the
  13. * {@link DocPrintJob}.
  14. *
  15. */
  16. public class PrintJobEvent extends PrintEvent {
  17. private static final long serialVersionUID = -1711656903622072997L;
  18. private int reason;
  19. /**
  20. * The job was canceled by the {@link javax.print.PrintService PrintService}.
  21. */
  22. public static final int JOB_CANCELED = 101;
  23. /**
  24. * The document cis completely printed.
  25. */
  26. public static final int JOB_COMPLETE = 102;
  27. /**
  28. * The print service reports that the job cannot be completed.
  29. * The application must resubmit the job.
  30. */
  31. public static final int JOB_FAILED = 103;
  32. /**
  33. * The print service indicates that a - possibly transient - problem
  34. * may require external intervention before the print service can
  35. * continue. One example of an event that can
  36. * generate this message is when the printer runs out of paper.
  37. */
  38. public static final int REQUIRES_ATTENTION = 104;
  39. /**
  40. * Not all print services may be capable of delivering interesting
  41. * events, or even telling when a job is complete. This message indicates
  42. * the print job has no further information or communication
  43. * with the print service. This message should always be delivered
  44. * if a terminal event (completed/failed/canceled) is not delivered.
  45. * For example, if messages such as JOB_COMPLETE have NOT been received
  46. * before receiving this message, the only inference that should be drawn
  47. * is that the print service does not support delivering such an event.
  48. */
  49. public static final int NO_MORE_EVENTS = 105;
  50. /**
  51. * The job is not necessarily printed yet, but the data has been transferred
  52. * successfully from the client to the print service. The client may
  53. * free data resources.
  54. */
  55. public static final int DATA_TRANSFER_COMPLETE = 106;
  56. /**
  57. * Constructs a <code>PrintJobEvent</code> object.
  58. *
  59. * @param source a <code>DocPrintJob</code> object
  60. * @param reason an int specifying the reason.
  61. * @throws IllegalArgumentException if <code>source</code> is
  62. * <code>null</code>.
  63. */
  64. public PrintJobEvent( DocPrintJob source, int reason) {
  65. super(source);
  66. this.reason = reason;
  67. }
  68. /**
  69. * Gets the reason for this event.
  70. * @return reason int.
  71. */
  72. public int getPrintEventType() {
  73. return reason;
  74. }
  75. /**
  76. * Determines the <code>DocPrintJob</code> to which this print job
  77. * event pertains.
  78. *
  79. * @return the <code>DocPrintJob</code> object that represents the
  80. * print job that reports the events encapsulated by this
  81. * <code>PrintJobEvent</code>.
  82. *
  83. */
  84. public DocPrintJob getPrintJob() {
  85. return (DocPrintJob) getSource();
  86. }
  87. }