Refine search
public IndentXmlStreamWriter(Writer out) throws XMLStreamException { XMLOutputFactory factory = XMLOutputFactory.newInstance(); this.indent = 0; this.out = factory.createXMLStreamWriter(out); }
public XmlDocumentationWriter(final OutputStream out) throws XMLStreamException { this.writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out, "UTF-8"); }
private XmlWriter(Writer writer) { try { XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance(); stream = xmlFactory.createXMLStreamWriter(writer); } catch (Exception e) { throw new WriterException("Fail to initialize XML Stream writer", e); } }
XmlReportWriter(final MessageInterface messageInterface, final BufferedWriter writer) throws XMLStreamException { super(messageInterface); final XMLOutputFactory factory = XMLOutputFactory.newInstance(); xmlWriter = new IndentingXmlWriter(factory.createXMLStreamWriter(writer)); }
@Override public void write(final ConfigurableComponent configurableComponent, final OutputStream streamToWriteTo, final boolean includesAdditionalDocumentation) throws IOException { try { XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter( streamToWriteTo, "UTF-8"); xmlStreamWriter.writeDTD("<!DOCTYPE html>"); xmlStreamWriter.writeStartElement("html"); xmlStreamWriter.writeAttribute("lang", "en"); writeHead(configurableComponent, xmlStreamWriter); writeBody(configurableComponent, xmlStreamWriter, includesAdditionalDocumentation); xmlStreamWriter.writeEndElement(); xmlStreamWriter.close(); } catch (XMLStreamException | FactoryConfigurationError e) { throw new IOException("Unable to create XMLOutputStream", e); } }
@Test public void isStaxResult() throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter()); Result result = StaxUtils.createCustomStaxResult(streamWriter); assertTrue("Not a StAX Result", StaxUtils.isStaxResult(result)); }
@Test public void isStaxResultJaxp14() throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter()); StAXResult result = new StAXResult(streamWriter); assertTrue("Not a StAX Result", StaxUtils.isStaxResult(result)); }
@Test public void marshalJaxp14StaxResultStreamWriter() throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); StringWriter writer = new StringWriter(); XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); StAXResult result = new StAXResult(streamWriter); marshaller.marshal(flights, result); assertThat("Marshaller writes invalid StreamResult", writer.toString(), isSimilarTo(EXPECTED_STRING)); }
@Test public void marshalStaxResultStreamWriter() throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); StringWriter writer = new StringWriter(); XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); Result result = StaxUtils.createStaxResult(streamWriter); marshaller.marshal(flights, result); assertThat("Marshaller writes invalid StreamResult", writer.toString(), isSimilarTo(EXPECTED_STRING)); }
@Test public void marshalStaxResultXMLStreamWriter() throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); StringWriter writer = new StringWriter(); XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); Result result = StaxUtils.createStaxResult(streamWriter); marshaller.marshal(flight, result); assertThat("Marshaller writes invalid StreamResult", writer.toString(), isSimilarTo(EXPECTED_STRING)); }
XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = factory.createXMLStreamWriter(stringWriter);
private void writeFile(TimerImpl timer) { final File file = fileName(timer.getTimedObjectId(), timer.getId()); //if the timer is expired or cancelled delete the file if (timer.getState() == TimerState.CANCELED || timer.getState() == TimerState.EXPIRED) { if (file.exists()) { file.delete(); } return; } try { FileOutputStream out = new FileOutputStream(file); try { XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out); XMLMapper mapper = createMapper(timer.getTimerService()); mapper.deparseDocument(new EjbTimerXmlPersister(factory, configuration), Collections.singletonList(timer), writer); writer.flush(); writer.close(); } finally { safeClose(out); } } catch (Exception e) { throw new RuntimeException(e); } }
_stringWriter = new StringWriter(); try { XMLOutputFactory xof = XMLOutputFactory.newInstance(); XMLStreamWriter xsw = xof.createXMLStreamWriter(_stringWriter); _active = true; return new StAXResult(xsw);
_stringWriter = new StringWriter(); try { XMLOutputFactory xof = XMLOutputFactory.newInstance(); XMLStreamWriter xsw = xof.createXMLStreamWriter(_stringWriter); _active = true; return (T) new StAXResult(xsw);
XMLOutputFactory xof = XMLOutputFactory.newInstance(); OutputStreamWriter out = new OutputStreamWriter(outputStream, encoding); XMLStreamWriter writer = xof.createXMLStreamWriter(out); XMLStreamWriter xtw = new IndentingXMLStreamWriter(writer);
XMLOutputFactory factory = XMLOutputFactory.newInstance(); writer = new IndentingXMLStreamWriter(factory.createXMLStreamWriter(out, charSet)); } else { writer = factory.createXMLStreamWriter(out, charSet);
XMLOutputFactory xof = XMLOutputFactory.newInstance(); OutputStreamWriter out = new OutputStreamWriter(outputStream, encoding); XMLStreamWriter writer = xof.createXMLStreamWriter(out); XMLStreamWriter xtw = new IndentingXMLStreamWriter(writer);
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); xmlWriter = outputFactory.createXMLStreamWriter(baos, "UTF-8"); xmlWriter = outputFactory.createXMLStreamWriter(baos, "UTF-8");
/** * Initializes a new instance. * * @param service the service * @param stream the stream * @throws XMLStreamException the XML stream exception */ public EwsServiceXmlWriter(ExchangeServiceBase service, OutputStream stream) throws XMLStreamException { this.service = service; XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); xmlWriter = xmlof.createXMLStreamWriter(stream, "utf-8"); }
/** * Get a new XML stream writer. * * @param output * An underlying OutputStream to write to. * @return a new {@link XMLStreamWriter} which writes to the specified * OutputStream. The output written by this XMLStreamWriter is * understandable by XMLStreamReaders produced by * {@link #createStreamReader(InputStream)}. * @throws XMLStreamException */ // Provides hook for subclasses to override how marshalling results are // serialized (ex. encoding). protected XMLStreamWriter createStreamWriter(OutputStream output) throws XMLStreamException { if (outputFactory == null) { outputFactory = XMLOutputFactory.newInstance(); } return outputFactory.createXMLStreamWriter(output); }