KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > core > StatusCode


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19
20 package sync4j.framework.core;
21
22 import java.util.Hashtable JavaDoc;
23
24 /**
25  * This class represents the possible status code.
26  *
27  * @author Stefano Fornari @ Funambol
28  *
29  * @version $Id: StatusCode.java,v 1.3 2005/03/02 20:57:37 harrie Exp $
30  *
31  */

32 public final class StatusCode {
33
34     public static final int IN_PROGRESS = 101;
35     public static final int OK = 200;
36     public static final int ITEM_ADDED = 201;
37     public static final int ACCEPTED_FOR_PROCESSING = 202;
38     public static final int NONAUTHORITATIVE_RESPONSE = 203;
39     public static final int NO_CONTENT = 204;
40     public static final int RESET_CONTENT = 205;
41     public static final int PARTIAL_CONTENT = 206;
42     public static final int CONFLICT_RESOLVED_WITH_MERGE = 207;
43     public static final int CONFLICT_RESOLVED_WITH_CLIENT_COMMAND_WINNING = 208;
44     public static final int CONFLICT_RESOLVED_WITH_DUPLICATE = 209;
45     public static final int DELETE_WITHOUT_ARCHIVE = 210;
46     public static final int ITEM_NOT_DELETED = 211;
47     public static final int AUTHENTICATION_ACCEPTED = 212;
48     public static final int CHUNKED_ITEM_ACCEPTED = 213;
49     public static final int OPERATION_CANCELLED_OK = 214;
50     public static final int NOT_EXECUTED = 215;
51     public static final int ATOMIC_ROLLBACK_OK = 216;
52     public static final int MULTIPLE_CHOICES = 300;
53     public static final int MOVED_PERMANENTLY = 301;
54     public static final int FOUND = 302;
55     public static final int SEE_ANOTHER_URI = 303;
56     public static final int NOT_MODIFIED = 304;
57     public static final int USE_PROXY = 305;
58     public static final int BAD_REQUEST = 400;
59     public static final int INVALID_CREDENTIALS = 401;
60     public static final int PAYMENT_REQUIRED = 402;
61     public static final int FORBIDDEN = 403;
62     public static final int NOT_FOUND = 404;
63     public static final int COMMAND_NOT_ALLOWED = 405;
64     public static final int OPTIONAL_FEATURE_NOT_SUPPORTED = 406;
65     public static final int MISSING_CREDENTIALS = 407;
66     public static final int REQUEST_TIMEOUT = 408;
67     public static final int UPDATE_CONFLICT = 409;
68     public static final int GONE = 410;
69     public static final int SIZE_REQUIRED = 411;
70     public static final int INCOMPLETE_COMMAND = 412;
71     public static final int REQUESTED_ENTITY_TOO_LARGE = 413;
72     public static final int URI_TOO_LONG = 414;
73     public static final int UNSUPPORTED_MEDIA_TYPE = 415;
74     public static final int REQUESTED_SIZE_TOO_BIG = 416;
75     public static final int RETRY_LATER = 417;
76     public static final int ALREADY_EXISTS = 418;
77     public static final int CONFLICT_RESOLVED_WITH_SERVER_DATA = 419;
78     public static final int DEVICE_FULL = 420;
79     public static final int UNKNOWN_SEARCH_GRAMMAR = 421;
80     public static final int BAD_CGI_SCRIPT = 422;
81     public static final int SOFT_DELETE_CONFLICT = 423;
82     public static final int OBJECT_SIZE_MISMATCH = 424;
83     public static final int PERMISSION_DENIED = 425;
84     public static final int COMMAND_FAILED = 500;
85     public static final int COMMAND_NOT_IMPLEMENTED = 501;
86     public static final int BAD_GATEWAY = 502;
87     public static final int SERVICE_UNAVAILABLE = 503;
88     public static final int GATEWAY_TIMEOUT = 504;
89     public static final int VERSION_NOT_SUPPORTED = 505;
90     public static final int PROCESSING_ERROR = 506;
91     public static final int ATOMIC_FAILED = 507;
92     public static final int REFRESH_REQUIRED = 508;
93     public static final int RECIPIENT_EXCEPTION_RESERVED1 = 509;
94     public static final int DATASTORE_FAILURE = 510;
95     public static final int SERVER_FAILURE = 511;
96     public static final int SYNCHRONIZATION_FAILED = 512;
97     public static final int PROTOCOL_VERSION_NOT_SUPPORTED = 513;
98     public static final int OPERATION_CANCELLED = 514;
99     public static final int ATOMIC_ROLLBACK_FAILED = 516;
100     public static final int ATOMIC_RESPONSE_TOO_LARGE_TO_FIT = 517;
101
102     /**
103      * These codes are application specific; they are not part of the SyncML
104      * protocol.
105      */

106     public static final int SESSION_EXPIRED = 10000;
107     public static final int SESSION_ABORTED = 20000;
108
109     private static Hashtable JavaDoc descriptions = null;
110
111     static {
112         descriptions = new Hashtable JavaDoc(71);
113
114         descriptions.put(new Integer JavaDoc(IN_PROGRESS ), "IN PROGRESS" );
115         descriptions.put(new Integer JavaDoc(OK ), "OK" );
116         descriptions.put(new Integer JavaDoc(ITEM_ADDED ), "ITEM ADDED" );
117         descriptions.put(new Integer JavaDoc(ACCEPTED_FOR_PROCESSING ), "ACCEPTED FOR PROCESSING" );
118         descriptions.put(new Integer JavaDoc(NONAUTHORITATIVE_RESPONSE ), "NONAUTHORITATIVE RESPONSE" );
119         descriptions.put(new Integer JavaDoc(NO_CONTENT ), "NO CONTENT" );
120         descriptions.put(new Integer JavaDoc(RESET_CONTENT ), "RESET CONTENT" );
121         descriptions.put(new Integer JavaDoc(PARTIAL_CONTENT ), "PARTIAL CONTENT" );
122         descriptions.put(new Integer JavaDoc(CONFLICT_RESOLVED_WITH_MERGE ), "CONFLICT RESOLVED WITH MERGE" );
123         descriptions.put(new Integer JavaDoc(CONFLICT_RESOLVED_WITH_CLIENT_COMMAND_WINNING), "CONFLICT RESOLVED WITH CLIENT COMMAND WINNING");
124         descriptions.put(new Integer JavaDoc(CONFLICT_RESOLVED_WITH_DUPLICATE ), "CONFLICT RESOLVED WITH DUPLICATE" );
125         descriptions.put(new Integer JavaDoc(DELETE_WITHOUT_ARCHIVE ), "DELETE WITHOUT ARCHIVE" );
126         descriptions.put(new Integer JavaDoc(ITEM_NOT_DELETED ), "ITEM NOT DELETED" );
127         descriptions.put(new Integer JavaDoc(AUTHENTICATION_ACCEPTED ), "AUTHENTICATION ACCEPTED" );
128         descriptions.put(new Integer JavaDoc(CHUNKED_ITEM_ACCEPTED ), "CHUNKED_ITEM_ACCEPTED" );
129         descriptions.put(new Integer JavaDoc(OPERATION_CANCELLED_OK ), "OPERATION_CANCELLED_OK" );
130         descriptions.put(new Integer JavaDoc(NOT_EXECUTED ), "NOT_EXECUTED" );
131         descriptions.put(new Integer JavaDoc(ATOMIC_ROLLBACK_OK ), "ATOMIC_ROLLBACK_OK" );
132         descriptions.put(new Integer JavaDoc(MULTIPLE_CHOICES ), "MULTIPLE CHOICES" );
133         descriptions.put(new Integer JavaDoc(MOVED_PERMANENTLY ), "MOVED PERMANENTLY" );
134         descriptions.put(new Integer JavaDoc(FOUND ), "FOUND" );
135         descriptions.put(new Integer JavaDoc(SEE_ANOTHER_URI ), "SEE ANOTHER URI" );
136         descriptions.put(new Integer JavaDoc(NOT_MODIFIED ), "NOT MODIFIED" );
137         descriptions.put(new Integer JavaDoc(USE_PROXY ), "USE PROXY" );
138         descriptions.put(new Integer JavaDoc(BAD_REQUEST ), "BAD REQUEST" );
139         descriptions.put(new Integer JavaDoc(INVALID_CREDENTIALS ), "INVALID CREDENTIALS" );
140         descriptions.put(new Integer JavaDoc(PAYMENT_REQUIRED ), "PAYMENT REQUIRED" );
141         descriptions.put(new Integer JavaDoc(FORBIDDEN ), "FORBIDDEN" );
142         descriptions.put(new Integer JavaDoc(NOT_FOUND ), "NOT FOUND" );
143         descriptions.put(new Integer JavaDoc(COMMAND_NOT_ALLOWED ), "COMMAND NOT ALLOWED" );
144         descriptions.put(new Integer JavaDoc(OPTIONAL_FEATURE_NOT_SUPPORTED ), "OPTIONAL FEATURE NOT SUPPORTED" );
145         descriptions.put(new Integer JavaDoc(MISSING_CREDENTIALS ), "MISSING CREDENTIALS" );
146         descriptions.put(new Integer JavaDoc(REQUEST_TIMEOUT ), "REQUEST TIMEOUT" );
147         descriptions.put(new Integer JavaDoc(UPDATE_CONFLICT ), "UPDATE CONFLICT" );
148         descriptions.put(new Integer JavaDoc(GONE ), "GONE" );
149         descriptions.put(new Integer JavaDoc(SIZE_REQUIRED ), "SIZE REQUIRED" );
150         descriptions.put(new Integer JavaDoc(INCOMPLETE_COMMAND ), "INCOMPLETE COMMAND" );
151         descriptions.put(new Integer JavaDoc(REQUESTED_ENTITY_TOO_LARGE ), "REQUESTED ENTITY TOO LARGE" );
152         descriptions.put(new Integer JavaDoc(URI_TOO_LONG ), "URI TOO LONG" );
153         descriptions.put(new Integer JavaDoc(UNSUPPORTED_MEDIA_TYPE ), "UNSUPPORTED MEDIA TYPE" );
154         descriptions.put(new Integer JavaDoc(REQUESTED_SIZE_TOO_BIG ), "REQUESTED SIZE TOO BIG" );
155         descriptions.put(new Integer JavaDoc(RETRY_LATER ), "RETRY LATER" );
156         descriptions.put(new Integer JavaDoc(ALREADY_EXISTS ), "ALREADY EXISTS" );
157         descriptions.put(new Integer JavaDoc(CONFLICT_RESOLVED_WITH_SERVER_DATA ), "CONFLICT RESOLVED WITH SERVER DATA" );
158         descriptions.put(new Integer JavaDoc(DEVICE_FULL ), "DEVICE FULL" );
159         descriptions.put(new Integer JavaDoc(UNKNOWN_SEARCH_GRAMMAR ), "UNKNOWN SEARCH GRAMMAR" );
160         descriptions.put(new Integer JavaDoc(BAD_CGI_SCRIPT ), "BAD CGI SCRIPT" );
161         descriptions.put(new Integer JavaDoc(SOFT_DELETE_CONFLICT ), "SOFT DELETE CONFLICT" );
162         descriptions.put(new Integer JavaDoc(OBJECT_SIZE_MISMATCH ), "OBJECT_SIZE_MISMATCH" );
163         descriptions.put(new Integer JavaDoc(PERMISSION_DENIED ), "PERMISSION_DENIED" );
164         descriptions.put(new Integer JavaDoc(COMMAND_FAILED ), "COMMAND FAILED" );
165         descriptions.put(new Integer JavaDoc(COMMAND_NOT_IMPLEMENTED ), "COMMAND NOT IMPLEMENTED" );
166         descriptions.put(new Integer JavaDoc(BAD_GATEWAY ), "BAD GATEWAY" );
167         descriptions.put(new Integer JavaDoc(SERVICE_UNAVAILABLE ), "SERVICE UNAVAILABLE" );
168         descriptions.put(new Integer JavaDoc(GATEWAY_TIMEOUT ), "GATEWAY TIMEOUT" );
169         descriptions.put(new Integer JavaDoc(VERSION_NOT_SUPPORTED ), "VERSION NOT SUPPORTED" );
170         descriptions.put(new Integer JavaDoc(PROCESSING_ERROR ), "PROCESSING ERROR" );
171         descriptions.put(new Integer JavaDoc(ATOMIC_FAILED ), "ATOMIC FAILED" );
172         descriptions.put(new Integer JavaDoc(REFRESH_REQUIRED ), "REFRESH REQUIRED" );
173         descriptions.put(new Integer JavaDoc(RECIPIENT_EXCEPTION_RESERVED1 ), "RECIPIENT EXCEPTION RESERVED1" );
174         descriptions.put(new Integer JavaDoc(DATASTORE_FAILURE ), "DATASTORE FAILURE" );
175         descriptions.put(new Integer JavaDoc(SERVER_FAILURE ), "SERVER FAILURE" );
176         descriptions.put(new Integer JavaDoc(SYNCHRONIZATION_FAILED ), "SYNCHRONIZATION FAILED" );
177         descriptions.put(new Integer JavaDoc(PROTOCOL_VERSION_NOT_SUPPORTED ), "PROTOCOL VERSION NOT SUPPORTED" );
178         descriptions.put(new Integer JavaDoc(OPERATION_CANCELLED ), "OPERATION_CANCELLED" );
179         descriptions.put(new Integer JavaDoc(ATOMIC_ROLLBACK_FAILED ), "ATOMIC_ROLLBACK_FAILED" );
180         descriptions.put(new Integer JavaDoc(ATOMIC_RESPONSE_TOO_LARGE_TO_FIT ), "ATOMIC_RESPONSE_TOO_LARGE_TO_FIT" );
181         descriptions.put(new Integer JavaDoc(SESSION_EXPIRED ), "SESSION_EXPIRED" );
182         descriptions.put(new Integer JavaDoc(SESSION_ABORTED ), "SESSION_ABORTED" );
183     }
184
185     /**
186      * Returns the description associated to the given status code.
187      *
188      * @return the description associated to the given status code
189      */

190     public static String JavaDoc getStatusDescription(int code) {
191         return (String JavaDoc)descriptions.get(new Integer JavaDoc(code));
192     }
193
194     /**
195      *
196      * This constructor is declared 'private'
197      * because we do not want to allow anybody to
198      * instantiate instances of the class
199      *
200      */

201     private StatusCode()
202     {
203     }
204
205 }
Popular Tags