1 /* 2 * Copyright (c) 2001, 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; 27 28 /** 29 * This interface is used by a printing application to cancel a print job. This 30 * interface extends {@link DocPrintJob}. A {@code DocPrintJob} implementation 31 * returned from a print service implements this interface if the print job can 32 * be cancelled. Before trying to cancel a print job, the client needs to test 33 * if the {@code DocPrintJob} object returned from the print service actually 34 * implements this interface. Clients should never assume that a 35 * {@code DocPrintJob} implements this interface. A print service might support 36 * cancellation only for certain types of print data and representation class 37 * names. This means that only some of the {@code DocPrintJob} objects returned 38 * from a service will implement this interface. 39 * <p> 40 * Service implementors are encouraged to implement this optional interface and 41 * to deliver a {@link javax.print.event.PrintJobEvent#JOB_CANCELED} event to 42 * any listeners if a job is successfully cancelled with an implementation of 43 * this interface. Services should also note that an implementation of this 44 * method may be made from a separate client thread than that which made the 45 * print request. Thus the implementation of this interface must be made thread 46 * safe. 47 */ 48 public interface CancelablePrintJob extends DocPrintJob { 49 50 /** 51 * Stops further processing of a print job. 52 * <p> 53 * If a service supports this method it cannot be concluded that job 54 * cancellation will always succeed. A job may not be able to be cancelled 55 * once it has reached and passed some point in its processing. A successful 56 * cancellation means only that the entire job was not printed, some portion 57 * may already have printed when cancel returns. 58 * <p> 59 * The service will throw a {@code PrintException} if the cancellation did 60 * not succeed. A job which has not yet been submitted for printing should 61 * throw this exception. Cancelling an already successfully cancelled Print 62 * Job is not considered an error and will always succeed. 63 * <p> 64 * Cancellation in some services may be a lengthy process, involving 65 * requests to a server and processing of its print queue. Clients may wish 66 * to execute cancel in a thread which does not affect application 67 * execution. 68 * 69 * @throws PrintException if the job could not be successfully cancelled 70 */ 71 public void cancel() throws PrintException; 72 }