List of utility methods to do XML JAXB Marshaller
String | marshal(Object obj) marshal return marshal(obj, obj.getClass());
|
org.w3c.dom.Element | marshal(Object obj) marshal try { Document doc = null; JAXBContext jc = getContext(obj.getClass()); Marshaller marshaller = jc.createMarshaller(); doc = dbf.newDocumentBuilder().newDocument(); marshaller.marshal(obj, doc); return doc.getDocumentElement(); } catch (ParserConfigurationException ex) { ... |
String | marshal(Object obj, Class> clazz) marshal String result = null; try { JAXBContext context = contextMap.get(clazz.getPackage().getName()); if (context == null) { context = JAXBContext.newInstance(clazz.getPackage().getName()); contextMap.put(clazz.getPackage().getName(), context); Marshaller m = context.createMarshaller(); ... |
void | marshal(Object obj, OutputStream out) marshal try { JAXBContext context = JAXBContext.newInstance(obj.getClass()); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(obj, out); } catch (JAXBException e) { throw new RuntimeException(e); |
void | marshal(Object obj, OutputStream out, Class... boundClasses) marshal try { Marshaller m = JAXBContext.newInstance(boundClasses).createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(obj, out); } catch (Exception ex) { |
void | marshal(Object obj, OutputStream stream) marshal JAXB.marshal(obj, stream); |
String | marshal(Object object) marshal StringWriter string = new StringWriter(); JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass()); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.FALSE); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marshaller.marshal(object, string); return string.toString(); |
String | marshal(Object object) marshal try { StringWriter writer = new StringWriter(); JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass()); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.marshal(object, writer); return writer.toString(); } catch (JAXBException e) { throw new RuntimeException("Error marshalling object", e); ... |
String | marshal(Object object) marshal StringWriter writer = new StringWriter(); JAXB.marshal(object, writer); return writer.toString(); |
void | marshal(Object object, File file, JAXBContext ctx) marshal Marshaller m = ctx.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(object, file); |