List of utility methods to do XML JAXB Marshaller
void | marshalPackage(OutputStream printStream, final Package p) marshal Package JAXBContext jc = JAXBContext.newInstance(ORG_ZEND_SDKLIB_DESCRIPTOR_PKG); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(p, printStream); |
String | marshalToString(Object obj) marshal To String StringWriter stringWriter = new StringWriter(); JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass()); Marshaller marshaller = jaxbContext.createMarshaller(); JAXBElement jaxbElement = new JAXBElement(new QName("ROOT"), obj.getClass(), obj); marshaller.marshal(jaxbElement, stringWriter); return stringWriter.toString(); |
String | marshalToString(Object obj) marshal To String StringWriter writer = new StringWriter(); JAXBContext jc = getContext(obj.getClass()); Marshaller marshaller = jc.createMarshaller(); marshaller.marshal(obj, writer); return writer.toString(); |
String | marshalV2(Class marshal V StringWriter out = new StringWriter(); JAXBContext context = JAXBContext.newInstance(clazz); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(new JAXBElement<T>(new QName(uri, nodeName), clazz, obj), out); return out.toString(); |
void | removeStandalone(final Marshaller marshaller) remove Standalone marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); |
void | setEncoding(@Nonnull final Marshaller aMarshaller, @Nullable final Charset aEncoding) Set the standard property for the encoding charset. setEncoding(aMarshaller, aEncoding == null ? null : aEncoding.name()); |
String | xmlMarshal(Object obj, Class> clazz) xml Marshal StringWriter stringWriter = new StringWriter(); try { JAXBContext context = JAXBContext.newInstance(clazz); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(obj, stringWriter); } catch (JAXBException e) { e.printStackTrace(); return stringWriter.toString(); |