Source Code Cross Referenced for Status.java in  » Web-Services » restlet-1.0.8 » org » restlet » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » restlet 1.0.8 » org.restlet.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2005-2007 Noelios Consulting.
0003:         * 
0004:         * The contents of this file are subject to the terms of the Common Development
0005:         * and Distribution License (the "License"). You may not use this file except in
0006:         * compliance with the License.
0007:         * 
0008:         * You can obtain a copy of the license at
0009:         * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
0010:         * language governing permissions and limitations under the License.
0011:         * 
0012:         * When distributing Covered Code, include this CDDL HEADER in each file and
0013:         * include the License file at http://www.opensource.org/licenses/cddl1.txt If
0014:         * applicable, add the following below this CDDL HEADER, with the fields
0015:         * enclosed by brackets "[]" replaced with your own identifying information:
0016:         * Portions Copyright [yyyy] [name of copyright owner]
0017:         */
0018:
0019:        package org.restlet.data;
0020:
0021:        /**
0022:         * Status to return after handling a call.
0023:         * 
0024:         * @author Jerome Louvel (contact@noelios.com)
0025:         */
0026:        public final class Status extends Metadata {
0027:            private static final String BASE_HTTP = "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html";
0028:
0029:            private static final String BASE_WEBDAV = "http://www.webdav.org/specs/rfc2518.html";
0030:
0031:            private static final String BASE_RESTLET = "http://www.restlet.org/documentation/1.0/api/";
0032:
0033:            /**
0034:             * This interim response (the client has to wait for the final response) is
0035:             * used to inform the client that the initial part of the request has been
0036:             * received and has not yet been rejected or completed by the server.
0037:             * 
0038:             * @see <a
0039:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1.1">HTTP
0040:             *      RFC - 10.1.1 100 Continue</a>
0041:             */
0042:            public static final Status INFO_CONTINUE = new Status(100);
0043:
0044:            /**
0045:             * The server understands and is willing to comply with the client's
0046:             * request, via the Upgrade message header field, for a change in the
0047:             * application protocol being used on this connection.
0048:             * 
0049:             * @see <a
0050:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1.2">HTTP
0051:             *      RFC - 10.1.1 101 Switching Protocols</a>
0052:             */
0053:            public static final Status INFO_SWITCHING_PROTOCOL = new Status(101);
0054:
0055:            /**
0056:             * This interim response is used to inform the client that the server has
0057:             * accepted the complete request, but has not yet completed it since the
0058:             * server has a reasonable expectation that the request will take
0059:             * significant time to complete.
0060:             * 
0061:             * @see <a href="http://www.webdav.org/specs/rfc2518.html#STATUS_102">WEBDAV
0062:             *      RFC - 10.1 102 Processing</a>
0063:             */
0064:            public static final Status INFO_PROCESSING = new Status(102);
0065:
0066:            /**
0067:             * The request has succeeded.
0068:             * 
0069:             * @see <a
0070:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">HTTP
0071:             *      RFC - 10.2.1 200 OK</a>
0072:             */
0073:            public static final Status SUCCESS_OK = new Status(200);
0074:
0075:            /**
0076:             * The request has been fulfilled and resulted in a new resource being
0077:             * created.
0078:             * 
0079:             * @see <a
0080:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2">HTTP
0081:             *      RFC - 10.2.2 201 Created</a>
0082:             */
0083:            public static final Status SUCCESS_CREATED = new Status(201);
0084:
0085:            /**
0086:             * The request has been accepted for processing, but the processing has not
0087:             * been completed.
0088:             * 
0089:             * @see <a
0090:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3">HTTP
0091:             *      RFC - 10.2.3 202 Accepted</a>
0092:             */
0093:            public static final Status SUCCESS_ACCEPTED = new Status(202);
0094:
0095:            /**
0096:             * The request has succeeded but the returned metainformation in the
0097:             * entity-header do not come from the origin server, but is gathered from a
0098:             * local or a third-party copy.
0099:             * 
0100:             * @see <a
0101:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.4">HTTP
0102:             *      RFC - 10.2.4 203 Non-Authoritative Information</a>
0103:             */
0104:            public static final Status SUCCESS_NON_AUTHORITATIVE = new Status(
0105:                    203);
0106:
0107:            /**
0108:             * The server has fulfilled the request but does not need to return an
0109:             * entity-body (for example after a DELETE), and might want to return
0110:             * updated metainformation.
0111:             * 
0112:             * @see <a
0113:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5">HTTP
0114:             *      RFC - 10.2.5 204 No Content</a>
0115:             */
0116:            public static final Status SUCCESS_NO_CONTENT = new Status(204);
0117:
0118:            /**
0119:             * The server has fulfilled the request and the user agent SHOULD reset the
0120:             * document view which caused the request to be sent.
0121:             * 
0122:             * @see <a
0123:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.6">HTTP
0124:             *      RFC - 10.2.6 205 Reset Content</a>
0125:             */
0126:            public static final Status SUCCESS_RESET_CONTENT = new Status(205);
0127:
0128:            /**
0129:             * The server has fulfilled the partial GET request for the resource
0130:             * assuming the request has included a Range header field indicating the
0131:             * desired range.
0132:             * 
0133:             * @see <a
0134:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.7">HTTP
0135:             *      RFC - 10.2.7 206 Partial Content</a>
0136:             */
0137:            public static final Status SUCCESS_PARTIAL_CONTENT = new Status(206);
0138:
0139:            /**
0140:             * This response is used to inform the client that the HTTP response entity
0141:             * contains a set of status codes generated during the method invocation.
0142:             * 
0143:             * @see <a href="http://www.webdav.org/specs/rfc2518.html#STATUS_207">WEBDAV
0144:             *      RFC - 10.2 207 Multi-Status</a>
0145:             */
0146:            public static final Status SUCCESS_MULTI_STATUS = new Status(207);
0147:
0148:            /**
0149:             * The server lets the user agent choosing one of the multiple
0150:             * representations of the requested resource, each representation having its
0151:             * own specific location provided in the response entity.
0152:             * 
0153:             * @see <a
0154:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1">HTTP
0155:             *      RFC - 10.3.1 300 Multiple Choices</a>
0156:             */
0157:            public static final Status REDIRECTION_MULTIPLE_CHOICES = new Status(
0158:                    300);
0159:
0160:            /**
0161:             * The requested resource has been assigned a new permanent URI and any
0162:             * future references to this resource SHOULD use one of the returned URIs.
0163:             * 
0164:             * @see <a
0165:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2">HTTP
0166:             *      RFC - 10.3.2 301 Moved Permanently</a>
0167:             */
0168:            public static final Status REDIRECTION_PERMANENT = new Status(301);
0169:
0170:            /**
0171:             * The requested resource resides temporarily under a different URI which
0172:             * should not be used for future requests by the client (use status codes
0173:             * 303 or 307 instead since this status has been manifestly misused).
0174:             * 
0175:             * @see <a
0176:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.3">HTTP
0177:             *      RFC - 10.3.3 302 Found</a>
0178:             */
0179:            public static final Status REDIRECTION_FOUND = new Status(302);
0180:
0181:            /**
0182:             * The response to the request can be found under a different URI and SHOULD
0183:             * be retrieved using a GET method on that resource.
0184:             * 
0185:             * @see <a
0186:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4">HTTP
0187:             *      RFC - 10.3.4 303 See Other</a>
0188:             */
0189:            public static final Status REDIRECTION_SEE_OTHER = new Status(303);
0190:
0191:            /**
0192:             * Status code sent by the server in response to a conditional GET request
0193:             * in case the document has not been modified.
0194:             * 
0195:             * @see <a
0196:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5">HTTP
0197:             *      RFC - 10.3.5 304 Not Modified</a>
0198:             */
0199:            public static final Status REDIRECTION_NOT_MODIFIED = new Status(
0200:                    304);
0201:
0202:            /**
0203:             * The requested resource MUST be accessed through the proxy given by the
0204:             * Location field.
0205:             * 
0206:             * @see <a
0207:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.6">HTTP
0208:             *      RFC - 10.3.6 305 Use Proxy</a>
0209:             */
0210:            public static final Status REDIRECTION_USE_PROXY = new Status(305);
0211:
0212:            /**
0213:             * The requested resource resides temporarily under a different URI which
0214:             * should not be used for future requests by the client.
0215:             * 
0216:             * @see <a
0217:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.8">HTTP
0218:             *      RFC - 10.3.8 307 Temporary Redirect</a>
0219:             */
0220:            public static final Status REDIRECTION_TEMPORARY = new Status(307);
0221:
0222:            /**
0223:             * The request could not be understood by the server due to malformed
0224:             * syntax.
0225:             * 
0226:             * @see <a
0227:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">HTTP
0228:             *      RFC - 10.4.1 400 Bad Request</a>
0229:             */
0230:            public static final Status CLIENT_ERROR_BAD_REQUEST = new Status(
0231:                    400);
0232:
0233:            /**
0234:             * The request requires user authentication.
0235:             * 
0236:             * @see <a
0237:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">HTTP
0238:             *      RFC - 10.4.2 401 Unauthorized</a>
0239:             */
0240:            public static final Status CLIENT_ERROR_UNAUTHORIZED = new Status(
0241:                    401);
0242:
0243:            /**
0244:             * This code is reserved for future use.
0245:             * 
0246:             * @see <a
0247:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.3">HTTP
0248:             *      RFC - 10.4.3 402 Payment Required</a>
0249:             */
0250:            public static final Status CLIENT_ERROR_PAYMENT_REQUIRED = new Status(
0251:                    402);
0252:
0253:            /**
0254:             * The server understood the request, but is refusing to fulfill it as it
0255:             * could be explained in the entity.
0256:             * 
0257:             * @see <a
0258:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4">HTTP
0259:             *      RFC - 10.4.4 403 Forbidden</a>
0260:             */
0261:            public static final Status CLIENT_ERROR_FORBIDDEN = new Status(403);
0262:
0263:            /**
0264:             * The server has not found anything matching the Request-URI or the server
0265:             * does not wish to reveal exactly why the request has been refused, or no
0266:             * other response is applicable.
0267:             * 
0268:             * @see <a
0269:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">HTTP
0270:             *      RFC - 10.4.5 404 Not Found</a>
0271:             */
0272:            public static final Status CLIENT_ERROR_NOT_FOUND = new Status(404);
0273:
0274:            /**
0275:             * The method specified in the Request-Line is not allowed for the resource
0276:             * identified by the Request-URI.
0277:             * 
0278:             * @see <a
0279:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6">HTTP
0280:             *      RFC - 10.4.6 405 Method Not Allowed</a>
0281:             */
0282:            public static final Status CLIENT_ERROR_METHOD_NOT_ALLOWED = new Status(
0283:                    405);
0284:
0285:            /**
0286:             * The resource identified by the request is only capable of generating
0287:             * response entities whose content characteristics do not match the user's
0288:             * requirements (in Accept* headers).
0289:             * 
0290:             * @see <a
0291:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7">HTTP
0292:             *      RFC - 10.4.7 406 Not Acceptable</a>
0293:             */
0294:            public static final Status CLIENT_ERROR_NOT_ACCEPTABLE = new Status(
0295:                    406);
0296:
0297:            /**
0298:             * This code is similar to 401 (Unauthorized), but indicates that the client
0299:             * must first authenticate itself with the proxy.
0300:             * 
0301:             * @see <a
0302:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.8">HTTP
0303:             *      RFC - 10.4.8 407 Proxy Authentication Required</a>
0304:             */
0305:            public static final Status CLIENT_ERROR_PROXY_AUTHENTIFICATION_REQUIRED = new Status(
0306:                    407);
0307:
0308:            /**
0309:             * Sent by the server when an HTTP client opens a connection, but has never
0310:             * sent a request (or never sent the blank line that signals the end of the
0311:             * request).
0312:             * 
0313:             * @see <a
0314:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.9">HTTP
0315:             *      RFC - 10.4.9 408 Request Timeout</a>
0316:             */
0317:            public static final Status CLIENT_ERROR_REQUEST_TIMEOUT = new Status(
0318:                    408);
0319:
0320:            /**
0321:             * The request could not be completed due to a conflict with the current
0322:             * state of the resource (as experienced in a version control system).
0323:             * 
0324:             * @see <a
0325:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10">HTTP
0326:             *      RFC - 10.4.10 409 Conflict</a>
0327:             */
0328:            public static final Status CLIENT_ERROR_CONFLICT = new Status(409);
0329:
0330:            /**
0331:             * The requested resource is no longer available at the server and no
0332:             * forwarding address is known.
0333:             * 
0334:             * @see <a
0335:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.11">HTTP
0336:             *      RFC - 10.4.11 410 Gone</a>
0337:             */
0338:            public static final Status CLIENT_ERROR_GONE = new Status(410);
0339:
0340:            /**
0341:             * The server refuses to accept the request without a defined
0342:             * Content-Length.
0343:             * 
0344:             * @see <a
0345:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.12">HTTP
0346:             *      RFC - 10.4.12 411 Length Required</a>
0347:             */
0348:            public static final Status CLIENT_ERROR_LENGTH_REQUIRED = new Status(
0349:                    411);
0350:
0351:            /**
0352:             * Sent by the server when the user agent asks the server to carry out a
0353:             * request under certain conditions that are not met.
0354:             * 
0355:             * @see <a
0356:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.13">HTTP
0357:             *      RFC - 10.4.13 412 Precondition Failed</a>
0358:             */
0359:            public static final Status CLIENT_ERROR_PRECONDITION_FAILED = new Status(
0360:                    412);
0361:
0362:            /**
0363:             * The server is refusing to process a request because the request entity is
0364:             * larger than the server is willing or able to process.
0365:             * 
0366:             * @see <a
0367:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.14">HTTP
0368:             *      RFC - 10.4.14 413 Request Entity Too Large</a>
0369:             */
0370:            public static final Status CLIENT_ERROR_REQUEST_ENTITY_TOO_LARGE = new Status(
0371:                    413);
0372:
0373:            /**
0374:             * The server is refusing to service the request because the Request-URI is
0375:             * longer than the server is willing to interpret.
0376:             * 
0377:             * @see <a
0378:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.15">HTTP
0379:             *      RFC - 10.4.15 414 Request-URI Too Long</a>
0380:             */
0381:            public static final Status CLIENT_ERROR_REQUEST_URI_TOO_LONG = new Status(
0382:                    414);
0383:
0384:            /**
0385:             * The server is refusing to service the request because the entity of the
0386:             * request is in a format not supported by the requested resource for the
0387:             * requested method.
0388:             * 
0389:             * @see <a
0390:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16">HTTP
0391:             *      RFC - 10.4.16 415 Unsupported Media Type</a>
0392:             */
0393:            public static final Status CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE = new Status(
0394:                    415);
0395:
0396:            /**
0397:             * The request includes a Range request-header field and the selected
0398:             * resource is too small for any of the byte-ranges to apply.
0399:             * 
0400:             * @see <a
0401:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.17">HTTP
0402:             *      RFC - 10.4.17 416 Requested Range Not Satisfiable</a>
0403:             */
0404:            public static final Status CLIENT_ERROR_REQUESTED_RANGE_NOT_SATISFIABLE = new Status(
0405:                    416);
0406:
0407:            /**
0408:             * The user agent expects some behaviour of the server (given in an Expect
0409:             * request-header field), but this expectation could not be met by this
0410:             * server.
0411:             * 
0412:             * @see <a
0413:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.18">HTTP
0414:             *      RFC - 10.4.18 417 Expectation Failed</a>
0415:             */
0416:            public static final Status CLIENT_ERROR_EXPECTATION_FAILED = new Status(
0417:                    417);
0418:
0419:            /**
0420:             * This status code means the server understands the content type of the
0421:             * request entity (syntactically correct) but was unable to process the
0422:             * contained instructions.
0423:             * 
0424:             * @see <a href="http://www.webdav.org/specs/rfc2518.html#STATUS_422">WEBDAV
0425:             *      RFC - 10.3 422 Unprocessable Entity</a>
0426:             */
0427:            public static final Status CLIENT_ERROR_UNPROCESSABLE_ENTITY = new Status(
0428:                    422);
0429:
0430:            /**
0431:             * The source or destination resource of a method is locked (or temporarily
0432:             * involved in another process).
0433:             * 
0434:             * @see <a href="http://www.webdav.org/specs/rfc2518.html#STATUS_423">WEBDAV
0435:             *      RFC - 10.4 423 Locked</a>
0436:             */
0437:            public static final Status CLIENT_ERROR_LOCKED = new Status(423);
0438:
0439:            /**
0440:             * This status code means that the method could not be performed on the
0441:             * resource because the requested action depended on another action and that
0442:             * action failed.
0443:             * 
0444:             * @see <a href="http://www.webdav.org/specs/rfc2518.html#STATUS_424">WEBDAV
0445:             *      RFC - 10.5 424 Failed Dependency</a>
0446:             */
0447:            public static final Status CLIENT_ERROR_FAILED_DEPENDENCY = new Status(
0448:                    424);
0449:
0450:            /**
0451:             * The server encountered an unexpected condition which prevented it from
0452:             * fulfilling the request.
0453:             * 
0454:             * @see <a
0455:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">HTTP
0456:             *      RFC - 10.5.1 500 Internal Server Error</a>
0457:             */
0458:            public static final Status SERVER_ERROR_INTERNAL = new Status(500);
0459:
0460:            /**
0461:             * The server does not support the functionality required to fulfill the
0462:             * request.
0463:             * 
0464:             * @see <a
0465:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.2">HTTP
0466:             *      RFC - 10.5.2 501 Not Implemented</a>
0467:             */
0468:            public static final Status SERVER_ERROR_NOT_IMPLEMENTED = new Status(
0469:                    501);
0470:
0471:            /**
0472:             * The server, while acting as a gateway or proxy, received an invalid
0473:             * response from the upstream server it accessed in attempting to fulfill
0474:             * the request.
0475:             * 
0476:             * @see <a
0477:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.3">HTTP
0478:             *      RFC - 10.5.3 502 Bad Gateway</a>
0479:             */
0480:            public static final Status SERVER_ERROR_BAD_GATEWAY = new Status(
0481:                    502);
0482:
0483:            /**
0484:             * The server is currently unable to handle the request due to a temporary
0485:             * overloading or maintenance of the server.
0486:             * 
0487:             * @see <a
0488:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4">HTTP
0489:             *      RFC - 10.5.4 503 Service Unavailable</a>
0490:             */
0491:            public static final Status SERVER_ERROR_SERVICE_UNAVAILABLE = new Status(
0492:                    503);
0493:
0494:            /**
0495:             * The server, while acting as a gateway or proxy, could not connect to the
0496:             * upstream server.
0497:             * 
0498:             * @see <a
0499:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.5">HTTP
0500:             *      RFC - 10.5.5 504 Gateway Timeout</a>
0501:             */
0502:            public static final Status SERVER_ERROR_GATEWAY_TIMEOUT = new Status(
0503:                    504);
0504:
0505:            /**
0506:             * The server does not support, or refuses to support, the HTTP protocol
0507:             * version that was used in the request message.
0508:             * 
0509:             * @see <a
0510:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.6">HTTP
0511:             *      RFC - 10.5.6 505 HTTP Version Not Supported</a>
0512:             */
0513:            public static final Status SERVER_ERROR_VERSION_NOT_SUPPORTED = new Status(
0514:                    505);
0515:
0516:            /**
0517:             * This status code means the method could not be performed on the resource
0518:             * because the server is unable to store the representation needed to
0519:             * successfully complete the request.
0520:             * 
0521:             * @see <a href="http://www.webdav.org/specs/rfc2518.html#STATUS_507">WEBDAV
0522:             *      RFC - 10.6 507 Insufficient Storage</a>
0523:             */
0524:            public static final Status SERVER_ERROR_INSUFFICIENT_STORAGE = new Status(
0525:                    507);
0526:
0527:            /**
0528:             * A client connector can not connect to the remote server.
0529:             */
0530:            public static final Status CONNECTOR_ERROR_CONNECTION = new Status(
0531:                    1000);
0532:
0533:            /**
0534:             * A client connector faces an error during the communication with the
0535:             * remote server (interruption, timeout, etc).
0536:             */
0537:            public static final Status CONNECTOR_ERROR_COMMUNICATION = new Status(
0538:                    1001);
0539:
0540:            /**
0541:             * Generic status code sent by a client connector when an error occurs
0542:             * during the process of a request to its server or the process of a
0543:             * response to its client.
0544:             */
0545:            public static final Status CONNECTOR_ERROR_INTERNAL = new Status(
0546:                    1002);
0547:
0548:            /**
0549:             * Indicates if the status is a client error status.
0550:             * 
0551:             * @param code
0552:             *                The code of the status.
0553:             * @return True if the status is a client error status.
0554:             */
0555:            public static boolean isClientError(int code) {
0556:                boolean result = false;
0557:
0558:                switch (code) {
0559:                case 400:
0560:                case 401:
0561:                case 402:
0562:                case 403:
0563:                case 404:
0564:                case 405:
0565:                case 406:
0566:                case 407:
0567:                case 408:
0568:                case 409:
0569:                case 410:
0570:                case 411:
0571:                case 412:
0572:                case 413:
0573:                case 414:
0574:                case 415:
0575:                case 416:
0576:                case 417:
0577:                case 422:
0578:                case 423:
0579:                case 424:
0580:                    result = true;
0581:                    break;
0582:                }
0583:
0584:                return result;
0585:            }
0586:
0587:            /**
0588:             * Indicates if the status is a connector error status.
0589:             * 
0590:             * @param code
0591:             *                The code of the status.
0592:             * @return True if the status is a server error status.
0593:             */
0594:            public static boolean isConnectorError(int code) {
0595:                boolean result = false;
0596:
0597:                switch (code) {
0598:                case 1000:
0599:                case 1001:
0600:                case 1002:
0601:                    result = true;
0602:                    break;
0603:                }
0604:
0605:                return result;
0606:            }
0607:
0608:            /**
0609:             * Indicates if the status is an error (client or server) status.
0610:             * 
0611:             * @param code
0612:             *                The code of the status.
0613:             * @return True if the status is an error (client or server) status.
0614:             */
0615:            public static boolean isError(int code) {
0616:                return isClientError(code) || isServerError(code)
0617:                        || isConnectorError(code);
0618:            }
0619:
0620:            /**
0621:             * Indicates if the status is an information status.
0622:             * 
0623:             * @param code
0624:             *                The code of the status.
0625:             * @return True if the status is an information status.
0626:             */
0627:            public static boolean isInfo(int code) {
0628:                boolean result = false;
0629:
0630:                switch (code) {
0631:                case 100:
0632:                case 101:
0633:                case 102:
0634:                    result = true;
0635:                    break;
0636:                }
0637:
0638:                return result;
0639:            }
0640:
0641:            /**
0642:             * Indicates if the status is a redirection status.
0643:             * 
0644:             * @param code
0645:             *                The code of the status.
0646:             * @return True if the status is a redirection status.
0647:             */
0648:            public static boolean isRedirection(int code) {
0649:                boolean result = false;
0650:
0651:                switch (code) {
0652:                case 300:
0653:                case 301:
0654:                case 302:
0655:                case 303:
0656:                case 304:
0657:                case 305:
0658:                case 307:
0659:                    result = true;
0660:                    break;
0661:                }
0662:
0663:                return result;
0664:            }
0665:
0666:            /**
0667:             * Indicates if the status is a server error status.
0668:             * 
0669:             * @param code
0670:             *                The code of the status.
0671:             * @return True if the status is a server error status.
0672:             */
0673:            public static boolean isServerError(int code) {
0674:                boolean result = false;
0675:
0676:                switch (code) {
0677:                case 500:
0678:                case 501:
0679:                case 502:
0680:                case 503:
0681:                case 504:
0682:                case 505:
0683:                case 507:
0684:                    result = true;
0685:                    break;
0686:                }
0687:
0688:                return result;
0689:            }
0690:
0691:            /**
0692:             * Indicates if the status is a success status.
0693:             * 
0694:             * @param code
0695:             *                The code of the status.
0696:             * @return True if the status is a success status.
0697:             */
0698:            public static boolean isSuccess(int code) {
0699:                boolean result = false;
0700:
0701:                switch (code) {
0702:                case 200:
0703:                case 201:
0704:                case 202:
0705:                case 203:
0706:                case 204:
0707:                case 205:
0708:                case 206:
0709:                case 207:
0710:                    result = true;
0711:                    break;
0712:                }
0713:
0714:                return result;
0715:            }
0716:
0717:            /**
0718:             * Returns the status associated to a code. If an existing constant exists
0719:             * then it is returned, otherwise a new instance is created.
0720:             * 
0721:             * @param code
0722:             *                The code.
0723:             * @return The associated status.
0724:             */
0725:            public static Status valueOf(int code) {
0726:                Status result = null;
0727:
0728:                switch (code) {
0729:                case 100:
0730:                    result = INFO_CONTINUE;
0731:                    break;
0732:                case 101:
0733:                    result = INFO_SWITCHING_PROTOCOL;
0734:                    break;
0735:                case 102:
0736:                    result = INFO_PROCESSING;
0737:                    break;
0738:
0739:                case 200:
0740:                    result = SUCCESS_OK;
0741:                    break;
0742:                case 201:
0743:                    result = SUCCESS_CREATED;
0744:                    break;
0745:                case 202:
0746:                    result = SUCCESS_ACCEPTED;
0747:                    break;
0748:                case 203:
0749:                    result = SUCCESS_NON_AUTHORITATIVE;
0750:                    break;
0751:                case 204:
0752:                    result = SUCCESS_NO_CONTENT;
0753:                    break;
0754:                case 205:
0755:                    result = SUCCESS_RESET_CONTENT;
0756:                    break;
0757:                case 206:
0758:                    result = SUCCESS_PARTIAL_CONTENT;
0759:                    break;
0760:                case 207:
0761:                    result = SUCCESS_MULTI_STATUS;
0762:                    break;
0763:
0764:                case 300:
0765:                    result = REDIRECTION_MULTIPLE_CHOICES;
0766:                    break;
0767:                case 301:
0768:                    result = REDIRECTION_PERMANENT;
0769:                    break;
0770:                case 302:
0771:                    result = REDIRECTION_FOUND;
0772:                    break;
0773:                case 303:
0774:                    result = REDIRECTION_SEE_OTHER;
0775:                    break;
0776:                case 304:
0777:                    result = REDIRECTION_NOT_MODIFIED;
0778:                    break;
0779:                case 305:
0780:                    result = REDIRECTION_USE_PROXY;
0781:                    break;
0782:                case 307:
0783:                    result = REDIRECTION_TEMPORARY;
0784:                    break;
0785:
0786:                case 400:
0787:                    result = CLIENT_ERROR_BAD_REQUEST;
0788:                    break;
0789:                case 401:
0790:                    result = CLIENT_ERROR_UNAUTHORIZED;
0791:                    break;
0792:                case 402:
0793:                    result = CLIENT_ERROR_PAYMENT_REQUIRED;
0794:                    break;
0795:                case 403:
0796:                    result = CLIENT_ERROR_FORBIDDEN;
0797:                    break;
0798:                case 404:
0799:                    result = CLIENT_ERROR_NOT_FOUND;
0800:                    break;
0801:                case 405:
0802:                    result = CLIENT_ERROR_METHOD_NOT_ALLOWED;
0803:                    break;
0804:                case 406:
0805:                    result = CLIENT_ERROR_NOT_ACCEPTABLE;
0806:                    break;
0807:                case 407:
0808:                    result = CLIENT_ERROR_PROXY_AUTHENTIFICATION_REQUIRED;
0809:                    break;
0810:                case 408:
0811:                    result = CLIENT_ERROR_REQUEST_TIMEOUT;
0812:                    break;
0813:                case 409:
0814:                    result = CLIENT_ERROR_CONFLICT;
0815:                    break;
0816:                case 410:
0817:                    result = CLIENT_ERROR_GONE;
0818:                    break;
0819:                case 411:
0820:                    result = CLIENT_ERROR_LENGTH_REQUIRED;
0821:                    break;
0822:                case 412:
0823:                    result = CLIENT_ERROR_PRECONDITION_FAILED;
0824:                    break;
0825:                case 413:
0826:                    result = CLIENT_ERROR_REQUEST_ENTITY_TOO_LARGE;
0827:                    break;
0828:                case 414:
0829:                    result = CLIENT_ERROR_REQUEST_URI_TOO_LONG;
0830:                    break;
0831:                case 415:
0832:                    result = CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE;
0833:                    break;
0834:                case 416:
0835:                    result = CLIENT_ERROR_REQUESTED_RANGE_NOT_SATISFIABLE;
0836:                    break;
0837:                case 417:
0838:                    result = CLIENT_ERROR_EXPECTATION_FAILED;
0839:                    break;
0840:                case 422:
0841:                    result = CLIENT_ERROR_UNPROCESSABLE_ENTITY;
0842:                    break;
0843:                case 423:
0844:                    result = CLIENT_ERROR_LOCKED;
0845:                    break;
0846:                case 424:
0847:                    result = CLIENT_ERROR_FAILED_DEPENDENCY;
0848:                    break;
0849:
0850:                case 500:
0851:                    result = SERVER_ERROR_INTERNAL;
0852:                    break;
0853:                case 501:
0854:                    result = SERVER_ERROR_NOT_IMPLEMENTED;
0855:                    break;
0856:                case 502:
0857:                    result = SERVER_ERROR_BAD_GATEWAY;
0858:                    break;
0859:                case 503:
0860:                    result = SERVER_ERROR_SERVICE_UNAVAILABLE;
0861:                    break;
0862:                case 504:
0863:                    result = SERVER_ERROR_GATEWAY_TIMEOUT;
0864:                    break;
0865:                case 505:
0866:                    result = SERVER_ERROR_VERSION_NOT_SUPPORTED;
0867:                    break;
0868:                case 507:
0869:                    result = SERVER_ERROR_INSUFFICIENT_STORAGE;
0870:                    break;
0871:
0872:                case 1000:
0873:                    result = CONNECTOR_ERROR_CONNECTION;
0874:                    break;
0875:                case 1001:
0876:                    result = CONNECTOR_ERROR_COMMUNICATION;
0877:                    break;
0878:                case 1002:
0879:                    result = CONNECTOR_ERROR_INTERNAL;
0880:                    break;
0881:                }
0882:
0883:                return result;
0884:            }
0885:
0886:            /** The specification code. */
0887:            private int code;
0888:
0889:            /** The URI of the specification describing the method. */
0890:            private String uri;
0891:
0892:            /**
0893:             * Constructor.
0894:             * 
0895:             * @param code
0896:             *                The specification code.
0897:             */
0898:            public Status(int code) {
0899:                this (code, null, null, null);
0900:            }
0901:
0902:            /**
0903:             * Constructor.
0904:             * 
0905:             * @param code
0906:             *                The specification code.
0907:             * @param name
0908:             *                The name.
0909:             * @param description
0910:             *                The description.
0911:             * @param uri
0912:             *                The URI of the specification describing the method.
0913:             */
0914:            public Status(int code, final String name,
0915:                    final String description, final String uri) {
0916:                super (name, checkDescription(description));
0917:                this .code = code;
0918:                this .uri = uri;
0919:            }
0920:
0921:            /**
0922:             * Constructor.
0923:             * 
0924:             * @param status
0925:             *                The status to copy.
0926:             * @param description
0927:             *                The description to associate.
0928:             */
0929:            public Status(final Status status, final String description) {
0930:                this (status.getCode(), status.getName(), description, status
0931:                        .getUri());
0932:            }
0933:
0934:            /**
0935:             * Indicates if the status is equal to a given one.
0936:             * 
0937:             * @param object
0938:             *                The object to compare to.
0939:             * @return True if the status is equal to a given one.
0940:             */
0941:            @Override
0942:            public boolean equals(final Object object) {
0943:                return (object instanceof  Status)
0944:                        && (this .code == ((Status) object).getCode());
0945:            }
0946:
0947:            /**
0948:             * Returns the corresponding code (HTTP or WebDAV or custom code).
0949:             * 
0950:             * @return The corresponding code.
0951:             */
0952:            public int getCode() {
0953:                return this .code;
0954:            }
0955:
0956:            /**
0957:             * Returns the description.
0958:             * 
0959:             * @return The description.
0960:             */
0961:            public String getDescription() {
0962:                String result = super .getDescription();
0963:
0964:                if (result == null) {
0965:                    switch (this .code) {
0966:                    case 100:
0967:                        result = "The client should continue with its request";
0968:                        break;
0969:                    case 101:
0970:                        result = "The server is willing to change the application protocol being used on this connection";
0971:                        break;
0972:                    case 102:
0973:                        result = "Interim response used to inform the client that the server has accepted the complete request, but has not yet completed it";
0974:                        break;
0975:
0976:                    case 200:
0977:                        result = "The request has succeeded";
0978:                        break;
0979:                    case 201:
0980:                        result = "The request has been fulfilled and resulted in a new resource being created";
0981:                        break;
0982:                    case 202:
0983:                        result = "The request has been accepted for processing, but the processing has not been completed";
0984:                        break;
0985:                    case 203:
0986:                        result = "The returned metainformation is not the definitive set as available from the origin server";
0987:                        break;
0988:                    case 204:
0989:                        result = "The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation";
0990:                        break;
0991:                    case 205:
0992:                        result = "The server has fulfilled the request and the user agent should reset the document view which caused the request to be sent";
0993:                        break;
0994:                    case 206:
0995:                        result = "The server has fulfilled the partial get request for the resource";
0996:                        break;
0997:                    case 207:
0998:                        result = "Provides status for multiple independent operations";
0999:                        break;
1000:
1001:                    case 300:
1002:                        result = "The requested resource corresponds to any one of a set of representations";
1003:                        break;
1004:                    case 301:
1005:                        result = "The requested resource has been assigned a new permanent URI";
1006:                        break;
1007:                    case 302:
1008:                        result = "The requested resource can be found under a different URI";
1009:                        break;
1010:                    case 303:
1011:                        result = "The response to the request can be found under a different URI";
1012:                        break;
1013:                    case 304:
1014:                        result = "The client has performed a conditional GET request and the document has not been modified";
1015:                        break;
1016:                    case 305:
1017:                        result = "The requested resource must be accessed through the proxy given by the location field";
1018:                        break;
1019:                    case 307:
1020:                        result = "The requested resource resides temporarily under a different URI";
1021:                        break;
1022:
1023:                    case 400:
1024:                        result = "The request could not be understood by the server due to malformed syntax";
1025:                        break;
1026:                    case 401:
1027:                        result = "The request requires user authentication";
1028:                        break;
1029:                    case 402:
1030:                        result = "This code is reserved for future use";
1031:                        break;
1032:                    case 403:
1033:                        result = "The server understood the request, but is refusing to fulfill it";
1034:                        break;
1035:                    case 404:
1036:                        result = "The server has not found anything matching the request URI";
1037:                        break;
1038:                    case 405:
1039:                        result = "The method specified in the request is not allowed for the resource identified by the request URI";
1040:                        break;
1041:                    case 406:
1042:                        result = "The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request";
1043:                        break;
1044:                    case 407:
1045:                        result = "This code is similar to Unauthorized, but indicates that the client must first authenticate itself with the proxy";
1046:                        break;
1047:                    case 408:
1048:                        result = "The client did not produce a request within the time that the server was prepared to wait";
1049:                        break;
1050:                    case 409:
1051:                        result = "The request could not be completed due to a conflict with the current state of the resource";
1052:                        break;
1053:                    case 410:
1054:                        result = "The requested resource is no longer available at the server and no forwarding address is known";
1055:                        break;
1056:                    case 411:
1057:                        result = "The server refuses to accept the request without a defined content length";
1058:                        break;
1059:                    case 412:
1060:                        result = "The precondition given in one or more of the request header fields evaluated to false when it was tested on the server";
1061:                        break;
1062:                    case 413:
1063:                        result = "The server is refusing to process a request because the request entity is larger than the server is willing or able to process";
1064:                        break;
1065:                    case 414:
1066:                        result = "The server is refusing to service the request because the request URI is longer than the server is willing to interpret";
1067:                        break;
1068:                    case 415:
1069:                        result = "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method";
1070:                        break;
1071:                    case 416:
1072:                        result = "For byte ranges, this means that the first byte position were greater than the current length of the selected resource";
1073:                        break;
1074:                    case 417:
1075:                        result = "The expectation given in the request header could not be met by this server";
1076:                        break;
1077:                    case 422:
1078:                        result = "The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions";
1079:                        break;
1080:                    case 423:
1081:                        result = "The source or destination resource of a method is locked";
1082:                        break;
1083:                    case 424:
1084:                        result = "The method could not be performed on the resource because the requested action depended on another action and that action failed";
1085:                        break;
1086:
1087:                    case 500:
1088:                        result = "The server encountered an unexpected condition which prevented it from fulfilling the request";
1089:                        break;
1090:                    case 501:
1091:                        result = "The server does not support the functionality required to fulfill the request";
1092:                        break;
1093:                    case 502:
1094:                        result = "The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request";
1095:                        break;
1096:                    case 503:
1097:                        result = "The server is currently unable to handle the request due to a temporary overloading or maintenance of the server";
1098:                        break;
1099:                    case 504:
1100:                        result = "The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request";
1101:                        break;
1102:                    case 505:
1103:                        result = "The server does not support, or refuses to support, the protocol version that was used in the request message";
1104:                        break;
1105:                    case 507:
1106:                        result = "The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request";
1107:                        break;
1108:
1109:                    case 1000:
1110:                        result = "The connector failed to connect to the server";
1111:                        break;
1112:                    case 1001:
1113:                        result = "The connector failed to complete the communication with the server";
1114:                        break;
1115:                    case 1002:
1116:                        result = "The connector encountered an unexpected condition which prevented it from fulfilling the request";
1117:                        break;
1118:                    }
1119:                }
1120:
1121:                return result;
1122:            }
1123:
1124:            /**
1125:             * Returns the name of this status.
1126:             * 
1127:             * @return The name of this status.
1128:             */
1129:            public String getName() {
1130:                String result = super .getName();
1131:
1132:                if (result == null) {
1133:                    switch (this .code) {
1134:                    case 100:
1135:                        result = "Continue";
1136:                        break;
1137:                    case 101:
1138:                        result = "Switching Protocols";
1139:                        break;
1140:                    case 102:
1141:                        result = "Processing";
1142:                        break;
1143:
1144:                    case 200:
1145:                        result = "OK";
1146:                        break;
1147:                    case 201:
1148:                        result = "Created";
1149:                        break;
1150:                    case 202:
1151:                        result = "Accepted";
1152:                        break;
1153:                    case 203:
1154:                        result = "Non-Authoritative Information";
1155:                        break;
1156:                    case 204:
1157:                        result = "No Content";
1158:                        break;
1159:                    case 205:
1160:                        result = "Reset Content";
1161:                        break;
1162:                    case 206:
1163:                        result = "Partial Content";
1164:                        break;
1165:                    case 207:
1166:                        result = "Multi-Status";
1167:                        break;
1168:
1169:                    case 300:
1170:                        result = "Multiple Choices";
1171:                        break;
1172:                    case 301:
1173:                        result = "Moved Permanently";
1174:                        break;
1175:                    case 302:
1176:                        result = "Found";
1177:                        break;
1178:                    case 303:
1179:                        result = "See Other";
1180:                        break;
1181:                    case 304:
1182:                        result = "Not Modified";
1183:                        break;
1184:                    case 305:
1185:                        result = "Use Proxy";
1186:                        break;
1187:                    case 307:
1188:                        result = "Temporary Redirect";
1189:                        break;
1190:
1191:                    case 400:
1192:                        result = "Bad Request";
1193:                        break;
1194:                    case 401:
1195:                        result = "Unauthorized";
1196:                        break;
1197:                    case 402:
1198:                        result = "Payment Required";
1199:                        break;
1200:                    case 403:
1201:                        result = "Forbidden";
1202:                        break;
1203:                    case 404:
1204:                        result = "Not Found";
1205:                        break;
1206:                    case 405:
1207:                        result = "Method Not Allowed";
1208:                        break;
1209:                    case 406:
1210:                        result = "Not Acceptable";
1211:                        break;
1212:                    case 407:
1213:                        result = "Proxy Authentication Required";
1214:                        break;
1215:                    case 408:
1216:                        result = "Request Timeout";
1217:                        break;
1218:                    case 409:
1219:                        result = "Conflict";
1220:                        break;
1221:                    case 410:
1222:                        result = "Gone";
1223:                        break;
1224:                    case 411:
1225:                        result = "Length Required";
1226:                        break;
1227:                    case 412:
1228:                        result = "Precondition Failed";
1229:                        break;
1230:                    case 413:
1231:                        result = "Request Entity Too Large";
1232:                        break;
1233:                    case 414:
1234:                        result = "Request URI Too Long";
1235:                        break;
1236:                    case 415:
1237:                        result = "Unsupported Media Type";
1238:                        break;
1239:                    case 416:
1240:                        result = "Requested Range Not Satisfiable";
1241:                        break;
1242:                    case 417:
1243:                        result = "Expectation Failed";
1244:                        break;
1245:                    case 422:
1246:                        result = "Unprocessable Entity";
1247:                        break;
1248:                    case 423:
1249:                        result = "Locked";
1250:                        break;
1251:                    case 424:
1252:                        result = "Failed Dependency";
1253:                        break;
1254:
1255:                    case 500:
1256:                        result = "Internal Server Error";
1257:                        break;
1258:                    case 501:
1259:                        result = "Not Implemented";
1260:                        break;
1261:                    case 502:
1262:                        result = "Bad Gateway";
1263:                        break;
1264:                    case 503:
1265:                        result = "Service Unavailable";
1266:                        break;
1267:                    case 504:
1268:                        result = "Gateway Timeout";
1269:                        break;
1270:                    case 505:
1271:                        result = "Version Not Supported";
1272:                        break;
1273:                    case 507:
1274:                        result = "Insufficient Storage";
1275:                        break;
1276:
1277:                    case 1000:
1278:                        result = "Connection Error";
1279:                        break;
1280:                    case 1001:
1281:                        result = "Communication Error";
1282:                        break;
1283:                    case 1002:
1284:                        result = "Internal Connector Error";
1285:                        break;
1286:                    }
1287:                }
1288:
1289:                return result;
1290:            }
1291:
1292:            /**
1293:             * Returns the URI of the specification describing the status.
1294:             * 
1295:             * @return The URI of the specification describing the status.
1296:             */
1297:            public String getUri() {
1298:                String result = this .uri;
1299:
1300:                if (result == null) {
1301:                    switch (this .code) {
1302:                    case 100:
1303:                        result = BASE_HTTP + "#sec10.1.1";
1304:                        break;
1305:                    case 101:
1306:                        result = BASE_HTTP + "#sec10.1.2";
1307:                        break;
1308:                    case 102:
1309:                        result = BASE_WEBDAV + "#STATUS_102";
1310:                        break;
1311:
1312:                    case 200:
1313:                        result = BASE_HTTP + "#sec10.2.1";
1314:                        break;
1315:                    case 201:
1316:                        result = BASE_HTTP + "#sec10.2.2";
1317:                        break;
1318:                    case 202:
1319:                        result = BASE_HTTP + "#sec10.2.3";
1320:                        break;
1321:                    case 203:
1322:                        result = BASE_HTTP + "#sec10.2.4";
1323:                        break;
1324:                    case 204:
1325:                        result = BASE_HTTP + "#sec10.2.5";
1326:                        break;
1327:                    case 205:
1328:                        result = BASE_HTTP + "#sec10.2.6";
1329:                        break;
1330:                    case 206:
1331:                        result = BASE_HTTP + "#sec10.2.7";
1332:                        break;
1333:                    case 207:
1334:                        result = BASE_WEBDAV + "#STATUS_207";
1335:                        break;
1336:
1337:                    case 300:
1338:                        result = BASE_HTTP + "#sec10.3.1";
1339:                        break;
1340:                    case 301:
1341:                        result = BASE_HTTP + "#sec10.3.2";
1342:                        break;
1343:                    case 302:
1344:                        result = BASE_HTTP + "#sec10.3.3";
1345:                        break;
1346:                    case 303:
1347:                        result = BASE_HTTP + "#sec10.3.4";
1348:                        break;
1349:                    case 304:
1350:                        result = BASE_HTTP + "#sec10.3.5";
1351:                        break;
1352:                    case 305:
1353:                        result = BASE_HTTP + "#sec10.3.6";
1354:                        break;
1355:                    case 307:
1356:                        result = BASE_HTTP + "#sec10.3.8";
1357:                        break;
1358:
1359:                    case 400:
1360:                        result = BASE_HTTP + "#sec10.4.1";
1361:                        break;
1362:                    case 401:
1363:                        result = BASE_HTTP + "#sec10.4.2";
1364:                        break;
1365:                    case 402:
1366:                        result = BASE_HTTP + "#sec10.4.3";
1367:                        break;
1368:                    case 403:
1369:                        result = BASE_HTTP + "#sec10.4.4";
1370:                        break;
1371:                    case 404:
1372:                        result = BASE_HTTP + "#sec10.4.5";
1373:                        break;
1374:                    case 405:
1375:                        result = BASE_HTTP + "#sec10.4.6";
1376:                        break;
1377:                    case 406:
1378:                        result = BASE_HTTP + "#sec10.4.7";
1379:                        break;
1380:                    case 407:
1381:                        result = BASE_HTTP + "#sec10.4.8";
1382:                        break;
1383:                    case 408:
1384:                        result = BASE_HTTP + "#sec10.4.9";
1385:                        break;
1386:                    case 409:
1387:                        result = BASE_HTTP + "#sec10.4.10";
1388:                        break;
1389:                    case 410:
1390:                        result = BASE_HTTP + "#sec10.4.11";
1391:                        break;
1392:                    case 411:
1393:                        result = BASE_HTTP + "#sec10.4.12";
1394:                        break;
1395:                    case 412:
1396:                        result = BASE_HTTP + "#sec10.4.13";
1397:                        break;
1398:                    case 413:
1399:                        result = BASE_HTTP + "#sec10.4.14";
1400:                        break;
1401:                    case 414:
1402:                        result = BASE_HTTP + "#sec10.4.15";
1403:                        break;
1404:                    case 415:
1405:                        result = BASE_HTTP + "#sec10.4.16";
1406:                        break;
1407:                    case 416:
1408:                        result = BASE_HTTP + "#sec10.4.17";
1409:                        break;
1410:                    case 417:
1411:                        result = BASE_HTTP + "#sec10.4.18";
1412:                        break;
1413:                    case 422:
1414:                        result = BASE_WEBDAV + "#STATUS_422";
1415:                        break;
1416:                    case 423:
1417:                        result = BASE_WEBDAV + "#STATUS_423";
1418:                        break;
1419:                    case 424:
1420:                        result = BASE_WEBDAV + "#STATUS_424";
1421:                        break;
1422:
1423:                    case 500:
1424:                        result = BASE_HTTP + "#sec10.5.1";
1425:                        break;
1426:                    case 501:
1427:                        result = BASE_HTTP + "#sec10.5.2";
1428:                        break;
1429:                    case 502:
1430:                        result = BASE_HTTP + "#sec10.5.3";
1431:                        break;
1432:                    case 503:
1433:                        result = BASE_HTTP + "#sec10.5.4";
1434:                        break;
1435:                    case 504:
1436:                        result = BASE_HTTP + "#sec10.5.5";
1437:                        break;
1438:                    case 505:
1439:                        result = BASE_HTTP + "#sec10.5.6";
1440:                        break;
1441:                    case 507:
1442:                        result = BASE_WEBDAV + "#STATUS_507";
1443:                        break;
1444:
1445:                    case 1000:
1446:                        result = BASE_RESTLET
1447:                                + "org/restlet/data/Status.html#CONNECTOR_ERROR_CONNECTION";
1448:                        break;
1449:                    case 1001:
1450:                        result = BASE_RESTLET
1451:                                + "org/restlet/data/Status.html#CONNECTOR_ERROR_COMMUNICATION";
1452:                        break;
1453:                    case 1002:
1454:                        result = BASE_RESTLET
1455:                                + "org/restlet/data/Status.html#CONNECTOR_ERROR_INTERNAL";
1456:                        break;
1457:                    }
1458:                }
1459:
1460:                return result;
1461:            }
1462:
1463:            /** {@inheritDoc} */
1464:            @Override
1465:            public int hashCode() {
1466:                return getCode();
1467:            }
1468:
1469:            /**
1470:             * Indicates if the status is a client error status.
1471:             * 
1472:             * @return True if the status is a client error status.
1473:             */
1474:            public boolean isClientError() {
1475:                return isClientError(getCode());
1476:            }
1477:
1478:            /**
1479:             * Indicates if the status is a connector error status.
1480:             * 
1481:             * @return True if the status is a connector error status.
1482:             */
1483:            public boolean isConnectorError() {
1484:                return isConnectorError(getCode());
1485:            }
1486:
1487:            /**
1488:             * Indicates if the status is an error (client or server) status.
1489:             * 
1490:             * @return True if the status is an error (client or server) status.
1491:             */
1492:            public boolean isError() {
1493:                return isError(getCode());
1494:            }
1495:
1496:            /**
1497:             * Indicates if the status is an information status.
1498:             * 
1499:             * @return True if the status is an information status.
1500:             */
1501:            public boolean isInfo() {
1502:                return isInfo(getCode());
1503:            }
1504:
1505:            /**
1506:             * Indicates if the status is a redirection status.
1507:             * 
1508:             * @return True if the status is a redirection status.
1509:             */
1510:            public boolean isRedirection() {
1511:                return isRedirection(getCode());
1512:            }
1513:
1514:            /**
1515:             * Indicates if the status is a server error status.
1516:             * 
1517:             * @return True if the status is a server error status.
1518:             */
1519:            public boolean isServerError() {
1520:                return isServerError(getCode());
1521:            }
1522:
1523:            /**
1524:             * Indicates if the status is a success status.
1525:             * 
1526:             * @return True if the status is a success status.
1527:             */
1528:            public boolean isSuccess() {
1529:                return isSuccess(getCode());
1530:            }
1531:
1532:            /**
1533:             * Returns the name of the status followed by its HTTP code.
1534:             * 
1535:             * @return The name of the status followed by its HTTP code.
1536:             */
1537:            public String toString() {
1538:                return getName() + " (" + this .code + ")";
1539:            }
1540:
1541:            /**
1542:             * Check if the provided description of the status contains forbidden
1543:             * characters such as CR and LF. an IllegalArgumentException is thrown in
1544:             * this case.
1545:             * 
1546:             * @see <a
1547:             *      href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1">Status
1548:             *      Code and Reason Phrase</a>
1549:             * @param description
1550:             *                the description to check
1551:             * @return the description if it is correct.
1552:             */
1553:            private static String checkDescription(String description) {
1554:                if (description != null) {
1555:                    if (description.contains("\n")
1556:                            && description.contains("\r")) {
1557:                        throw new IllegalArgumentException(
1558:                                "Description of the status must not contain CR and LF characters.");
1559:                    }
1560:                }
1561:
1562:                return description;
1563:            }
1564:
1565:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.