mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix comment
This commit is contained in:
parent
fc61fc9fe0
commit
61c80b0957
@ -21,10 +21,8 @@ import java.nio.charset.Charset;
|
||||
* <li>https://my.oschina.net/u/4266515/blog/3330113</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see XmlUtil
|
||||
* //@see JSONUtil
|
||||
*
|
||||
* @author dazer
|
||||
* @see XmlUtil
|
||||
* @since 5.7.3
|
||||
*/
|
||||
public class JAXBUtil {
|
||||
|
@ -61,9 +61,8 @@ import java.util.Map;
|
||||
* 此工具使用w3c dom工具,不需要依赖第三方包。<br>
|
||||
* 工具类封装了XML文档的创建、读取、写出和部分XML操作
|
||||
*
|
||||
* @see JAXBUtil bean<==> xml互转,请用该JAXBUtil, XmlUtil只转换了最外层;
|
||||
*
|
||||
* @author xiaoleilu
|
||||
* @see JAXBUtil
|
||||
*/
|
||||
public class XmlUtil {
|
||||
|
||||
@ -235,13 +234,13 @@ public class XmlUtil {
|
||||
* 使用Sax方式读取指定的XML<br>
|
||||
* 如果用户传入的contentHandler为{@link DefaultHandler},则其接口都会被处理
|
||||
*
|
||||
* @param file XML源文件,使用后自动关闭
|
||||
* @param file XML源文件,使用后自动关闭
|
||||
* @param contentHandler XML流处理器,用于按照Element处理xml
|
||||
* @since 5.4.4
|
||||
*/
|
||||
public static void readBySax(File file, ContentHandler contentHandler) {
|
||||
InputStream in = null;
|
||||
try{
|
||||
try {
|
||||
in = FileUtil.getInputStream(file);
|
||||
readBySax(new InputSource(in), contentHandler);
|
||||
} finally {
|
||||
@ -258,7 +257,7 @@ public class XmlUtil {
|
||||
* @since 5.4.4
|
||||
*/
|
||||
public static void readBySax(Reader reader, ContentHandler contentHandler) {
|
||||
try{
|
||||
try {
|
||||
readBySax(new InputSource(reader), contentHandler);
|
||||
} finally {
|
||||
IoUtil.close(reader);
|
||||
@ -274,7 +273,7 @@ public class XmlUtil {
|
||||
* @since 5.4.4
|
||||
*/
|
||||
public static void readBySax(InputStream source, ContentHandler contentHandler) {
|
||||
try{
|
||||
try {
|
||||
readBySax(new InputSource(source), contentHandler);
|
||||
} finally {
|
||||
IoUtil.close(source);
|
||||
@ -399,7 +398,7 @@ public class XmlUtil {
|
||||
* @return XML字符串
|
||||
*/
|
||||
public static String toStr(Document doc) {
|
||||
return toStr((Node)doc);
|
||||
return toStr((Node) doc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -425,7 +424,7 @@ public class XmlUtil {
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static String toStr(Document doc, boolean isPretty) {
|
||||
return toStr((Node)doc, isPretty);
|
||||
return toStr((Node) doc, isPretty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -453,7 +452,7 @@ public class XmlUtil {
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static String toStr(Document doc, String charset, boolean isPretty) {
|
||||
return toStr((Node)doc, charset, isPretty);
|
||||
return toStr((Node) doc, charset, isPretty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1017,19 +1016,18 @@ public class XmlUtil {
|
||||
/**
|
||||
* XML转Java Bean
|
||||
*
|
||||
* @see JAXBUtil#xmlToBean(String, Class) 可以解析多层xml;
|
||||
*
|
||||
* @param <T> bean类型
|
||||
* @param node XML节点
|
||||
* @param bean bean类
|
||||
* @return bean
|
||||
* @see JAXBUtil#xmlToBean(String, Class)
|
||||
* @since 5.2.4
|
||||
*/
|
||||
public static <T> T xmlToBean(Node node, Class<T> bean) {
|
||||
final Map<String, Object> map = xmlToMap(node);
|
||||
if (null != map && map.size() == 1) {
|
||||
final String simpleName = bean.getSimpleName();
|
||||
if(map.containsKey(simpleName)){
|
||||
if (map.containsKey(simpleName)) {
|
||||
// 只有key和bean的名称匹配时才做单一对象转换
|
||||
return BeanUtil.toBean(map.get(simpleName), bean);
|
||||
}
|
||||
@ -1122,10 +1120,9 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML格式的字符串
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
*
|
||||
* @param data Map类型数据
|
||||
* @return XML格式的字符串
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public static String mapToXmlStr(Map<?, ?> data) {
|
||||
@ -1135,11 +1132,10 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML格式的字符串
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
*
|
||||
* @param data Map类型数据
|
||||
* @param omitXmlDeclaration 是否输出 xml Declaration
|
||||
* @return XML格式的字符串
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public static String mapToXmlStr(Map<?, ?> data, boolean omitXmlDeclaration) {
|
||||
@ -1149,11 +1145,10 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML格式的字符串
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
*
|
||||
* @param data Map类型数据
|
||||
* @param rootName 根节点名
|
||||
* @return XML格式的字符串
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 4.0.8
|
||||
*/
|
||||
public static String mapToXmlStr(Map<?, ?> data, String rootName) {
|
||||
@ -1163,12 +1158,11 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML格式的字符串
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
*
|
||||
* @param data Map类型数据
|
||||
* @param rootName 根节点名
|
||||
* @param namespace 命名空间,可以为null
|
||||
* @return XML格式的字符串
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public static String mapToXmlStr(Map<?, ?> data, String rootName, String namespace) {
|
||||
@ -1178,13 +1172,12 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML格式的字符串
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
*
|
||||
* @param data Map类型数据
|
||||
* @param rootName 根节点名
|
||||
* @param namespace 命名空间,可以为null
|
||||
* @param omitXmlDeclaration 是否输出 xml Declaration
|
||||
* @return XML格式的字符串
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public static String mapToXmlStr(Map<?, ?> data, String rootName, String namespace, boolean omitXmlDeclaration) {
|
||||
@ -1194,14 +1187,13 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML格式的字符串
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
*
|
||||
* @param data Map类型数据
|
||||
* @param rootName 根节点名
|
||||
* @param namespace 命名空间,可以为null
|
||||
* @param isPretty 是否格式化输出
|
||||
* @param omitXmlDeclaration 是否输出 xml Declaration
|
||||
* @return XML格式的字符串
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public static String mapToXmlStr(Map<?, ?> data, String rootName, String namespace, boolean isPretty, boolean omitXmlDeclaration) {
|
||||
@ -1211,7 +1203,6 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML格式的字符串
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
* @param data Map类型数据
|
||||
* @param rootName 根节点名
|
||||
* @param namespace 命名空间,可以为null
|
||||
@ -1219,6 +1210,7 @@ public class XmlUtil {
|
||||
* @param isPretty 是否格式化输出
|
||||
* @param omitXmlDeclaration 是否输出 xml Declaration
|
||||
* @return XML格式的字符串
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.1.2
|
||||
*/
|
||||
public static String mapToXmlStr(Map<?, ?> data, String rootName, String namespace, String charset, boolean isPretty, boolean omitXmlDeclaration) {
|
||||
@ -1228,10 +1220,10 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
* @param data Map类型数据
|
||||
* @param rootName 根节点名
|
||||
* @return XML
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 4.0.9
|
||||
*/
|
||||
public static Document mapToXml(Map<?, ?> data, String rootName) {
|
||||
@ -1241,11 +1233,11 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Map转换为XML
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
* @param data Map类型数据
|
||||
* @param rootName 根节点名
|
||||
* @param namespace 命名空间,可以为null
|
||||
* @return XML
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public static Document mapToXml(Map<?, ?> data, String rootName, String namespace) {
|
||||
@ -1259,9 +1251,9 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Bean转换为XML
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
* @param bean Bean对象
|
||||
* @return XML
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.3.4
|
||||
*/
|
||||
public static Document beanToXml(Object bean) {
|
||||
@ -1271,10 +1263,10 @@ public class XmlUtil {
|
||||
/**
|
||||
* 将Bean转换为XML
|
||||
*
|
||||
* @see JAXBUtil#beanToXml(Object) 可以解析多层xml;
|
||||
* @param bean Bean对象
|
||||
* @param namespace 命名空间,可以为null
|
||||
* @return XML
|
||||
* @see JAXBUtil#beanToXml(Object)
|
||||
* @since 5.2.4
|
||||
*/
|
||||
public static Document beanToXml(Object bean, String namespace) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user