]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/gss-lib-2.2/src/com/pras/conn/Response.java
Added gss-lib-2.2.
[Dictionary.git] / jars / gss-lib-2.2 / src / com / pras / conn / Response.java
1 /*\r
2  * Copyright (C) 2010 Prasanta Paul, http://prasanta-paul.blogspot.com\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package com.pras.conn;\r
18 \r
19 import com.pras.Log;\r
20 \r
21 /**\r
22  * Wrapper class to hold Response from Server, Connection Exception etc.\r
23  * \r
24  * @author rasanta\r
25  *\r
26  */\r
27 public class Response {\r
28 \r
29         String TAG = "HTTP_Response";\r
30         \r
31         boolean error = false;\r
32         String responseCode;\r
33         String responseMessage;\r
34         String errorStreamMsg;\r
35         String output;\r
36         Exception exception;\r
37         \r
38         \r
39         public boolean isError() {\r
40                 return error;\r
41         }\r
42         public void setError(boolean error) {\r
43                 this.error = error;\r
44         }\r
45         public String getResponseCode() {\r
46                 return responseCode;\r
47         }\r
48         public void setResponseCode(String responseCode) {\r
49                 this.responseCode = responseCode;\r
50                 \r
51                 /*\r
52                  * Response Codes-\r
53                  * 1xx: Informational\r
54                  * 2xx: Success\r
55                  * 3xx: Redirection\r
56                  * 4xx: Client Error\r
57                  * 5xx: Server Error\r
58                  */\r
59            \r
60                 if(this.responseCode.startsWith("2"))\r
61                         error = false;\r
62                 else\r
63                         error = true;\r
64         }\r
65         public String getResponseMessage() {\r
66                 return responseMessage;\r
67         }\r
68         public void setResponseMessage(String responseMessage) {\r
69                 this.responseMessage = responseMessage;\r
70         }\r
71         public String getErrorStreamMsg() {\r
72                 return errorStreamMsg;\r
73         }\r
74         public void setErrorStreamMsg(String errorStreamMsg) {\r
75                 this.errorStreamMsg = errorStreamMsg;\r
76         }\r
77         public String getOutput() {\r
78                 return output;\r
79         }\r
80         public void setOutput(String output) {\r
81                 this.output = output;\r
82         }\r
83         public Exception getException() {\r
84                 return exception;\r
85         }\r
86         public void setException(Exception exception) {\r
87                 this.exception = exception;\r
88         }\r
89         \r
90         public void printErrorLog(){\r
91                 Log.p(TAG, "HTTP Response Code: "+ getResponseCode());\r
92                 Log.p(TAG, "HTTP Response: "+ getResponseMessage());\r
93                 Log.p(TAG, "Error Msg from Server: "+ getErrorStreamMsg());\r
94                 if(exception != null){\r
95                         Log.p(TAG, "Error in Connection: "+ exception.getMessage());\r
96                         exception.printStackTrace();\r
97                 }\r
98         }\r
99 }\r