![]() |
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 00030 public class HAlert implements HJsonObj{ 00031 00032 private JSONObject halert = new JSONObject(); 00033 00034 public HAlert() {}; 00035 00036 public HAlert(JSONObject jsonObj){ 00037 fromJSON(jsonObj); 00038 } 00039 00040 /* HJsonObj interface */ 00041 00042 public JSONObject toJSON() { 00043 return halert; 00044 } 00045 00046 public void fromJSON(JSONObject jsonObj) { 00047 if(jsonObj != null) { 00048 this.halert = jsonObj; 00049 } else { 00050 this.halert = new JSONObject(); 00051 } 00052 } 00053 00054 public String getHType() { 00055 return "halert"; 00056 } 00057 00058 @Override 00059 public String toString() { 00060 return halert.toString(); 00061 } 00062 00063 @Override 00064 public boolean equals(Object obj) { 00065 return halert.equals(obj); 00066 } 00067 00068 @Override 00069 public int hashCode() { 00070 return halert.hashCode(); 00071 } 00072 00073 /* Getters & Setters */ 00074 00079 public String getAlert() { 00080 String alert; 00081 try { 00082 alert = halert.getString("alert"); 00083 } catch (Exception e) { 00084 alert = null; 00085 } 00086 return alert; 00087 } 00088 00089 public void setAlert(String alert) { 00090 try { 00091 if(alert == null) { 00092 halert.remove("alert"); 00093 } else { 00094 halert.put("alert", alert); 00095 } 00096 } catch (JSONException e) { 00097 } 00098 } 00099 }