Search in sources :

Example 41 with XMLOutputFactory

use of javax.xml.stream.XMLOutputFactory in project jqa-core-framework by buschmais.

the class RuleSetWriterImpl method marshal.

private void marshal(Writer writer, JqassistantRules rules) {
    XMLOutputFactory xof = XMLOutputFactory.newInstance();
    XMLStreamWriter streamWriter = null;
    try {
        streamWriter = xof.createXMLStreamWriter(writer);
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
    XMLStreamWriter indentingStreamWriter = new IndentingXMLStreamWriter(new CDataXMLStreamWriter(streamWriter));
    try {
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        marshaller.marshal(rules, indentingStreamWriter);
    } catch (JAXBException e) {
        throw new IllegalArgumentException("Cannot write rules to " + writer, e);
    }
}
Also used : IndentingXMLStreamWriter(com.sun.xml.txw2.output.IndentingXMLStreamWriter) XMLOutputFactory(javax.xml.stream.XMLOutputFactory) Marshaller(javax.xml.bind.Marshaller) CDataXMLStreamWriter(com.buschmais.jqassistant.core.rule.impl.reader.CDataXMLStreamWriter) XMLStreamException(javax.xml.stream.XMLStreamException) IndentingXMLStreamWriter(com.sun.xml.txw2.output.IndentingXMLStreamWriter) CDataXMLStreamWriter(com.buschmais.jqassistant.core.rule.impl.reader.CDataXMLStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) JAXBException(javax.xml.bind.JAXBException)

Example 42 with XMLOutputFactory

use of javax.xml.stream.XMLOutputFactory in project CFLint by cflint.

the class DefaultCFlintResultMarshaller method output.

@Override
public void output(BugList bugList, Writer writer, boolean showStats) throws MarshallerException {
    try {
        final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
        XMLStreamWriter xtw = new IndentingXMLStreamWriter(xmlOutputFactory.createXMLStreamWriter(writer));
        writeIssues(bugList, xtw, showStats);
        xtw.flush();
    } catch (XMLStreamException e) {
        throw new MarshallerException(e);
    }
}
Also used : IndentingXMLStreamWriter(javanet.staxutils.IndentingXMLStreamWriter) XMLOutputFactory(javax.xml.stream.XMLOutputFactory) MarshallerException(com.cflint.xml.MarshallerException) XMLStreamException(javax.xml.stream.XMLStreamException) IndentingXMLStreamWriter(javanet.staxutils.IndentingXMLStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter)

Aggregations

XMLOutputFactory (javax.xml.stream.XMLOutputFactory)42 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)28 StringWriter (java.io.StringWriter)18 XMLStreamException (javax.xml.stream.XMLStreamException)15 XMLEventWriter (javax.xml.stream.XMLEventWriter)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 Test (org.junit.Test)8 StAXResult (javax.xml.transform.stax.StAXResult)7 IOException (java.io.IOException)6 DOMResult (javax.xml.transform.dom.DOMResult)6 StreamResult (javax.xml.transform.stream.StreamResult)6 Result (javax.xml.transform.Result)5 PcrManifest (com.intel.mountwilson.manifest.data.PcrManifest)3 OutputStream (java.io.OutputStream)3 SAXResult (javax.xml.transform.sax.SAXResult)3 IManifest (com.intel.mountwilson.manifest.data.IManifest)2 Headers (com.sun.net.httpserver.Headers)2 OutputStreamWriter (java.io.OutputStreamWriter)2 InetSocketAddress (java.net.InetSocketAddress)2 Path (java.nio.file.Path)2