![]() |
Hubiquitus Android
0.3
Android client for hubiquitus protocol
|
00001 /* 00002 * Copyright (c) Novedia Group 2012. 00003 * 00004 * This file is part of Hubiquitus. 00005 * 00006 * Hubiquitus is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * Hubiquitus is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with Hubiquitus. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 package org.hubiquitus.hapi.hStructures; 00021 00022 import org.json.JSONException; 00023 import org.json.JSONObject; 00024 00031 public class HConvState implements HJsonObj{ 00032 00033 private JSONObject hconvstate = new JSONObject(); 00034 00035 public HConvState() {}; 00036 00037 public HConvState(JSONObject jsonObj){ 00038 fromJSON(jsonObj); 00039 } 00040 00041 /* HJsonObj interface */ 00042 00043 public JSONObject toJSON() { 00044 return hconvstate; 00045 } 00046 00047 public void fromJSON(JSONObject jsonObj) { 00048 if(jsonObj != null) { 00049 this.hconvstate = jsonObj; 00050 } else { 00051 this.hconvstate = new JSONObject(); 00052 } 00053 } 00054 00055 public String getHType() { 00056 return "hconv"; 00057 } 00058 00059 @Override 00060 public String toString() { 00061 return hconvstate.toString(); 00062 } 00063 00069 public boolean equals(HConvState obj) { 00070 if(obj.getStatus() != this.getStatus()) { 00071 return false; 00072 } 00073 return true; 00074 } 00075 00076 @Override 00077 public int hashCode() { 00078 return hconvstate.hashCode(); 00079 } 00080 00081 /* Getters & Setters */ 00082 00087 public String getStatus() { 00088 String status; 00089 try { 00090 status = hconvstate.getString("status"); 00091 } catch (Exception e) { 00092 status = null; 00093 } 00094 return status; 00095 } 00096 00097 public void setStatus(String status) { 00098 try { 00099 if(status == null) { 00100 hconvstate.remove("status"); 00101 } else { 00102 hconvstate.put("status", status); 00103 } 00104 } catch (JSONException e) { 00105 } 00106 } 00107 00108 } 00109