public static String toString(Object o) {
if (!(o instanceof JAXBElement) && o.getClass().getAnnotation(XmlRootElement.class) == null
&& o.getClass().getAnnotation(XmlType.class)!= null) {
o = new JAXBElement(new QName("uri:lens:cube:0.1", o.getClass().getAnnotation(XmlType.class).name()),
o.getClass(), null, o);
}
try {
StringWriter stringWriter = new StringWriter();
Class cl = null;
if (o instanceof JAXBElement) {
cl = ((JAXBElement) o).getDeclaredType();
} else {
cl = o.getClass();
}
Marshaller marshaller = getLensJAXBContext(cl).createMarshaller();
marshaller.marshal(o, stringWriter);
return stringWriter.toString();
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
ToXMLString.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:lens
作者:
评论列表
文章目录