]> git.ipfire.org Git - thirdparty/cups.git/blob - scripting/java/src/com/easysw/cups/CupsJob.java
Load cups into easysw/current.
[thirdparty/cups.git] / scripting / java / src / com / easysw / cups / CupsJob.java
1 package com.easysw.cups;
2
3 /**
4 * @version 1.00 06-NOV-2002
5 * @author Easy Software Products
6 *
7 * Internet Printing Protocol definitions for the Common UNIX Printing
8 * System (CUPS).
9 *
10 * Copyright 1997-2002 by Easy Software Products.
11 *
12 * These coded instructions, statements, and computer programs are the
13 * property of Easy Software Products and are protected by Federal
14 * copyright law. Distribution and use rights are outlined in the file
15 * "LICENSE.txt" which should have been included with this file. If this
16 * file is missing or damaged please contact Easy Software Products
17 * at:
18 *
19 * Attn: CUPS Licensing Information
20 * Easy Software Products
21 * 44141 Airport View Drive, Suite 204
22 * Hollywood, Maryland 20636-3111 USA
23 *
24 * Voice: (301) 373-9603
25 * EMail: cups-info@cups.org
26 * WWW: http://www.cups.org
27 */
28
29
30 /**
31 * A <code>CupsJob</code> object holds job data, and has methods to
32 * process cups job list responses into a usable form.
33 *
34 * @author TDB
35 * @version 1.0
36 * @since JDK1.3
37 */
38
39 //
40 import java.io.*;
41 import java.net.*;
42
43 public class CupsJob
44 {
45 public int job_id;
46 public String job_more_info;
47 public String job_uri;
48 public String job_printer_uri;
49 public long job_printer_up_time;
50 public String job_name;
51 public String job_originating_user_name;
52 public String document_format;
53 public String job_originating_host_name;
54 public int job_priority;
55 public int job_state;
56 public int job_media_sheets_completed;
57 public int job_k_octets;
58 public long time_at_creation;
59 public long time_at_processing;
60 public long time_at_completed;
61 public String job_hold_until;
62 public String job_sheets;
63 public String job_state_reasons;
64
65
66 /**
67 * Constructor - set some default values.
68 */
69 public CupsJob()
70 {
71 job_id = -1;
72 job_more_info = "";
73 job_uri = "";
74 job_printer_uri = "";
75 job_printer_up_time = 0;
76 job_name = "";
77 job_originating_user_name = "";
78 document_format = "";
79 job_originating_host_name = "";
80 job_priority = -1;
81 job_state = 0;
82 job_media_sheets_completed = 0;
83 job_k_octets = 0;
84 time_at_creation = 0;
85 time_at_processing = 0;
86 time_at_completed = 0;
87 job_hold_until = "";
88 job_sheets = "";
89 job_state_reasons = "";
90 }
91
92
93
94
95 /**
96 * Process an attribute from a cups.doRequest() call
97 * and move the value into a local member.
98 *
99 * @see <code>IPPDefs</code>
100 * @see <code>IPPValues</code>
101 * @see <code>IPPAttributes</code>
102 */
103 public void updateAttribute( IPPAttribute a )
104 {
105 IPPValue val;
106
107 //
108 // Kick out if no values are present.
109 //
110 if (a.values.size() < 1)
111 return;
112
113 val = (IPPValue)a.values.get(0);
114 if (a.name.compareTo("job-more-info") == 0)
115 {
116 job_more_info = val.text;
117 }
118 else if (a.name.compareTo("job-uri") == 0)
119 {
120 job_uri = val.text;
121 }
122 else if (a.name.compareTo("job-printer-up-time") == 0)
123 {
124 job_printer_up_time = val.integer_value;
125 }
126 else if (a.name.compareTo("job-originating-user-name") == 0)
127 {
128 job_originating_user_name = val.text;
129 }
130 else if (a.name.compareTo("document-format") == 0)
131 {
132 document_format = val.text;
133 }
134 else if (a.name.compareTo("job-priority") == 0)
135 {
136 job_priority = val.integer_value;
137 }
138 else if (a.name.compareTo("job-originating-host-name") == 0)
139 {
140 job_originating_host_name = val.text;
141 }
142 else if (a.name.compareTo("job-id") == 0)
143 {
144 job_id = val.integer_value;
145 }
146 else if (a.name.compareTo("job-state") == 0)
147 {
148 job_state = val.integer_value;
149 }
150 else if (a.name.compareTo("job-media-sheets-completed") == 0)
151 {
152 job_media_sheets_completed = val.integer_value;
153 }
154 else if (a.name.compareTo("job-printer-uri") == 0)
155 {
156 job_printer_uri = val.text;
157 }
158 else if (a.name.compareTo("job-name") == 0)
159 {
160 job_name = val.text;
161 }
162 else if (a.name.compareTo("job-k-octets") == 0)
163 {
164 job_k_octets = val.integer_value;
165 }
166 else if (a.name.compareTo("time-at-creation") == 0)
167 {
168 time_at_creation = val.integer_value;
169 }
170 else if (a.name.compareTo("time-at-processing") == 0)
171 {
172 time_at_processing = val.integer_value;
173 }
174 else if (a.name.compareTo("time-at-completed") == 0)
175 {
176 time_at_completed = val.integer_value;
177 }
178 else if (a.name.compareTo("job-hold-until") == 0)
179 {
180 job_hold_until = val.text;
181 }
182 else if (a.name.compareTo("job-sheets") == 0)
183 {
184 job_sheets = val.text;
185 }
186 else if (a.name.compareTo("job-state-reasons") == 0)
187 {
188 job_state_reasons = val.text;
189 }
190 }
191
192
193 /**
194 * Convert a job status to a string.
195 *
196 * @see <code>IPPDefs</code>
197 */
198 public String jobStatusText()
199 {
200 switch( job_state )
201 {
202 case 3: return("Pending");
203 case 4: return("Held");
204 case 5: return("Processing");
205 case 6: return("Stopped");
206 case 7: return("Cancelled");
207 case 8: return("Aborted");
208 case 9: return("Completed");
209 }
210 return("Unknown");
211 }
212
213
214 }
215
216 // eof ....