/src/com/wqdsoft/im/Entity/MapInfo.java

https://gitlab.com/Er_Hei/PlayCar · Java · 107 lines · 88 code · 19 blank · 0 comment · 8 complexity · 481ac2a1c682378ddd9b1bfd10257e17 MD5 · raw file

  1. package com.wqdsoft.im.Entity;
  2. import java.io.Serializable;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.wqdsoft.im.org.json.JSONException;
  5. public class MapInfo implements Serializable{
  6. private static final long serialVersionUID = -1153484834874L;
  7. private String city;
  8. private String addr;
  9. private String lat;
  10. private String lng;
  11. public MapInfo(String city, String addr, String lat, String lng) {
  12. super();
  13. this.city = city;
  14. this.addr = addr;
  15. this.lat = lat;
  16. this.lng = lng;
  17. }
  18. public MapInfo() {
  19. super();
  20. }
  21. public static MapInfo getInfo(String json) {
  22. try {
  23. return JSONObject.toJavaObject(JSONObject.parseObject(json),
  24. MapInfo.class);
  25. } catch (Exception e) {
  26. e.printStackTrace();
  27. return null;
  28. }
  29. }
  30. public MapInfo(String reqString) {
  31. super();
  32. if(reqString == null || reqString.equals("")){
  33. return;
  34. }
  35. try {
  36. com.wqdsoft.im.org.json.JSONObject json = new com.wqdsoft.im.org.json.JSONObject(reqString);
  37. if(json!=null ){
  38. if(!json.isNull("lng")){
  39. this.lng = json.getString("lng");
  40. }
  41. if(!json.isNull("lat")){
  42. this.lat = json.getString("lat");
  43. }
  44. if(!json.isNull("addr")){
  45. this.addr = json.getString("addr");
  46. }
  47. if(!json.isNull("city")){
  48. this.city = json.getString("city");
  49. }
  50. }
  51. } catch (JSONException e) {
  52. e.printStackTrace();
  53. }
  54. }
  55. public static String getInfo(MapInfo info) {
  56. String json = JSONObject.toJSON(info).toString();
  57. return json;
  58. }
  59. public String getCtiy() {
  60. return city;
  61. }
  62. public String getAddr() {
  63. return addr;
  64. }
  65. public String getLat() {
  66. return lat;
  67. }
  68. public String getLng() {
  69. return lng;
  70. }
  71. public void setCtiy(String ctiy) {
  72. this.city = ctiy;
  73. }
  74. public void setAddr(String addr) {
  75. this.addr = addr;
  76. }
  77. public void setLat(String lat) {
  78. this.lat = lat;
  79. }
  80. public void setLon(String lng) {
  81. this.lng = lng;
  82. }
  83. @Override
  84. public String toString() {
  85. return "MapInfo [city=" + city + ", addr=" + addr + ", lat=" + lat
  86. + ", lng=" + lng + "]";
  87. }
  88. }