Package com.luna.common.xml
Class JAXBUtil
java.lang.Object
com.luna.common.xml.JAXBUtil
JAXB(Java Architecture for XML Binding),根据XML Schema产生Java对象,即实现xml和Bean互转。
相关介绍:
- https://www.cnblogs.com/yanghaolie/p/11110991.html
- https://my.oschina.net/u/4266515/blog/3330113
- Since:
- 5.7.3
- Author:
- dazer
- See Also:
-
Constructor Details
-
JAXBUtil
public JAXBUtil()
-
-
Method Details
-
beanToXml
JavaBean转换成xmlbean上面用的常用注解
- Parameters:
bean
- Bean对象- Returns:
- 输出的XML字符串
- See Also:
-
@XmlRootElement(name = "school")
@XmlElement(name = "school_name", required = true)
@XmlElementWrapper(name="schools")
JAXB "有两个名为 "**" 的属性,类的两个属性具有相同名称 "**""解决方案
-
beanToXml
JavaBean转换成xml- Parameters:
bean
- Bean对象charset
- 编码 eg: utf-8format
- 是否格式化输出eg: true- Returns:
- 输出的XML字符串
-
xmlToBean
xml转换成JavaBean- Type Parameters:
T
- Bean类型- Parameters:
xml
- XML字符串c
- Bean类型- Returns:
- bean
-
xmlToBean
XML文件转Bean- Type Parameters:
T
- Bean类型- Parameters:
file
- 文件charset
- 编码c
- Bean类- Returns:
- Bean
-
xmlToBean
从Reader
中读取XML字符串,并转换为Bean- Type Parameters:
T
- Bean类型- Parameters:
reader
-Reader
c
- Bean类- Returns:
- Bean
-