Back to project page Common-Library.
The source code is released under:
Apache License
If you think the Android project Common-Library listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.morgan.library.model; /* w w w . j av a 2 s . co m*/ import org.json.JSONException; import org.json.JSONObject; import com.morgan.library.net.JsonUtils; import com.morgan.library.utils.HttpClientUtils; /** * ????????json??????????????????????????????????????????????VO????????? * * @author Morgan.Ji * * @param <T>?????????VO */ public class NetResult<T> { public static final int SUCCESS_CODE = 200; /** * ???????? */ private int mStatusCode; /** * ????????? */ private String mErrorMessage; /** * ??????? */ private String mResponseMessage; private T mObject; public NetResult(String vo) { if (HttpClientUtils.SERVER_CONNECT_ERROR.equals(vo)) { try { JSONObject jsonObject = new JSONObject(vo); this.mStatusCode = jsonObject.getInt("code"); this.mErrorMessage = jsonObject.optString("message"); } catch (JSONException e) { this.mStatusCode = JsonUtils.JSON_PARSE_ERROR_CODE; this.mErrorMessage = JsonUtils.JSON_PARSE_ERROR_MESSAGE; } } else { this.mResponseMessage = vo; } } public boolean isSuccess() { return mStatusCode == SUCCESS_CODE; } public void setStatusCode(int statusCode) { this.mStatusCode = statusCode; } public String getErrorMessage() { return mErrorMessage; } public void setErrorMessage(String errorMessage) { this.mErrorMessage = errorMessage; } public String getResponseMessage() { return mResponseMessage; } public T getObject() { return mObject; } public void setObject(T mObject) { this.mObject = mObject; } }