1 /* 2 * @(#)CancelablePrintJob.java 1.6 03/12/19 3 * 4 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 8 package javax.print; 9 10 /** 11 * This interface is used by a printing application to cancel a 12 * print job. This interface extends {@link DocPrintJob}. A 13 * <code>DocPrintJob</code> implementation returned from a print 14 * service implements this interface if the print job can be 15 * cancelled. Before trying to cancel 16 * a print job, the client needs to test if the 17 * <code>DocPrintJob</code> object returned from the print service 18 * actually implements this interface. Clients should never assume 19 * that a <code>DocPrintJob</code> implements this interface. A 20 * print service might support cancellation only for certain types 21 * of print data and representation class names. This means that 22 * only some of the <code>DocPrintJob</code> objects returned from 23 * a service will implement this interface. 24 * <p> 25 * Service implementors are encouraged to implement this optional interface 26 * and to deliver a javax.print.event.PrintJobEvent.JOB_CANCELLED event 27 * to any listeners if a job is successfully cancelled with an 28 * implementation of this interface. Services should also note that an 29 * implementation of this method may be made from a separate client thread 30 * than that which made the print request. Thus the implementation of 31 * this interface must be made thread safe. 32 */ 33 34 public interface CancelablePrintJob extends DocPrintJob { 35 36 /** 37 * Stops further processing of a print job. 38 * <p> 39 * If a service supports this method it cannot be concluded that 40 * job cancellation will always suceeed. A job may not be able to be 41 * cancelled once it has reached and passed some point in its processing. 42 * A successful cancellation means only that the entire job was not 43 * printed, some portion may already have printed when cancel returns. 44 * <p> 45 * The service will throw a PrintException if the cancellation did not 46 * succeed. A job which has not yet been submitted for printing should 47 * throw this exception. 48 * Cancelling an already successfully cancelled Print Job is not 49 * considered an error and will always succeed. 50 * <p> 51 * Cancellation in some services may be a lengthy process, involving 52 * requests to a server and processing of its print queue. Clients 53 * may wish to execute cancel in a thread which does not affect 54 * application execution. 55 * @throws PrintException if the job could not be successfully cancelled. 56 */ 57 public void cancel() throws PrintException; 58 59 } 60