优化解析XML遇到无法识别的节点的兼容

pull/1669/head
648540858 2024-10-29 15:06:08 +08:00
parent ace7b78498
commit caf9e99939
1 changed files with 19 additions and 14 deletions

View File

@ -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;
}
}