]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/java/org/opensrf/Result.java
added shutdown call to cleanly disconnect from the opensrf network
[OpenSRF.git] / src / java / org / opensrf / Result.java
1 package org.opensrf;
2 import org.opensrf.util.*;
3
4
5 /**
6  * Models a single result from a method request.
7  */
8 public class Result implements OSRFSerializable {
9
10     /** Method result content */
11     private Object content;
12     /** Name of the status */
13     private String status;
14     /** Status code number */
15     private int statusCode;
16
17
18     /** Register this object */
19     private static OSRFRegistry registry = 
20         OSRFRegistry.registerObject(
21             "osrfResult", 
22             OSRFRegistry.WireProtocol.HASH, 
23             new String[] {"status", "statusCode", "content"});
24
25
26     /**
27      * @param status The status message for this result
28      * @param statusCode The status code
29      * @param content The content of the result
30      */
31     public Result(String status, int statusCode, Object content) {
32         this.status = status;
33         this.statusCode = statusCode;
34         this.content = content;
35     }
36     
37     /**
38      * Get status.
39      * @return status as String.
40      */
41     public String getStatus() {
42         return status;
43     }
44     
45     /**
46      * Set status.
47      * @param status the value to set.
48      */
49     public void setStatus(String status) {
50         this.status = status;
51     }
52     
53     /**
54      * Get statusCode.
55      * @return statusCode as int.
56      */
57     public int getStatusCode() {
58         return statusCode;
59     }
60     
61     /**
62      * Set statusCode.
63      * @param statusCode the value to set.
64      */
65     public void setStatusCode(int statusCode) {
66         this.statusCode = statusCode;
67     }
68     
69     /**
70      * Get content.
71      * @return content as Object.
72      */
73     public Object getContent() {
74         return content;
75     }
76     
77     /**
78      * Set content.
79      * @param content the value to set.
80      */
81     public void setContent(Object content) {
82         this.content = content;
83     }
84
85     /**
86      * Implements the generic get() API required by OSRFSerializable
87      */
88     public Object get(String field) {
89         if("status".equals(field))
90             return getStatus();
91         if("statusCode".equals(field))
92             return getStatusCode();
93         if("content".equals(field))
94             return getContent();
95         return null;
96     }
97
98     /**
99      * @return The osrfMethod registry.
100      */
101     public OSRFRegistry getRegistry() {
102         return registry;
103     }
104
105 }
106