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