◆ getResponse() [1/2]
static String org.turro.http.ElephantResponse.getResponse |
( |
ElephantResponseType |
type, |
|
|
String |
message, |
|
|
String |
code |
|
) |
| throws IOException |
|
static |
Definition at line 71 of file ElephantResponse.java.
72 Gson gson =
new GsonBuilder().create();
73 ElephantResponse er =
new ElephantResponse();
74 er.type =
type.toString();
77 return gson.toJson(er);
◆ getResponse() [2/2]
static ElephantResponse org.turro.http.ElephantResponse.getResponse |
( |
HttpEntity |
entity | ) |
throws IOException |
|
static |
Definition at line 58 of file ElephantResponse.java.
59 Gson gson =
new GsonBuilder().create();
60 ContentType contentType = ContentType.create(entity.getContentType(), Charsets.toCharset(entity.getContentEncoding()));
61 Charset charset = contentType.getCharset();
62 Reader reader =
new InputStreamReader(entity.getContent(), charset);
64 return gson.fromJson(reader, ElephantResponse.class);
65 }
catch(JsonSyntaxException ex) {
66 Logger.getLogger(ElephantResponse.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
◆ getType()
Definition at line 50 of file ElephantResponse.java.
52 return er !=
null ? ElephantResponseType.valueOf(er.type) :
null;
53 }
catch(IllegalArgumentException |NullPointerException ex) {
◆ isCorrect()
Definition at line 46 of file ElephantResponse.java.
47 return ElephantResponseType.RESPONSE_CORRECT.equals(ElephantResponse.getType(er));
◆ writeToResponse()
static void org.turro.http.ElephantResponse.writeToResponse |
( |
HttpServletResponse |
response, |
|
|
ElephantResponseType |
type, |
|
|
String |
message, |
|
|
String |
code |
|
) |
| throws IOException |
|
static |
Definition at line 80 of file ElephantResponse.java.
81 response.setContentType(
"application/json");
82 response.setCharacterEncoding(ElephantContext.getEncoding());
static ElephantResponse getResponse(HttpEntity entity)
◆ code
String org.turro.http.ElephantResponse.code |
◆ message
String org.turro.http.ElephantResponse.message |
◆ type
String org.turro.http.ElephantResponse.type |
The documentation for this class was generated from the following file: