Newer
Older
task-bldg / src / main / java / osm / surveyor / task / util / JsonProperties.java
  1. package osm.surveyor.task.util;
  2.  
  3. import java.util.Hashtable;
  4.  
  5. import com.fasterxml.jackson.databind.JsonNode;
  6.  
  7. import lombok.Getter;
  8. import lombok.Setter;
  9.  
  10. @Getter
  11. @Setter
  12. public class JsonProperties extends JsonTemple {
  13. /*
  14. * "properties":{
  15. * "id":"64412288"
  16. * }
  17. */
  18. private String name;
  19. private String path;
  20. private String id;
  21. private String version;
  22. private String surveyYear;
  23. private Long prefcode;
  24. private String prefname;
  25. private Long citycode;
  26. private String cityname;
  27. private Long meshcode;
  28. public Hashtable<String,Object> items = new Hashtable<>();
  29. public String toString() {
  30. StringBuffer sb = new StringBuffer();
  31. boolean c1 = false;
  32. sb.append("{");
  33. c1 = outStr(c1, sb, "name", this.name);
  34. c1 = outStr(c1, sb, "path", this.path);
  35. c1 = outStr(c1, sb, "id", this.id);
  36. c1 = outStr(c1, sb, "version", this.version);
  37. c1 = outStr(c1, sb, "surveyYear", this.surveyYear);
  38. c1 = out(c1, sb, "prefcode", getPrefcode());
  39. c1 = outStr(c1, sb, "prefname", getPrefname());
  40. sb.append("}");
  41. return sb.toString();
  42. }
  43. public void parse(JsonNode node) {
  44. JsonNode node1 = node.get("name");
  45. if (node1 != null) {
  46. this.name = node1.textValue();
  47. }
  48. node1 = node.get("path");
  49. if (node1 != null) {
  50. this.path = node1.textValue();
  51. }
  52. node1 = node.get("id");
  53. if (node1 != null) {
  54. this.id = node1.textValue();
  55. }
  56.  
  57. node1 = node.get("version");
  58. if (node1 != null) {
  59. this.version = node1.textValue();
  60. }
  61.  
  62. node1 = node.get("surveyYear");
  63. if (node1 != null) {
  64. this.surveyYear = node1.textValue();
  65. }
  66.  
  67. node1 = node.get("prefcode");
  68. if (node1 != null) {
  69. setPrefcode(node1.longValue());
  70. }
  71.  
  72. node1 = node.get("prefname");
  73. if (node1 != null) {
  74. setPrefname(node1.textValue());
  75. }
  76. }
  77. }