/** * Gives the underlying stream for XMLStreamWriter. It closes any start elements, and returns the * stream so that JAXB can write infoset directly to the stream. * * @param writer XMLStreamWriter for which stream is required * @return underlying OutputStream, null if writer doesn't provide a way to get it * @throws XMLStreamException if any of writer operations throw the exception */ public static @Nullable OutputStream getOutputStream(XMLStreamWriter writer) throws XMLStreamException { Object obj = null; // Hack for JDK6's SJSXP if (writer instanceof Map) { obj = ((Map) writer).get("sjsxp-outputstream"); } // woodstox if (obj == null) { try { obj = writer.getProperty("com.ctc.wstx.outputUnderlyingStream"); } catch (Exception ie) { // Catch all exceptions. SJSXP in JDK throws NPE // nothing to do here } } // SJSXP if (obj == null) { try { obj = writer.getProperty("http://java.sun.com/xml/stream/properties/outputstream"); } catch (Exception ie) { // Catch all exceptions. SJSXP in JDK throws NPE // nothing to do here } } if (obj != null) { writer.writeCharacters(""); // Force completion of open elems writer.flush(); return (OutputStream) obj; } return null; }
public Object getProperty(String name) throws IllegalArgumentException { return writer.getProperty(name); }
public java.lang.Object getProperty(java.lang.String name) throws IllegalArgumentException { return baseWriter.getProperty(name); }