Commit d8b24fc7950cf0ae31e6db41bfd1d698e0fdeecc

Authored by 648540858
1 parent 5bf87ca3

XmlUtil添加直接获取Double和Integer的方法

src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
... ... @@ -78,6 +78,50 @@ public class XmlUtil {
78 78 }
79 79  
80 80 /**
  81 + * 获取element对象的text的值
  82 + *
  83 + * @param em 节点的对象
  84 + * @param tag 节点的tag
  85 + * @return 节点
  86 + */
  87 + public static Double getDouble(Element em, String tag) {
  88 + if (null == em) {
  89 + return null;
  90 + }
  91 + Element e = em.element(tag);
  92 + if (null == e) {
  93 + return null;
  94 + }
  95 + String text = e.getText().trim();
  96 + if (ObjectUtils.isEmpty(text) || !NumberUtils.isParsable(text)) {
  97 + return null;
  98 + }
  99 + return Double.parseDouble(text);
  100 + }
  101 +
  102 + /**
  103 + * 获取element对象的text的值
  104 + *
  105 + * @param em 节点的对象
  106 + * @param tag 节点的tag
  107 + * @return 节点
  108 + */
  109 + public static Integer getInteger(Element em, String tag) {
  110 + if (null == em) {
  111 + return null;
  112 + }
  113 + Element e = em.element(tag);
  114 + if (null == e) {
  115 + return null;
  116 + }
  117 + String text = e.getText().trim();
  118 + if (ObjectUtils.isEmpty(text) || !NumberUtils.isParsable(text)) {
  119 + return null;
  120 + }
  121 + return Integer.parseInt(text);
  122 + }
  123 +
  124 + /**
81 125 * 递归解析xml节点,适用于 多节点数据
82 126 *
83 127 * @param node node
... ...