protected XMLOutputFactory getXMLOutputFactory() { return XmlFactories.getXof(); }
public void write(OutputStream is, T o, RuntimeContext context) throws Exception { XMLStreamWriter w = XmlFactories.getXof().createXMLStreamWriter(is); try { write(w, o); } finally { w.close(); } }
public void marshal(Object jaxbElement, Result result) throws JAXBException { if (jaxbElement == null) throw new IllegalArgumentException("jaxbElement is null"); if (result == null) throw new IllegalArgumentException("result is null"); XMLStreamWriter writer = null; try { if (result instanceof DOMResult) { Node node = ((DOMResult) result).getNode(); if (node instanceof Document) { writer = new W3CDOMStreamWriter((Document) node); } else if (node instanceof Element) { writer = new W3CDOMStreamWriter((Element) node); } else { throw new UnsupportedOperationException("Node type not supported."); } } else { writer = XmlFactories.getXof().createXMLStreamWriter(result); } marshal(jaxbElement, writer); } catch (XMLStreamException e) { throw new JAXBException("Could not close XMLStreamWriter.", e); } finally { if (writer != null) { try { writer.close(); } catch (XMLStreamException ignored) { } } } }