implemented client bootstrap. created a status object to model connection statuses...
[OpenSRF.git] / src / java / org / opensrf / Status.java
1 package org.opensrf;
2 import org.opensrf.util.*;
3
4 public class Status {
5
6     public static final int CONTINUE            = 100;
7     public static final int OK                  = 200;
8     public static final int ACCEPTED            = 202;
9     public static final int COMPLETE            = 205;
10     public static final int REDIRECTED          = 307;
11     public static final int EST                 = 400;
12     public static final int STATUS_UNAUTHORIZED = 401;
13     public static final int FORBIDDEN           = 403;
14     public static final int NOTFOUND            = 404;
15     public static final int NOTALLOWED          = 405;
16     public static final int TIMEOUT             = 408;
17     public static final int EXPFAILED           = 417;
18     public static final int INTERNALSERVERERROR = 500;
19     public static final int NOTIMPLEMENTED      = 501;
20     public static final int VERSIONNOTSUPPORTED = 505;
21
22     private OSRFRegistry registry = OSRFRegistry.registerObject(
23         "osrfConnectStatus",
24         OSRFRegistry.WireProtocol.HASH,
25         new String[] {"status", "statusCode"});
26
27     /** The name of the status */
28     String status;
29     /** The status code */
30     int statusCode;
31
32     public Status(String status, int statusCode) {
33         this.status = status;
34         this.statusCode = statusCode;
35     }
36
37     public int getStatusCode() {
38         return statusCode;
39     }
40     public String getStatus() {
41         return status;
42     }
43
44     /**
45      * Implements the generic get() API required by OSRFSerializable
46      */
47     public Object get(String field) {
48         if("status".equals(field))
49             return getStatus();
50         if("statusCode".equals(field))
51             return new Integer(getStatusCode());
52         return null;
53     }
54
55     /**
56      * @return The osrfMessage registry.
57      */
58     public OSRFRegistry getRegistry() {
59         return registry;
60     }
61 }
62
63