KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > print > event > PrintJobEvent


1 /*
2  * @(#)PrintJobEvent.java 1.9 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.event;
9
10 import javax.print.DocPrintJob JavaDoc;
11
12 /**
13  *
14  * Class <code>PrintJobEvent</code> encapsulates common events a print job
15  * reports to let a listener know of progress in the processing of the
16  * {@link DocPrintJob}.
17  *
18  */

19
20 public class PrintJobEvent extends PrintEvent JavaDoc {
21
22    private static final long serialVersionUID = -1711656903622072997L;
23
24    private int reason;
25    
26    /**
27     * The job was canceled by the {@link javax.print.PrintService PrintService}.
28     */

29    public static final int JOB_CANCELED = 101;
30
31    /**
32     * The document cis completely printed.
33     */

34    public static final int JOB_COMPLETE = 102;
35
36    /**
37     * The print service reports that the job cannot be completed.
38     * The application must resubmit the job.
39     */

40
41    public static final int JOB_FAILED = 103;
42
43    /**
44     * The print service indicates that a - possibly transient - problem
45     * may require external intervention before the print service can
46     * continue. One example of an event that can
47     * generate this message is when the printer runs out of paper.
48     */

49    public static final int REQUIRES_ATTENTION = 104;
50
51    /**
52     * Not all print services may be capable of delivering interesting
53     * events, or even telling when a job is complete. This message indicates
54     * the print job has no further information or communication
55     * with the print service. This message should always be delivered
56     * if a terminal event (completed/failed/canceled) is not delivered.
57     * For example, if messages such as JOB_COMPLETE have NOT been received
58     * before receiving this message, the only inference that should be drawn
59     * is that the print service does not support delivering such an event.
60     */

61    public static final int NO_MORE_EVENTS = 105;
62
63    /**
64     * The job is not necessarily printed yet, but the data has been transferred
65     * successfully from the client to the print service. The client may
66     * free data resources.
67     */

68    public static final int DATA_TRANSFER_COMPLETE = 106;
69
70    /**
71      * Constructs a <code>PrintJobEvent</code> object.
72      *
73      * @param source a <code>DocPrintJob</code> object
74      * @param reason an int specifying the reason.
75      * @throws IllegalArgumentException if <code>source</code> is
76      * <code>null</code>.
77      */

78
79     public PrintJobEvent( DocPrintJob JavaDoc source, int reason) {
80
81         super(source);
82         this.reason = reason;
83    }
84
85     /**
86      * Gets the reason for this event.
87      * @return reason int.
88      */

89     public int getPrintEventType() {
90         return reason;
91     }
92
93     /**
94      * Determines the <code>DocPrintJob</code> to which this print job
95      * event pertains.
96      *
97      * @return the <code>DocPrintJob</code> object that represents the
98      * print job that reports the events encapsulated by this
99      * <code>PrintJobEvent</code>.
100      *
101      */

102     public DocPrintJob JavaDoc getPrintJob() {
103         return (DocPrintJob JavaDoc) getSource();
104     }
105
106
107 }
108
Popular Tags