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