Path: blob/master/src/java.desktop/share/classes/javax/print/CancelablePrintJob.java
41153 views
/*1* Copyright (c) 2001, 2017, 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;2627/**28* This interface is used by a printing application to cancel a print job. This29* interface extends {@link DocPrintJob}. A {@code DocPrintJob} implementation30* returned from a print service implements this interface if the print job can31* be cancelled. Before trying to cancel a print job, the client needs to test32* if the {@code DocPrintJob} object returned from the print service actually33* implements this interface. Clients should never assume that a34* {@code DocPrintJob} implements this interface. A print service might support35* cancellation only for certain types of print data and representation class36* names. This means that only some of the {@code DocPrintJob} objects returned37* from a service will implement this interface.38* <p>39* Service implementors are encouraged to implement this optional interface and40* to deliver a {@link javax.print.event.PrintJobEvent#JOB_CANCELED} event to41* any listeners if a job is successfully cancelled with an implementation of42* this interface. Services should also note that an implementation of this43* method may be made from a separate client thread than that which made the44* print request. Thus the implementation of this interface must be made thread45* safe.46*/47public interface CancelablePrintJob extends DocPrintJob {4849/**50* Stops further processing of a print job.51* <p>52* If a service supports this method it cannot be concluded that job53* cancellation will always succeed. A job may not be able to be cancelled54* once it has reached and passed some point in its processing. A successful55* cancellation means only that the entire job was not printed, some portion56* may already have printed when cancel returns.57* <p>58* The service will throw a {@code PrintException} if the cancellation did59* not succeed. A job which has not yet been submitted for printing should60* throw this exception. Cancelling an already successfully cancelled Print61* Job is not considered an error and will always succeed.62* <p>63* Cancellation in some services may be a lengthy process, involving64* requests to a server and processing of its print queue. Clients may wish65* to execute cancel in a thread which does not affect application66* execution.67*68* @throws PrintException if the job could not be successfully cancelled69*/70public void cancel() throws PrintException;71}727374