Path: blob/master/src/java.desktop/share/classes/javax/print/event/PrintJobEvent.java
41159 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print.event;2627import java.io.Serial;2829import javax.print.DocPrintJob;3031/**32* Class {@code PrintJobEvent} encapsulates common events a print job reports to33* let a listener know of progress in the processing of the {@link DocPrintJob}.34*/35public class PrintJobEvent extends PrintEvent {3637/**38* Use serialVersionUID from JDK 1.4 for interoperability.39*/40@Serial41private static final long serialVersionUID = -1711656903622072997L;4243/**44* The reason of this event.45*/46private int reason;4748/**49* The job was canceled by the50* {@link javax.print.PrintService PrintService}.51*/52public static final int JOB_CANCELED = 101;5354/**55* The document is completely printed.56*/57public static final int JOB_COMPLETE = 102;5859/**60* The print service reports that the job cannot be completed. The61* application must resubmit the job.62*/63public static final int JOB_FAILED = 103;6465/**66* The print service indicates that a - possibly transient - problem may67* require external intervention before the print service can continue. One68* example of an event that can generate this message is when the printer69* runs out of paper.70*/71public static final int REQUIRES_ATTENTION = 104;7273/**74* Not all print services may be capable of delivering interesting events,75* or even telling when a job is complete. This message indicates the print76* job has no further information or communication with the print service.77* This message should always be delivered if a terminal event78* (completed/failed/canceled) is not delivered. For example, if messages79* such as {@code JOB_COMPLETE} have NOT been received before receiving this80* message, the only inference that should be drawn is that the print81* service does not support delivering such an event.82*/83public static final int NO_MORE_EVENTS = 105;8485/**86* The job is not necessarily printed yet, but the data has been transferred87* successfully from the client to the print service. The client may free88* data resources.89*/90public static final int DATA_TRANSFER_COMPLETE = 106;9192/**93* Constructs a {@code PrintJobEvent} object.94*95* @param source a {@code DocPrintJob} object96* @param reason an int specifying the reason97* @throws IllegalArgumentException if {@code source} is {@code null}98*/99public PrintJobEvent( DocPrintJob source, int reason) {100101super(source);102this.reason = reason;103}104105/**106* Gets the reason for this event.107*108* @return reason int109*/110public int getPrintEventType() {111return reason;112}113114/**115* Determines the {@code DocPrintJob} to which this print job event116* pertains.117*118* @return the {@code DocPrintJob} object that represents the print job that119* reports the events encapsulated by this {@code PrintJobEvent}120*/121public DocPrintJob getPrintJob() {122return (DocPrintJob) getSource();123}124}125126127