]> git.ipfire.org Git - thirdparty/cups.git/blame - scripting/java/src/com/easysw/cups/IPPError.java
Load cups into easysw/current.
[thirdparty/cups.git] / scripting / java / src / com / easysw / cups / IPPError.java
CommitLineData
ef416fc2 1package com.easysw.cups;
2
3/**
4 * @version 1.00 06-NOV-2002
bc44d920 5 * @author Apple Inc.
ef416fc2 6 *
7 * Internet Printing Protocol definitions for the Common UNIX Printing
8 * System (CUPS).
9 *
bc44d920 10 * Copyright 2007 by Apple Inc.
ef416fc2 11 * Copyright 1997-2002 by Easy Software Products.
12 *
13 * These coded instructions, statements, and computer programs are the
bc44d920 14 * property of Apple Inc. and are protected by Federal copyright
15 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
16 * which should have been included with this file. If this file is
17 * file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 18 */
19
20/**
21 * An <code>IPPError</code> object is used for error conversion.
22 *
23 * @author TDB
24 * @version 1.0
25 * @since JDK1.3
26 */
27
28import java.util.*;
29import java.io.*;
30
31
32public class IPPError
33{
34 private int error_number;
35 private String error_string;
36
37
38 /**
39 * Constructor that sets <code>error_string</code> after creation.
40 *
41 * @param <code>error_number</code> Error number to convert.
42 * @see <code>IPPDefs</code>
43 */
44 public IPPError(int p_error)
45 {
46 error_number = p_error;
47 error_string = ippErrorString( error_number );
48 }
49
50
51 /**
52 * Get the string associated with an error number.
53 *
54 * @param <code>error</code> Error number to convert.
55 * @see <code>IPPDefs</code>
56 */
57 private String ippErrorString( int error )
58 {
59 String unknown;
60 String status_oks[] = // "OK" status codes
61 {
62 "successful-ok",
63 "successful-ok-ignored-or-substituted-attributes",
64 "successful-ok-conflicting-attributes",
65 "successful-ok-ignored-subscriptions",
66 "successful-ok-ignored-notifications",
67 "successful-ok-too-many-events",
68 "successful-ok-but-cancel-subscription"
69 };
70
71 String status_400s[] = // Client errors
72 {
73 "client-error-bad-request",
74 "client-error-forbidden",
75 "client-error-not-authenticated",
76 "client-error-not-authorized",
77 "client-error-not-possible",
78 "client-error-timeout",
79 "client-error-not-found",
80 "client-error-gone",
81 "client-error-request-entity-too-large",
82 "client-error-request-value-too-long",
83 "client-error-document-format-not-supported",
84 "client-error-attributes-or-values-not-supported",
85 "client-error-uri-scheme-not-supported",
86 "client-error-charset-not-supported",
87 "client-error-conflicting-attributes",
88 "client-error-compression-not-supported",
89 "client-error-compression-error",
90 "client-error-document-format-error",
91 "client-error-document-access-error",
92 "client-error-attributes-not-settable",
93 "client-error-ignored-all-subscriptions",
94 "client-error-too-many-subscriptions",
95 "client-error-ignored-all-notifications",
96 "client-error-print-support-file-not-found"
97 };
98
99 String status_500s[] = // Server errors
100 {
101 "server-error-internal-error",
102 "server-error-operation-not-supported",
103 "server-error-service-unavailable",
104 "server-error-version-not-supported",
105 "server-error-device-error",
106 "server-error-temporary-error",
107 "server-error-not-accepting-jobs",
108 "server-error-busy",
109 "server-error-job-canceled",
110 "server-error-multiple-document-jobs-not-supported",
111 "server-error-printer-is-deactivated"
112 };
113
114
115 //
116 // See if the error code is a known value...
117 //
118 if ((error >= IPPDefs.OK) && (error <= IPPDefs.OK_BUT_CANCEL_SUBSCRIPTION))
119 {
120 return (status_oks[error]);
121 }
122 else if (error == IPPDefs.REDIRECTION_OTHER_SITE)
123 {
124 return ("redirection-other-site");
125 }
126 else if ((error >= IPPDefs.BAD_REQUEST) &&
127 (error <= IPPDefs.PRINT_SUPPORT_FILE_NOT_FOUND))
128 {
129 return (status_400s[error - IPPDefs.BAD_REQUEST]);
130 }
131 else if ((error >= IPPDefs.INTERNAL_ERROR) &&
132 (error <= IPPDefs.PRINTER_IS_DEACTIVATED))
133 {
134 return (status_500s[error - IPPDefs.INTERNAL_ERROR]);
135 }
136
137 //
138 // No, build an "unknown-xxxx" error string...
139 //
140
141 unknown = "unknown" + error;
142
143 return (unknown);
144 }
145
146
147} // End of IPPError class
148
149
150