View gist:be3f257555e32a057b9e76dde270ba07
public class ReportDefintionBase { | |
public static final String T = "t"; | |
public static final String F = "f"; | |
public final String toXMLString() { | |
StringWriter stringWriter = new StringWriter(); | |
Marshaller marshaller = null; | |
try { | |
marshaller = JAXBContext.newInstance(this.getClass()).createMarshaller(); |
View java
public class XmlHelper { | |
private static Logger logger = LoggerFactory.getLogger(XmlHelper.class); | |
public static <T> T fromXml(String xml, Class<?> clazz) { | |
Unmarshaller um = null; | |
try { | |
um = JAXBContext.newInstance(clazz).createUnmarshaller(); | |
Object obj = um.unmarshal(new StringReader(xml)); | |
return (T) obj; |