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