From caf9e999392c397e99312552fce72cc3693eed07 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 29 Oct 2024 15:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=A3=E6=9E=90XML?= =?UTF-8?q?=E9=81=87=E5=88=B0=E6=97=A0=E6=B3=95=E8=AF=86=E5=88=AB=E7=9A=84?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=9A=84=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/utils/XmlUtil.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java index 98c8dadb..4656670f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java @@ -706,21 +706,26 @@ public class XmlUtil { * @return */ private static Object simpleTypeDeal(Class tClass, Object val) { - if (val == null || val.toString().equalsIgnoreCase("null")) { + try { + if (val == null || val.toString().equalsIgnoreCase("null")) { + return null; + } + if (tClass.equals(String.class)) { + return val.toString(); + } + if (tClass.equals(Integer.class)) { + return Integer.valueOf(val.toString()); + } + if (tClass.equals(Double.class)) { + return Double.valueOf(val.toString()); + + } + if (tClass.equals(Long.class)) { + return Long.valueOf(val.toString()); + } + return val; + }catch (Exception e) { return null; } - if (tClass.equals(String.class)) { - return val.toString(); - } - if (tClass.equals(Integer.class)) { - return Integer.valueOf(val.toString()); - } - if (tClass.equals(Double.class)) { - return Double.valueOf(val.toString()); - } - if (tClass.equals(Long.class)) { - return Long.valueOf(val.toString()); - } - return val; } } \ No newline at end of file