com.jelastic.api.environment.response.FileReadResponse Maven / Gradle / Ivy
The newest version!
/*Server class MD5: 496a7c4d5da22c93f4fabb3145e063b2*/
package com.jelastic.api.environment.response;
import com.jelastic.api.Response;
import org.json.JSONException;
import org.json.JSONObject;
/**
* @name Jelastic API Client
* @version 8.11.2
* @copyright Jelastic, Inc.
*/
public class FileReadResponse extends Response {
private String body;
public FileReadResponse(String body) {
super(Response.OK);
this.body = body;
}
public FileReadResponse(int result, String error) {
super(result, error);
}
public FileReadResponse() {
super(Response.OK);
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
@Override
public FileReadResponse fromJSON(JSONObject json) {
Response response = super.fromJSON(json);
try {
if (json.has("body")) {
body = json.getString("body");
}
} catch (JSONException ex) {
response = new Response(ERROR_UNKNOWN, ex.toString());
}
setResult(response.getResult());
setError(response.getError());
return this;
}
@Override
public JSONObject toJSON() {
JSONObject json = super.toJSON();
try {
if (body != null) {
json.put("body", body);
}
} catch (Exception ex) {
ex.printStackTrace();
try {
json.put("result", Response.ERROR_UNKNOWN).put("error", ex.toString());
} catch (JSONException exc) {
}
}
return json;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy